exploit

package
v0.180.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 9 Imported by: 1 module, 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 exploit enriches a finding's severity with real-world exploitability signals: CISA KEV (Known Exploited Vulnerabilities, confirmed exploited in the wild) and FIRST EPSS (Exploit Prediction Scoring System, probability of exploitation). Data is loaded from local files (bring-your-own), so enrichment is optional and works offline.

Index

Constants

View Source
const (
	// SignalKEV is confirmed, observed exploitation.
	SignalKEV = "kev"
	// SignalEPSS is a predicted probability of exploitation.
	SignalEPSS = "epss"
)

The signals a Source can escalate on, as they appear in an Escalation.

Variables

This section is empty.

Functions

func CVE added in v0.179.0

func CVE(res sarif.Result) string

CVE is the CVE a finding is looked up by in KEV and EPSS: the one its rule id names, or, where the rule id names none, the first CVE among its aliases in the order the scanner recorded them. Empty for a finding that names no CVE anywhere, which neither dataset can raise.

The aliases matter because a scanner names a finding by the advisory it matched on. Grype without --by-cve reports `GHSA-4rgh-jx4f-qfcq` and relates CVE-2020-35669 to it, and a lookup reading only the rule id would leave a CVE on KEV unraised with nothing on the finding to say it was skipped.

The rule id first, so a finding that names its CVE is never re-keyed by an alias, and the first alias rather than any, so the same report ranks the same way every time.

func LoadEPSS

func LoadEPSS(r io.Reader) (map[string]float64, error)

LoadEPSS parses a FIRST EPSS scores CSV (columns: cve,epss,percentile; leading #comment and header lines are ignored) into a CVE→score map. Source: https://www.first.org/epss/data_stats

func LoadKEV

func LoadKEV(r io.Reader) (map[string]bool, error)

LoadKEV parses the CISA Known Exploited Vulnerabilities JSON catalog into a CVE set. Source: https://www.cisa.gov/known-exploited-vulnerabilities-catalog

func Matchable added in v0.175.0

func Matchable(ruleID string) bool

Matchable reports whether ruleID names a CVE, which is what KEV and EPSS are keyed on. CVE is the question to ask of a finding, which also reads the CVEs it lists as aliases.

Types

type Options added in v0.56.0

type Options struct {
	// KEV is the set of CVEs CISA has observed being exploited.
	KEV map[string]bool
	// EPSS maps a CVE to its exploitation probability.
	EPSS map[string]float64
	// ThresholdFrom names what set Threshold, the default, a descriptor key, or a flag. So a report
	// can say who chose the line a score was measured against.
	ThresholdFrom string
	// Threshold is the EPSS probability at or above which severity is raised one level. Zero or
	// less disables the EPSS bump; KEV still applies.
	Threshold float64
	// Fetched says when each dataset was obtained, so an escalation can cite a date. Keys are
	// SignalKEV and SignalEPSS; a zero time simply omits the date.
	Fetched map[string]time.Time
	// Stale marks the datasets that were older than the run's maxAge when they were read, keyed like
	// Fetched. Only the caller knows the limit, so it says; the source only carries the answer.
	Stale map[string]bool
}

Options builds a Source. Every field is optional; a Source with no data enriches nothing.

type Source

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

Source holds exploitability data plus the EPSS threshold for a severity bump.

func New

func New(kev map[string]bool, epss map[string]float64, threshold float64) *Source

New returns a Source. threshold is the EPSS probability (0–1) at or above which a finding's severity is bumped one level; a threshold ≤ 0 disables the EPSS bump (KEV still applies).

The convenience form, for a caller with nothing to say about where the data came from. Use NewFrom to record fetch dates, without which an escalation cannot cite one.

func NewFrom added in v0.56.0

func NewFrom(opts Options) *Source

NewFrom returns a Source built from opts.

func (*Source) Consulted added in v0.107.0

func (s *Source) Consulted() []sarif.Consulted

Consulted names the datasets this source can answer from, with the day each was obtained.

Which is a different statement from any escalation, and the one a reader needs first. An escalation is recorded only when a signal *moved* a finding, so its absence covers three unrelated cases: the CVE is not listed, it is listed but was already at the top band, and nobody loaded the data at all. Silence reads as the last of those, which is the reading that makes a ranking look unexplained.

Sorted, so evidence produced twice from the same inputs is byte-identical.

func (*Source) Empty

func (s *Source) Empty() bool

Empty reports whether the source carries no data (no enrichment possible).

func (*Source) Enrich

func (s *Source) Enrich(base sarif.Severity, ruleID string) sarif.Severity

Enrich raises base severity using exploitability signals for the CVE referenced by ruleID: on KEV → critical; else EPSS ≥ threshold → one level higher. Findings without a CVE ruleID (secrets, SAST, IaC) or with no matching data return base unchanged. Pass CVE(res) rather than the rule id for a finding that may name its CVE only as an alias.

func (*Source) Explain added in v0.56.0

func (s *Source) Explain(base sarif.Severity, ruleID string) (sarif.Severity, *sarif.Escalation)

Explain does what Enrich does and also says why, returning nil when nothing moved.

Separate from Enrich rather than replacing it because most callers only want the severity, and a reason nobody reads is a reason nobody keeps accurate.

func (*Source) Exploited added in v0.165.3

func (s *Source) Exploited(ruleID string) *sarif.Match

Exploited is the KEV entry for the CVE ruleID references, or nil where KEV does not list it or was not loaded.

Answered whether or not Explain moved anything. Explain records a change of band, and a CVE the scanner already rated critical is listed and changes nothing, so a caller reading only the escalation loses the one fact that orders the fix list.

Jump to

Keyboard shortcuts

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