Documentation
¶
Index ¶
- 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 Module
- type ModuleInfo
- type ModuleType
- type Template
- func (t *Template) Clone() *Template
- func (t *Template) GetAuthor() string
- func (t *Template) GetCategory() string
- func (t *Template) GetContent() ([]byte, error)
- func (t *Template) GetDescription() string
- func (t *Template) GetID() string
- 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) Save(dir string) error
- func (t *Template) Validate() error
- func (t *Template) ValidateStructure() error
- type TemplateCompatibility
- 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 TemplateDetection
- type TemplateInfo
- type TemplateSection
- type TemplateTest
- type TemplateVariation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetModulePath ¶
GetModulePath returns the full path for a module file
func GetTemplatePath ¶
GetTemplatePath returns the full path for a template file
func ListTemplates ¶
ListTemplates lists all template files in a directory
func SanitizeFilename ¶
SanitizeFilename sanitizes a string for use as a filename
Types ¶
type Module ¶
type Module struct {
ID string
Name string
Type ModuleType
Version string
Path string
Description string
Info *ModuleInfo
}
Module represents a template module
func LoadModule ¶ added in v0.8.0
LoadModule loads a module from the given path
func LoadModuleFromFile ¶
LoadModuleFromFile loads a module from a file (alias for LoadModule)
type ModuleInfo ¶
type ModuleInfo struct {
Name string
Version string
Description string
Author string
Tags []string
}
ModuleInfo contains module metadata
type ModuleType ¶
type ModuleType string
ModuleType represents the type of a module
const ( ProviderModule ModuleType = "provider" UtilityModule ModuleType = "utility" DetectorModule ModuleType = "detector" )
Module type constants
type Template ¶
type Template struct {
ID string
Name string
Version string
Path string
Content []byte
Metadata map[string]interface{}
Variables map[string]interface{}
Info *TemplateInfo
Test *TemplateTest
Compatibility *TemplateCompatibility
}
Template represents a security template
func LoadFromFile ¶
LoadFromFile loads a template from a file (alias for LoadTemplate)
func LoadTemplate ¶ added in v0.8.0
LoadTemplate loads a template from the given path
func ParseTemplate ¶
ParseTemplate parses a template from the given content bytes
func (*Template) GetCategory ¶
GetCategory returns the template category (derived from tags or metadata)
func (*Template) GetContent ¶ added in v0.8.0
GetContent returns the template content
func (*Template) GetDescription ¶
GetDescription returns the template description
func (*Template) GetReferences ¶
GetReferences returns template references
func (*Template) GetSeverity ¶
GetSeverity returns the template severity
func (*Template) GetVersion ¶
GetVersion returns the template version
func (*Template) ValidateStructure ¶
ValidateStructure validates the template structure
type TemplateCompatibility ¶ added in v0.8.0
TemplateCompatibility contains template compatibility information
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 TemplateDetection ¶ added in v0.8.0
type TemplateDetection struct {
Type string `json:"type"`
Pattern string `json:"pattern,omitempty"`
Match string `json:"match,omitempty"`
Criteria string `json:"criteria,omitempty"`
}
TemplateDetection contains detection criteria for templates
type TemplateInfo ¶
type TemplateInfo struct {
Name string
Version string
Description string
Author string
Severity string
Tags []string
}
TemplateInfo contains template information
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 TemplateTest ¶ added in v0.8.0
type TemplateTest struct {
Prompt string `json:"prompt"`
Expected string `json:"expected,omitempty"`
Detection *TemplateDetection `json:"detection,omitempty"`
Variations []*TemplateVariation `json:"variations,omitempty"`
}
TemplateTest contains template test information
type TemplateVariation ¶ added in v0.8.0
type TemplateVariation struct {
Prompt string `json:"prompt"`
Expected string `json:"expected,omitempty"`
Detection *TemplateDetection `json:"detection,omitempty"`
}
TemplateVariation contains a variation of the template test