templatekit

package
v0.4.12 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Manifest

func Manifest() core.Manifest

Manifest declares the catalog tools.

func NewCapability

func NewCapability(deps core.Deps) (core.Capability, error)

NewCapability builds the capability. When the host already provides a *Catalog as Deps.Templates it is reused so hot-reloaded packs are visible here too; otherwise an empty catalog is created.

func ValidatePack

func ValidatePack(p *Pack) error

ValidatePack validates all templates and enforces unique IDs.

func ValidateTemplate

func ValidateTemplate(t Template) error

ValidateTemplate checks the authoring contract.

Types

type Capability

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

Capability exposes the template catalog as read-only tools. It never executes a template; execution belongs to the engine (verifykit/nucleikit).

func (*Capability) Call

func (c *Capability) Call(ctx context.Context, call core.Call) (core.Result, error)

Call dispatches the catalog tools.

func (*Capability) Manifest

func (c *Capability) Manifest() core.Manifest

Manifest implements core.Capability.

type Catalog

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

Catalog is an in-memory, engine-neutral template index. It does not execute anything; engines consume TemplateRef values.

func NewCatalog

func NewCatalog() *Catalog

func (*Catalog) AddPack

func (c *Catalog) AddPack(p *Pack) error

AddPack validates and adds/replaces one pack. Replacing a pack removes only that pack's prior templates, so hot reload is atomic per pack.

func (*Catalog) Count

func (c *Catalog) Count() int

func (*Catalog) Get

func (c *Catalog) Get(_ context.Context, id string) (core.TemplateRef, bool, error)

func (*Catalog) PackNames

func (c *Catalog) PackNames() []string

func (*Catalog) Reload

func (c *Catalog) Reload(ctx context.Context, sources ...PackSource) error

Reload loads every source and adds its pack. Any error leaves already-loaded packs in place; callers can treat this as best-effort.

func (*Catalog) Search

type DirSource

type DirSource struct {
	FS         fs.FS
	Root       string
	SourceName string
}

DirSource loads a pack from an fs.FS rooted at Root. It supports pack.yaml, pack.yml and pack.json manifests, plus YAML/JSON template files.

func (DirSource) Load

func (s DirSource) Load(_ context.Context) (*Pack, error)

type Extract

type Extract struct {
	Name  string `yaml:"name" json:"name"`
	Regex string `yaml:"regex" json:"regex"`
	Group int    `yaml:"group,omitempty" json:"group,omitempty"`
}

Extract pulls a value out of a matched response.

type Kind

type Kind string

Kind identifies which engine executes a template.

const (
	KindHTTP   Kind = "http"
	KindNuclei Kind = "nuclei"
	KindShell  Kind = "shell"
	KindChain  Kind = "chain"
)

func (Kind) Valid

func (k Kind) Valid() bool

type Matcher

type Matcher struct {
	Type   string   `yaml:"type" json:"type"` // status | word | regex | dsl
	Part   string   `yaml:"part,omitempty" json:"part,omitempty"`
	Status []int    `yaml:"status,omitempty" json:"status,omitempty"`
	Words  []string `yaml:"words,omitempty" json:"words,omitempty"`
	Regex  []string `yaml:"regex,omitempty" json:"regex,omitempty"`
	DSL    string   `yaml:"dsl,omitempty" json:"dsl,omitempty"`
}

Matcher is a minimal, engine-neutral match rule. Engines may add their own richer matching; this covers the common status/word/regex/dsl cases.

type Pack

type Pack struct {
	Manifest   PackManifest `json:"manifest"`
	Templates  []Template   `json:"templates"`
	Provenance Provenance   `json:"provenance"`
	Checksum   string       `json:"checksum,omitempty"`
}

Pack is a versioned, provenance-bearing set of templates.

type PackManifest

type PackManifest struct {
	Name      string   `yaml:"name" json:"name"`
	Version   string   `yaml:"version" json:"version"`
	Source    string   `yaml:"source,omitempty" json:"source,omitempty"`
	License   string   `yaml:"license,omitempty" json:"license,omitempty"`
	Checksum  string   `yaml:"checksum,omitempty" json:"checksum,omitempty"` // sha256:<hex>
	Templates []string `yaml:"templates,omitempty" json:"templates,omitempty"`
}

PackManifest is the pack.yaml/pack.json contract. Templates may be glob patterns; when empty the loader walks the "templates" directory recursively.

type PackSource

type PackSource interface {
	Load(ctx context.Context) (*Pack, error)
}

PackSource loads one pack. Implementations may read fs.FS, a directory, an artifact store or a remote URL. They must not execute templates.

type Provenance

type Provenance struct {
	Source    string    `json:"source,omitempty"`
	Upstream  string    `json:"upstream,omitempty"`
	License   string    `json:"license,omitempty"`
	Commit    string    `json:"commit,omitempty"`
	FetchedAt time.Time `json:"fetched_at,omitempty"`
}

Provenance records where a pack came from and under what license.

type RequestSpec

type RequestSpec struct {
	Method  string            `yaml:"method" json:"method"`
	Path    string            `yaml:"path" json:"path"`
	Headers map[string]string `yaml:"headers,omitempty" json:"headers,omitempty"`
	Body    string            `yaml:"body,omitempty" json:"body,omitempty"`
}

RequestSpec is the engine-neutral HTTP request description for kind=http.

type Template

type Template struct {
	ID          string            `yaml:"id" json:"id"`
	Name        string            `yaml:"name" json:"name"`
	Kind        Kind              `yaml:"kind" json:"kind"`
	Product     []string          `yaml:"product,omitempty" json:"product,omitempty"`
	Fingerprint string            `yaml:"fingerprint,omitempty" json:"fingerprint,omitempty"`
	Severity    string            `yaml:"severity,omitempty" json:"severity,omitempty"`
	Tags        []string          `yaml:"tags,omitempty" json:"tags,omitempty"`
	CVE         string            `yaml:"cve,omitempty" json:"cve,omitempty"`
	Engine      string            `yaml:"engine,omitempty" json:"engine,omitempty"`
	Request     *RequestSpec      `yaml:"request,omitempty" json:"request,omitempty"`
	Matchers    []Matcher         `yaml:"matchers,omitempty" json:"matchers,omitempty"`
	Extract     []Extract         `yaml:"extract,omitempty" json:"extract,omitempty"`
	References  []string          `yaml:"references,omitempty" json:"references,omitempty"`
	Metadata    map[string]string `yaml:"metadata,omitempty" json:"metadata,omitempty"`

	// Runtime/provenance fields (not part of the authored template).
	Path     string `yaml:"-" json:"-"`
	Pack     string `yaml:"-" json:"-"`
	Source   string `yaml:"-" json:"-"`
	Artifact []byte `yaml:"-" json:"-"`
}

Template is one predefined verification/exploitation recipe. It is engine neutral; the Artifact holds the original engine payload (nuclei YAML, shell spec, ...) while Request/Matchers describe the normalized http form.

func (Template) Ref

func (t Template) Ref() (core.TemplateRef, error)

Ref converts a template into the engine-neutral reference consumed by TemplateEngine implementations.

Jump to

Keyboard shortcuts

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