format

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureDir

func EnsureDir(dir string) error

EnsureDir ensures that a directory exists

func GetModulePath

func GetModulePath(baseDir, moduleType, name, version string) string

GetModulePath returns the full path for a module file

func GetTemplatePath

func GetTemplatePath(baseDir, category, name, version string) string

GetTemplatePath returns the full path for a template file

func ListModules

func ListModules(baseDir string) (map[string][]string, error)

func ListTemplates

func ListTemplates(baseDir string) ([]string, error)

ListTemplates lists all template files in a directory

func SanitizeFilename

func SanitizeFilename(name string) string

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

func LoadModule(path string) (*Module, error)

LoadModule loads a module from the given path

func LoadModuleFromFile

func LoadModuleFromFile(path string) (*Module, error)

LoadModuleFromFile loads a module from a file (alias for LoadModule)

func (*Module) Save added in v0.8.0

func (m *Module) Save(dir string) error

Save saves the module to the specified directory

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

func LoadFromFile(path string) (*Template, error)

LoadFromFile loads a template from a file (alias for LoadTemplate)

func LoadTemplate added in v0.8.0

func LoadTemplate(path string) (*Template, error)

LoadTemplate loads a template from the given path

func ParseTemplate

func ParseTemplate(content []byte) (*Template, error)

ParseTemplate parses a template from the given content bytes

func (*Template) Clone

func (t *Template) Clone() *Template

Clone creates a deep copy of the template

func (*Template) GetAuthor

func (t *Template) GetAuthor() string

GetAuthor returns the template author

func (*Template) GetCategory

func (t *Template) GetCategory() string

GetCategory returns the template category (derived from tags or metadata)

func (*Template) GetContent added in v0.8.0

func (t *Template) GetContent() ([]byte, error)

GetContent returns the template content

func (*Template) GetDescription

func (t *Template) GetDescription() string

GetDescription returns the template description

func (*Template) GetID

func (t *Template) GetID() string

GetID returns the template ID

func (*Template) GetName

func (t *Template) GetName() string

GetName returns the template name

func (*Template) GetReferences

func (t *Template) GetReferences() []string

GetReferences returns template references

func (*Template) GetSeverity

func (t *Template) GetSeverity() string

GetSeverity returns the template severity

func (*Template) GetTags

func (t *Template) GetTags() []string

GetTags returns the template tags

func (*Template) GetVersion

func (t *Template) GetVersion() string

GetVersion returns the template version

func (*Template) Save added in v0.8.0

func (t *Template) Save(dir string) error

Save saves the template to the specified directory

func (*Template) Validate

func (t *Template) Validate() error

Validate validates the template

func (*Template) ValidateStructure

func (t *Template) ValidateStructure() error

ValidateStructure validates the template structure

type TemplateCompatibility added in v0.8.0

type TemplateCompatibility struct {
	MinToolVersion string
	MaxToolVersion string
}

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

Jump to

Keyboard shortcuts

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