Documentation
¶
Overview ¶
Package evals runs the security benchmark corpus and scores the scanner against it. It is the regression net: a detector that stops firing on a known vulnerability, or starts firing on a case that was fixed, fails here before it reaches anyone.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Case ¶
type Case struct {
ID string `yaml:"id"`
Category string `yaml:"category"`
Class Class `yaml:"-"`
Dir string `yaml:"-"`
// Notes explains what the case is testing. Required, because a corpus of
// unlabelled fixtures rots into noise.
Notes string `yaml:"notes"`
Target CaseTarget `yaml:"target"`
Expected Expectation `yaml:"expected"`
// Analyzers restricts the scan. Empty means every applicable analyzer,
// which is how cross-analyzer regressions get caught.
Analyzers []string `yaml:"analyzers"`
// Regression marks a case added because of a bug found in the field. These
// are never removed and never allowed to fail.
Regression bool `yaml:"regression"`
}
Case is one corpus entry, loaded from case.yaml next to the fixture
func Load ¶
Load reads every case under root. A directory containing a case.yaml is a case; anything else is fixture material belonging to one.
func (Case) ScanTarget ¶
ScanTarget builds the scan target for the case, resolved against its directory
type CaseTarget ¶
type CaseTarget struct {
Kind model.TargetKind `yaml:"kind"`
Path string `yaml:"path"`
URL string `yaml:"url"`
}
CaseTarget describes what to scan, relative to the case directory
type Class ¶
type Class string
Class is which part of the corpus a case belongs to
const ( // ClassVulnerable must produce a finding ClassVulnerable Class = "vulnerable" // ClassFixed is the repaired version of a vulnerable case and must be quiet ClassFixed Class = "fixed" // ClassBenign is ordinary code that must be quiet ClassBenign Class = "benign" // ClassHoldout is benign or vulnerable code kept out of rule tuning ClassHoldout Class = "holdout" )
type Expectation ¶
type Expectation struct {
Vulnerable bool `yaml:"vulnerable"`
MinimumSeverity model.Severity `yaml:"minimum_severity"`
// Rules that must appear. A case can require a specific detector rather
// than accepting any finding at all, which stops an unrelated rule from
// masking a regression.
Rules []string `yaml:"rules"`
// ForbiddenRules must not appear. Used for fixed and benign cases that
// previously produced a specific false positive.
ForbiddenRules []string `yaml:"forbidden_rules"`
// Status the scan must reach. Defaults to COMPLETED
Status model.ScanStatus `yaml:"status"`
}
Expectation is what the scan should produce
type Metrics ¶
Metrics is the confusion matrix and its derived rates.
Gaps sits outside the matrix on purpose: those cases hold a vulnerability the build cannot see and assert that the scan reports a gap instead of a clean result. Folding them into TN would let precision and recall rise by documenting more blind spots.
type Outcome ¶
type Outcome struct {
Case Case
Result *model.ScanResult
// Detected is whether the scan produced a qualifying finding
Detected bool
// Classification is TP, TN, FP, FN, or GAP for a case that pins a
// blind spot rather than a detection
Classification string
// Problems lists why the case failed, empty when it passed
Problems []string
}
Outcome is how one case turned out