seed

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: Apache-2.0 Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package seed produces leads: deterministic, model-free observations that start an investigation. A lead is not a verdict. Seeders are either built-in rule sets or adapters around an installed scanner.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunAll

func RunAll(ctx context.Context, seeders []Seeder, root string, files []walk.File) ([]Lead, []Status)

RunAll runs every available seeder and returns the merged, sorted leads. One failing seeder does not stop the others: its error is recorded in its Status and the run continues.

Types

type Lead

type Lead struct {
	ID      string   `json:"id"`              // stable; see (*Lead).Finalize
	Source  string   `json:"source"`          // seeder name: builtin-code, builtin-secrets, semgrep, ...
	RuleID  string   `json:"rule_id"`         // rule within the seeder
	Title   string   `json:"title"`           // short, specific, no trailing period
	Class   string   `json:"class"`           // a class known to finding.DefaultVector
	Surface string   `json:"surface"`         // finding.SurfaceCode, SurfaceInfra or SurfaceDAST
	CWE     []string `json:"cwe,omitempty"`   // "CWE-89"
	OWASP   []string `json:"owasp,omitempty"` // "A03:2021 Injection"
	// Severity is the seeder's hint: critical, high, medium or low.
	Severity string `json:"severity"`

	File    string `json:"file,omitempty"` // forward-slash, relative to the target root
	Line    int    `json:"line,omitempty"` // 1-based
	EndLine int    `json:"end_line,omitempty"`

	Method   string `json:"method,omitempty"`
	Endpoint string `json:"endpoint,omitempty"`
	Param    string `json:"param,omitempty"`

	// Snippet is the matched source or traffic, already redacted. It must
	// never contain a secret value.
	Snippet string `json:"snippet,omitempty"`
	Detail  string `json:"detail"` // what is wrong, in one or two sentences
	Fix     string `json:"fix"`    // the concrete remediation, in one or two sentences
	// Evidence names stored artifacts (for DAST, the exchange ids).
	Evidence []string `json:"evidence,omitempty"`
}

Lead is one observation from a seeder.

func Sort

func Sort(leads []Lead) []Lead

Sort orders leads by file, line, source and rule so output is stable.

func Unique

func Unique(leads []Lead) []Lead

Unique drops leads with a repeated ID, keeping the first.

func (*Lead) Finalize

func (l *Lead) Finalize()

Finalize sets the stable ID from the lead's identity. Seeders call it on every lead before returning.

type Noter

type Noter interface {
	Note() string
}

Noter is implemented by seeders that have something to say about their last Run beyond the leads, such as how many scanner results were dropped because they could not be classified. Callers may type-assert a Seeder to Noter after Run.

type Rule

type Rule struct {
	ID    string
	Langs []string // walk.File.Lang values the rule applies to
	// Pattern must match the line.
	Pattern *regexp.Regexp
	// Exclude, when set, suppresses the rule if it matches the same line.
	// It expresses the safe variant of the pattern (a literal argument, a
	// safe loader) which RE2 cannot express as a negative lookahead.
	Exclude *regexp.Regexp
	// Require, when set, must also match the same line.
	Require *regexp.Regexp
	// Near, when set, must match some line within NearLines of the hit.
	// It is for settings that are only dangerous together.
	Near      *regexp.Regexp
	NearLines int

	Title    string
	Class    string
	CWE      string
	OWASP    string
	Severity string
	Detail   string
	Fix      string
}

Rule is one line-oriented source pattern. The engine is deliberately simple: a lead is a starting point for an investigation, so a rule only has to be precise enough that most of its hits deserve a look.

type Seeder

type Seeder interface {
	// Name is the stable seeder name used in Lead.Source and in doctor output.
	Name() string
	// Available reports whether the seeder can run here, with a note that
	// says how to get it when it cannot (for example an install hint).
	Available() (ok bool, note string)
	// Run examines the target. files is the safe file listing of root;
	// seeders must read target files only through it or through
	// walk.Resolve, never by walking the tree themselves.
	Run(ctx context.Context, root string, files []walk.File) ([]Lead, error)
}

Seeder produces leads for a target on disk.

func All

func All() []Seeder

All returns the built-in seeders followed by the scanner adapters.

func Builtin

func Builtin() []Seeder

Builtin returns the seeders that need nothing installed.

func External

func External() []Seeder

External returns the adapters for scanners the operator may have installed.

type Status

type Status struct {
	Name      string `json:"name"`
	Available bool   `json:"available"`
	Note      string `json:"note,omitempty"`
	Leads     int    `json:"leads"`
	Error     string `json:"error,omitempty"`
}

Status records how one seeder fared in a run.

Jump to

Keyboard shortcuts

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