Documentation
¶
Index ¶
- Variables
- func EnsureDir(dir string) error
- func GetModulePath(baseDir, moduleType, name, version string) string
- func GetTemplatePath(baseDir, category, name, version string) string
- func ListModules(baseDir string) (map[string][]string, error)
- func ListTemplates(baseDir string) ([]string, error)
- func SanitizeFilename(name string) string
- type DetectionCriteria
- type DetectorConfig
- type Module
- type ModuleInfo
- type ModuleType
- type ProviderConfig
- type Template
- func (t *Template) Clone() *Template
- func (t *Template) GetAuthor() string
- func (t *Template) GetCategory() string
- func (t *Template) GetDescription() string
- func (t *Template) GetID() string
- func (t *Template) GetMetadata() map[string]interface{}
- func (t *Template) GetName() string
- func (t *Template) GetReferences() []string
- func (t *Template) GetSeverity() string
- func (t *Template) GetTags() []string
- func (t *Template) GetVersion() string
- func (t *Template) SaveToFile(filePath string) error
- func (t *Template) Validate() error
- func (t *Template) ValidateStructure() []string
- func (t *Template) Version() string
- type TemplateContent
- func (c *TemplateContent) AddSection(sectionType, content string)
- func (c *TemplateContent) AddVariable(name string, value interface{})
- func (c *TemplateContent) Clone() *TemplateContent
- func (c *TemplateContent) GetSectionContent(sectionType string) (string, bool)
- func (c *TemplateContent) GetSections(sectionType string) []TemplateSection
- func (c *TemplateContent) GetVariable(name string) (interface{}, bool)
- type TemplateInfo
- type TemplateSection
- type TestDefinition
- type TestVariation
- type UtilityConfig
Constants ¶
This section is empty.
Variables ¶
var ValidConditions = []string{"contains", "not_contains"}
ValidConditions defines the valid conditions for detection criteria
var ValidDetectionTypes = []string{"string_match", "regex_match", "semantic_match"}
ValidDetectionTypes defines the valid detection types for templates
var ValidSeverityLevels = []string{"info", "low", "medium", "high", "critical"}
ValidSeverityLevels defines the valid severity levels for templates
Functions ¶
func GetModulePath ¶
GetModulePath returns the full path for a module file
func GetTemplatePath ¶
GetTemplatePath returns the full path for a template file
func ListModules ¶
ListModules lists all module files in a directory
func ListTemplates ¶
ListTemplates lists all template files in a directory
func SanitizeFilename ¶
SanitizeFilename sanitizes a string for use as a filename
Types ¶
type DetectionCriteria ¶
type DetectionCriteria struct {
Type string `yaml:"type" json:"type"`
Match string `yaml:"match,omitempty" json:"match,omitempty"`
Pattern string `yaml:"pattern,omitempty" json:"pattern,omitempty"`
Criteria string `yaml:"criteria,omitempty" json:"criteria,omitempty"`
Condition string `yaml:"condition,omitempty" json:"condition,omitempty"`
}
DetectionCriteria represents the detection criteria for a test
type DetectorConfig ¶
type DetectorConfig struct {
DetectionType string `yaml:"detection_type" json:"detection_type"`
DefaultOptions map[string]interface{} `yaml:"default_options,omitempty" json:"default_options,omitempty"`
}
DetectorConfig represents the configuration for a detector module
type Module ¶
type Module struct {
ID string `yaml:"id" json:"id"`
Type ModuleType `yaml:"type" json:"type"`
Info ModuleInfo `yaml:"info" json:"info"`
Compatibility *compatibility.CompatibilityMetadata `yaml:"compatibility" json:"compatibility"`
Provider *ProviderConfig `yaml:"provider,omitempty" json:"provider,omitempty"`
Utility *UtilityConfig `yaml:"utility,omitempty" json:"utility,omitempty"`
Detector *DetectorConfig `yaml:"detector,omitempty" json:"detector,omitempty"`
}
Module represents a module definition (provider, utility, or detector)
func LoadModuleFromFile ¶
LoadModuleFromFile loads a module from a YAML file
func NewModule ¶
func NewModule(moduleType ModuleType) *Module
NewModule creates a new module with default values
func (*Module) SaveToFile ¶
SaveToFile saves a module to a YAML file
type ModuleInfo ¶
type ModuleInfo struct {
Name string `yaml:"name" json:"name"`
Description string `yaml:"description" json:"description"`
Version string `yaml:"version" json:"version"`
Author string `yaml:"author" json:"author"`
Tags []string `yaml:"tags,omitempty" json:"tags,omitempty"`
References []string `yaml:"references,omitempty" json:"references,omitempty"`
}
ModuleInfo represents the basic information section of a module
type ModuleType ¶
type ModuleType string
ModuleType represents the type of module
const ( ProviderModule ModuleType = "provider" UtilityModule ModuleType = "utility" DetectorModule ModuleType = "detector" )
Available module types
func GetModuleType ¶
func GetModuleType(dirPath string) (ModuleType, error)
GetModuleType returns the module type based on the directory
type ProviderConfig ¶
type ProviderConfig struct {
SupportedModels []string `yaml:"supported_models" json:"supported_models"`
Features []string `yaml:"features" json:"features"`
DefaultOptions map[string]interface{} `yaml:"default_options,omitempty" json:"default_options,omitempty"`
RateLimits struct {
RequestsPerMinute int `yaml:"requests_per_minute,omitempty" json:"requests_per_minute,omitempty"`
TokensPerMinute int `yaml:"tokens_per_minute,omitempty" json:"tokens_per_minute,omitempty"`
} `yaml:"rate_limits,omitempty" json:"rate_limits,omitempty"`
}
ProviderConfig represents the configuration for a provider module
type Template ¶
type Template struct {
ID string `yaml:"id" json:"id"`
Info TemplateInfo `yaml:"info" json:"info"`
Compatibility *compatibility.CompatibilityMetadata `yaml:"compatibility" json:"compatibility"`
Test TestDefinition `yaml:"test" json:"test"`
Content []byte `json:"-"` // Raw content for caching
Variables map[string]interface{} `yaml:"variables,omitempty" json:"variables,omitempty"`
Parent string `yaml:"parent,omitempty" json:"parent,omitempty"`
Metadata map[string]interface{} `yaml:"metadata,omitempty" json:"metadata,omitempty"`
}
Template represents a vulnerability test template
func LoadFromFile ¶
LoadFromFile loads a template from a YAML file
func NewTemplate ¶
func NewTemplate() *Template
NewTemplate creates a new template with default values
func ParseTemplate ¶
ParseTemplate parses a template from bytes
func (*Template) GetCategory ¶
GetCategory returns the template category
func (*Template) GetDescription ¶
GetDescription returns the template description
func (*Template) GetMetadata ¶
GetMetadata returns the template metadata
func (*Template) GetReferences ¶
GetReferences returns the template references
func (*Template) GetSeverity ¶
GetSeverity returns the template severity
func (*Template) GetVersion ¶
GetVersion returns the template version
func (*Template) SaveToFile ¶
SaveToFile saves a template to a YAML file
func (*Template) Validate ¶
Validate validates the template and returns an error if invalid (implements Template interface)
func (*Template) ValidateStructure ¶
ValidateStructure validates the template structure and returns validation issues
type TemplateContent ¶
type TemplateContent struct {
// Sections is a list of template sections
Sections []TemplateSection
// Variables is a map of variable names to values
Variables map[string]interface{}
}
TemplateContent represents the content of a template
func NewTemplateContent ¶
func NewTemplateContent() *TemplateContent
NewTemplateContent creates a new template content
func (*TemplateContent) AddSection ¶
func (c *TemplateContent) AddSection(sectionType, content string)
AddSection adds a section to the template content
func (*TemplateContent) AddVariable ¶
func (c *TemplateContent) AddVariable(name string, value interface{})
AddVariable adds a variable to the template content
func (*TemplateContent) Clone ¶
func (c *TemplateContent) Clone() *TemplateContent
Clone creates a deep copy of the template content
func (*TemplateContent) GetSectionContent ¶
func (c *TemplateContent) GetSectionContent(sectionType string) (string, bool)
GetSectionContent gets the content of the first section of a specific type
func (*TemplateContent) GetSections ¶
func (c *TemplateContent) GetSections(sectionType string) []TemplateSection
GetSections gets all sections of a specific type
func (*TemplateContent) GetVariable ¶
func (c *TemplateContent) GetVariable(name string) (interface{}, bool)
GetVariable gets a variable from the template content
type TemplateInfo ¶
type TemplateInfo struct {
Name string `yaml:"name" json:"name"`
Description string `yaml:"description" json:"description"`
Version string `yaml:"version" json:"version"`
Author string `yaml:"author" json:"author"`
Severity string `yaml:"severity" json:"severity"`
Tags []string `yaml:"tags,omitempty" json:"tags,omitempty"`
References []string `yaml:"references,omitempty" json:"references,omitempty"`
Compliance struct {
OWASP string `yaml:"owasp,omitempty" json:"owasp,omitempty"`
ISO string `yaml:"iso,omitempty" json:"iso,omitempty"`
} `yaml:"compliance,omitempty" json:"compliance,omitempty"`
}
TemplateInfo represents the basic information section of a template
type TemplateSection ¶
type TemplateSection struct {
// Type is the type of the section
Type string
// Content is the content of the section
Content string
}
TemplateSection represents a section of a template
type TestDefinition ¶
type TestDefinition struct {
Prompt string `yaml:"prompt" json:"prompt"`
ExpectedBehavior string `yaml:"expected_behavior,omitempty" json:"expected_behavior,omitempty"`
Detection DetectionCriteria `yaml:"detection" json:"detection"`
Variations []TestVariation `yaml:"variations,omitempty" json:"variations,omitempty"`
}
TestDefinition represents the test section of a template
type TestVariation ¶
type TestVariation struct {
Prompt string `yaml:"prompt" json:"prompt"`
Detection DetectionCriteria `yaml:"detection" json:"detection"`
}
TestVariation represents a variation of a test
type UtilityConfig ¶
type UtilityConfig struct {
Functions []string `yaml:"functions" json:"functions"`
DefaultOptions map[string]interface{} `yaml:"default_options,omitempty" json:"default_options,omitempty"`
}
UtilityConfig represents the configuration for a utility module