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 ¶
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.
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.