templates

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMissingID is returned when template validation fails due to missing id field.
	ErrMissingID = errors.New("template validation failed: 'id' is required")

	// ErrMissingName is returned when template validation fails due to missing info.name field.
	ErrMissingName = errors.New("template validation failed: 'info.name' is required")

	// ErrMissingDetector is returned when template validation fails due to missing info.detector field.
	ErrMissingDetector = errors.New("template validation failed: 'info.detector' is required")

	// ErrInvalidSeverity is returned when template validation fails due to invalid severity value.
	ErrInvalidSeverity = errors.New("template validation failed: invalid severity")

	// ErrEmptyPrompts is returned when template validation fails due to empty prompts array.
	ErrEmptyPrompts = errors.New("template validation failed: 'prompts' cannot be empty")
)

Functions

This section is empty.

Types

type Loader

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

Loader loads probe templates from an embedded filesystem.

func NewLoader

func NewLoader(fs embed.FS, basedir string) *Loader

NewLoader creates a new template loader.

func (*Loader) Load

func (l *Loader) Load(filename string) (*ProbeTemplate, error)

Load loads a single template by filename.

func (*Loader) LoadAll

func (l *Loader) LoadAll() ([]*ProbeTemplate, error)

LoadAll loads all YAML templates from the embedded filesystem.

type ProbeInfo

type ProbeInfo struct {
	// Name is the human-readable probe name
	Name string `yaml:"name"`

	// Author identifies who created the template
	Author string `yaml:"author"`

	// Description explains what the probe does
	Description string `yaml:"description"`

	// Goal matches the probe goal
	Goal string `yaml:"goal"`

	// Detector is the recommended detector for this probe
	Detector string `yaml:"detector"`

	// Tags for categorization and filtering
	Tags []string `yaml:"tags"`

	// Severity indicates potential impact (info, low, medium, high, critical)
	Severity string `yaml:"severity"`

	// Security classification (optional)
	CWEIDs      []string `yaml:"cwe,omitempty"`
	MITREAttack []string `yaml:"mitre_attack,omitempty"`
	OWASPTopTen []string `yaml:"owasp,omitempty"`
}

ProbeInfo contains metadata about a probe template.

type ProbeTemplate

type ProbeTemplate struct {
	// ID is the fully qualified probe name (e.g., "dan.Dan_11_0")
	ID string `yaml:"id"`

	// Info contains probe metadata
	Info ProbeInfo `yaml:"info"`

	// Prompts contains the attack prompts
	Prompts []string `yaml:"prompts"`
}

ProbeTemplate defines the YAML structure for probe templates. Follows Nuclei's template pattern for community contributions.

func LoadFromPath

func LoadFromPath(basedir string) ([]*ProbeTemplate, error)

LoadFromPath loads templates from a filesystem path (not embedded). This enables runtime loading of custom templates without recompilation.

func (*ProbeTemplate) Validate added in v0.0.2

func (t *ProbeTemplate) Validate() error

Validate checks if the ProbeTemplate has all required fields and valid values.

func (*ProbeTemplate) ValidateClassification added in v0.0.2

func (t *ProbeTemplate) ValidateClassification() error

ValidateClassification checks that classification fields follow expected formats. This is optional validation -- templates without classification are still valid.

type TemplateProbe

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

TemplateProbe wraps a ProbeTemplate to implement types.Prober.

func NewTemplateProbe

func NewTemplateProbe(tmpl *ProbeTemplate) *TemplateProbe

NewTemplateProbe creates a new TemplateProbe from a template definition.

func (*TemplateProbe) Description

func (t *TemplateProbe) Description() string

Description returns a human-readable description.

func (*TemplateProbe) GetPrimaryDetector

func (t *TemplateProbe) GetPrimaryDetector() string

GetPrimaryDetector returns the recommended detector.

func (*TemplateProbe) GetPrompts

func (t *TemplateProbe) GetPrompts() []string

GetPrompts returns the prompts used by this probe.

func (*TemplateProbe) Goal

func (t *TemplateProbe) Goal() string

Goal returns the probe's objective.

func (*TemplateProbe) Name

func (t *TemplateProbe) Name() string

Name returns the probe's fully qualified name.

func (*TemplateProbe) Probe

func (t *TemplateProbe) Probe(ctx context.Context, gen types.Generator) ([]*attempt.Attempt, error)

Probe executes the probe against the generator. Implements types.Prober interface.

Jump to

Keyboard shortcuts

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