
Research
/Security News
Malicious npm Packages Target WhatsApp Developers with Remote Kill Switch
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
github.com/CrisisTextLine/modular/modules/jsonschema
A Modular module that provides JSON Schema validation capabilities.
The JSON Schema module provides a service for validating JSON data against JSON Schema specifications. It wraps github.com/santhosh-tekuri/jsonschema/v6 to provide a clean, service-oriented interface that integrates with the Modular framework.
go get github.com/CrisisTextLine/modular/modules/jsonschema@v1.0.0
import (
"github.com/CrisisTextLine/modular"
"github.com/CrisisTextLine/modular/modules/jsonschema"
)
func main() {
app := modular.NewStdApplication(
modular.NewStdConfigProvider(nil),
logger,
)
// Register the JSON Schema module
app.RegisterModule(jsonschema.NewModule())
// Register your modules that depend on the schema service
app.RegisterModule(NewYourModule())
// Run the application
if err := app.Run(); err != nil {
logger.Error("Application error", "error", err)
}
}
type YourModule struct {
schemaService jsonschema.JSONSchemaService
}
// Request the JSON Schema service
func (m *YourModule) RequiresServices() []modular.ServiceDependency {
return []modular.ServiceDependency{
{
Name: "jsonschema.service",
Required: true,
SatisfiesInterface: reflect.TypeOf((*jsonschema.JSONSchemaService)(nil)).Elem(),
},
}
}
// Inject the service using constructor injection
func (m *YourModule) Constructor() modular.ModuleConstructor {
return func(app *modular.StdApplication, services map[string]any) (modular.Module, error) {
schemaService, ok := services["jsonschema.service"].(jsonschema.JSONSchemaService)
if !ok {
return nil, fmt.Errorf("service 'jsonschema.service' not found or wrong type")
}
return &YourModule{
schemaService: schemaService,
}, nil
}
}
// Example of using the schema service
func (m *YourModule) ValidateData(schemaPath string, data []byte) error {
// Compile the schema
schema, err := m.schemaService.CompileSchema(schemaPath)
if err != nil {
return fmt.Errorf("failed to compile schema: %w", err)
}
// Validate data against the schema
if err := m.schemaService.ValidateBytes(schema, data); err != nil {
return fmt.Errorf("validation failed: %w", err)
}
return nil
}
type Schema interface {
// Validate validates the given value against the JSON schema
Validate(value interface{}) error
}
type JSONSchemaService interface {
// CompileSchema compiles a JSON schema from a file path or URL
CompileSchema(source string) (Schema, error)
// ValidateBytes validates raw JSON data against a compiled schema
ValidateBytes(schema Schema, data []byte) error
// ValidateReader validates JSON from an io.Reader against a compiled schema
ValidateReader(schema Schema, reader io.Reader) error
// ValidateInterface validates a Go interface{} against a compiled schema
ValidateInterface(schema Schema, data interface{}) error
}
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
Research
/Security News
Socket uncovered 11 malicious Go packages using obfuscated loaders to fetch and execute second-stage payloads via C2 domains.
Security News
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.