validation

package
v0.4.5-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package validation provides infrastructure for validating profile configurations. This includes structural validation and JSON Schema validation for plugin configs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidatePluginName

func ValidatePluginName(name string) error

ValidatePluginName validates that a plugin name is safe to use in filesystem paths. This prevents path traversal attacks when loading plugins. EXPORTED for use by other packages that need to validate plugin names.

Types

type PluginSchemaProvider

type PluginSchemaProvider interface {
	// GetPluginSchema returns the JSON Schema for a plugin's configuration.
	// Returns nil if the plugin is not found.
	GetPluginSchema(ctx context.Context, pluginName string) ([]byte, error)
}

PluginSchemaProvider is an interface for loading plugins and retrieving their schemas. This allows validation code to be decoupled from the WASM runtime implementation.

type ProfileValidator

type ProfileValidator struct{}

ProfileValidator validates profile configurations.

func NewProfileValidator

func NewProfileValidator() *ProfileValidator

NewProfileValidator creates a new profile validator.

func (*ProfileValidator) Validate

func (v *ProfileValidator) Validate(profile *entities.Profile) error

Validate performs comprehensive structural validation of a profile. Returns an error describing all validation failures found. This performs structural validation only - no schema validation.

func (*ProfileValidator) ValidateWithSchemas

func (v *ProfileValidator) ValidateWithSchemas(ctx context.Context, profile *entities.Profile, provider PluginSchemaProvider) error

ValidateWithSchemas performs comprehensive validation including plugin config schema validation. This requires a PluginSchemaProvider to fetch plugin schemas during validation. Use this for pre-flight validation before execution.

type SchemaCompiler

type SchemaCompiler struct {
	// contains filtered or unexported fields
}

SchemaCompiler caches compiled JSON schemas to avoid repeated compilation overhead. For profiles with many observations using the same plugin, this significantly improves validation performance by compiling each unique schema only once.

func NewSchemaCompiler

func NewSchemaCompiler(provider PluginSchemaProvider) *SchemaCompiler

NewSchemaCompiler creates a new schema compiler that wraps a PluginSchemaProvider.

func (*SchemaCompiler) GetCompiledSchema

func (sc *SchemaCompiler) GetCompiledSchema(ctx context.Context, pluginName string) (*jsonschema.Schema, error)

GetCompiledSchema returns a compiled JSON schema for the given plugin. Schemas are cached after first compilation for performance.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL