Documentation
¶
Overview ¶
Package vuln is the engine module for vulnerability scanning (CAPABILITY_SPEC domain 2). It consumes the SBOM produced by internal/sbom — it never re-walks the image — matches each component against a local, offline advisory database (internal/vulndb), enriches matches with CVSS/EPSS/CISA-KEV, applies VEX statements and waivers to cut false positives, ranks by real exploitability, and projects the survivors into the unified Finding model.
The design is "deterministic core, optional intelligence layer": matching and ranking are pure and reproducible with zero models or network present; the reachability-aware VEX auto-generation (reachability.go) is an off-by-default enrichment behind a clean interface. Given the same SBOM and the same pinned advisory DB, the findings are byte-identical — with one exception: DS-RAT-VULN-EOL falls back to the wall clock (time.Now().UTC()) when Options.Now is zero, so EOL findings are time-dependent unless a clock is explicitly injected via Options.Now. Pin Options.Now to get fully byte-identical output including EOL.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Evidence ¶
type Evidence struct {
Component sbom.Component
Coord vulndb.Coord
UsedSymbols map[string]bool // symbols/imports observed in the artifact
HaveSymbols bool // whether symbol evidence was available at all
}
Evidence is what an analyzer gets to reason over.
type Fix ¶
type Fix struct {
// Type is "upgrade" when a fixed version exists, else "no-fix".
Type string `json:"type"`
Ecosystem string `json:"ecosystem"`
Package string `json:"package"`
From string `json:"from"`
To string `json:"to,omitempty"`
// Action is a terse imperative an agent can act on directly.
Action string `json:"action"`
}
Fix is a structured, model-consumable remediation.
type MapSymbolSource ¶
MapSymbolSource is a trivial SymbolSource backed by an in-memory map, keyed by component PURL (falling back to name). It exists so callers and tests can inject symbol evidence without a binary analyzer.
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module is the vulnerability-scanning capability.
func New ¶
func New() *Module
New returns a vuln module using the embedded advisory snapshot and safe defaults (no suppression).
func NewWithOptions ¶
NewWithOptions returns a vuln module with explicit options, used by tests and by the frontends that pre-load a DB / VEX / waivers.
func (*Module) Analyze ¶
Analyze generates the SBOM for the target, matches every component against the advisory DB, and returns the resulting findings plus a summary.
func (*Module) Description ¶
type Options ¶
type Options struct {
// DB is the advisory source. When nil, the module loads DBPath if set,
// otherwise the embedded bootstrap snapshot.
DB *vulndb.DB
DBPath string
// Now is the injected clock used for DB staleness and waiver expiry. Zero
// disables both time-dependent behaviors, keeping analysis deterministic.
Now time.Time
// VEX holds OpenVEX statements that suppress not-affected/fixed findings.
VEX []VEXStatement
// Waivers are operator allowlist entries with a justification and expiry.
Waivers []Waiver
// Reachability, when set, judges whether a vulnerable symbol is plausibly
// reached and can emit not_reachable VEX drafts. Nil means "always
// reachable" — the safe default that suppresses nothing.
Reachability Reachability
// Symbols supplies per-component symbol evidence for reachability. Nil means
// no evidence, so reachability never concludes not-reached (no false
// negatives from a missing symbol table).
Symbols SymbolSource
}
Options configures a vuln module. The zero value is valid: it uses the embedded advisory snapshot, no VEX/waivers, and reachability off (nothing is suppressed). Frontends may also pass configuration per-run via Target.Metadata (see optionsFromTarget), which is how the CLI/HTTP layers reach this module without a bespoke API.
type Reachability ¶
Reachability judges whether a vulnerability's code is plausibly reached.
type SymbolReachability ¶
type SymbolReachability struct{}
SymbolReachability is the deterministic heuristic analyzer. Enable it (with a SymbolSource) to cut confirmed noise.
func (SymbolReachability) Reached ¶
func (SymbolReachability) Reached(ev Evidence, adv vulndb.Advisory) Verdict
Reached applies the symbol-level rule:
- advisory declares no symbols → reachable (unknown, be safe)
- no symbol evidence for the component → reachable (be safe)
- evidence present, none of the advisory's symbols used → NOT reached
- otherwise (an affected symbol is used) → reachable
type SymbolSource ¶
type SymbolSource interface {
// Symbols returns the set of symbols/imports observed for a component and
// whether any symbol information was available.
Symbols(c sbom.Component) (used map[string]bool, have bool)
}
SymbolSource supplies per-component symbol evidence to the reachability layer. A real implementation reads symbol tables from binaries or import graphs from lockfiles; the module ships without one, so reachability stays inert until a caller wires evidence in.
type VEXStatement ¶
type VEXStatement struct {
Vuln string // CVE/GHSA id the statement is about
Products []string // product identifiers (PURLs); empty = applies to all
Status vexStatus
Justification string
}
VEXStatement is a normalized single VEX assertion.
func LoadVEXFile ¶
func LoadVEXFile(path string) ([]VEXStatement, error)
LoadVEXFile reads and parses an OpenVEX document from disk.
func ParseVEX ¶
func ParseVEX(data []byte) ([]VEXStatement, error)
ParseVEX parses an OpenVEX document into normalized statements. It tolerates both the object and string spellings OpenVEX allows for vulnerability and product fields.