Documentation
¶
Overview ¶
Package targets implements the concrete benchmark corpora for the v0.20 baseline suite: OWASP Benchmark (white-box / SAST), DVWA, and OWASP Juice Shop (black-box / DAST). Each target knows how to run a Fendix scan against itself and how to score the result against ground truth.
Honesty constraints (roadmap Rule 5 — "benchmark before marketing"):
- DAST targets (DVWA, Juice Shop) have no well-defined negative corpus, so TrueNeg is 0 and FPRate is not meaningful for them; the useful numbers are recall (did we catch the known bugs) and the raw false-positive COUNT. OWASP Benchmark ships labeled true AND false test cases, so its TN — and therefore FPRate — is real.
- Memory is NOT measured here (capturing a subprocess's peak RSS portably is fragile); the memory baseline comes from `make bench` (the in-process BenchmarkScan). These targets own accuracy + wall time only.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrDockerMissing = errors.New("docker not found on PATH (required for DVWA/Juice Shop benchmarks)")
ErrDockerMissing is returned by a DAST target when the docker CLI is not available — surfaced loudly rather than silently skipped (agent spec).
var ErrHostPortInUse = errors.New("benchmark host port already in use")
ErrHostPortInUse is returned when the port a benchmark target needs is already bound. Distinguished so the CLI can print the override hint instead of a raw Docker error.
var ErrTargetSkipped = errors.New("benchmark target skipped")
ErrTargetSkipped marks a target that cannot run in the current product version (as opposed to a real failure). The runner reports SKIPPED with the reason instead of failing the suite.
Functions ¶
This section is empty.
Types ¶
type DVWA ¶
type DVWA struct {
// contains filtered or unexported fields
}
DVWA is the Damn Vulnerable Web App DAST benchmark target.
LIMITATION (documented for honesty, roadmap Rule 5): most DVWA vulnerabilities live behind a login + a one-time DB setup at /setup.php, and behind a security-level cookie. An unauthenticated black-box scan reaches only the surface (headers, exposed setup, cookie flags). Authenticated DVWA scanning is a v0.21+ enhancement; until then the ground-truth list is deliberately scoped to what an unauthenticated scan can actually reach, so recall numbers stay honest.
func NewDVWA ¶
func NewDVWA() *DVWA
NewDVWA returns a DVWA target reading ground truth from benchmarks/targets/dvwa-known.json.
func (*DVWA) Run ¶
func (d *DVWA) Run(ctx context.Context, result *benchmark.ScanResult) (*benchmark.BenchmarkResult, error)
Run scores result against the DVWA ground truth.
type ExpectedVuln ¶
type ExpectedVuln struct {
ID string `json:"id"`
Type string `json:"type"`
Location string `json:"location"`
Severity string `json:"severity"`
Confirmed bool `json:"confirmed"`
}
ExpectedVuln is one ground-truth vulnerability the target is known to contain. Type is matched (case-insensitively, substring) against a finding's Category; Location against its Endpoint or Line.
type JuiceShop ¶
type JuiceShop struct {
// contains filtered or unexported fields
}
JuiceShop is the OWASP Juice Shop DAST benchmark target (Node app — black-box HTTP scanning, language-agnostic).
func NewJuiceShop ¶
func NewJuiceShop() *JuiceShop
NewJuiceShop returns a Juice Shop target reading ground truth from benchmarks/targets/juiceshop-known.json.
func (*JuiceShop) Run ¶
func (j *JuiceShop) Run(ctx context.Context, result *benchmark.ScanResult) (*benchmark.BenchmarkResult, error)
Run scores result against the Juice Shop ground truth.
type KnownSet ¶
type KnownSet struct {
Version string `json:"version"`
Target string `json:"target"`
Negatives int `json:"negatives,omitempty"`
Vulnerabilities []ExpectedVuln `json:"vulnerabilities"`
}
KnownSet is the ground-truth file for a target.
type OWASP ¶
type OWASP struct{}
OWASP is the OWASP Benchmark target.
IMPORTANT (roadmap honesty, Rule 5): OWASP Benchmark is a *Java* web application whose score depends on interprocedural, sanitizer-aware source→sink taint analysis (~half its ~2740 cases are deliberate sanitized false-positive twins, so a line-local matcher scores ~0 on the FP-penalized Youden metric). As of v0.27 Fendix ships Java *regex* SAST (line-local, TierNativeGo) — real coverage, but NOT the deep Java taint analysis this benchmark requires. Emitting a number now would be a garbage baseline, so this target loudly SKIPS in BOTH Scan() and Run() (defence in depth: no all-zero result can reach the baseline/Compare path). It un-SKIPS only when a real Java taint analyzer + a labeled owasp-known.json corpus exist (see NEXT_v029.md). The shipped DAST baseline is DVWA + Juice Shop.
func (*OWASP) Run ¶
func (o *OWASP) Run(ctx context.Context, result *benchmark.ScanResult) (*benchmark.BenchmarkResult, error)
Run also reports skipped. Previously it returned an all-zero BenchmarkResult "for interface completeness"; that was a latent Rule-5 landmine — a future refactor calling Run() without Scan() short-circuiting first would feed a 0.0-recall result into Compare() and flag a phantom regression. SKIP here too so a fabricated number can never be persisted (target_test.go pins this).
type RealWorld ¶
type RealWorld struct {
// Result is the rich scored outcome attached by Run for the CLI's
// per-class + triage output. BenchmarkResult (Run's return) is the
// compact shape the baseline stores.
Result *benchmark.RealWorldResult
// contains filtered or unexported fields
}
RealWorld is a SAST corpus target: a source tree at a pinned revision plus a committed labels.yaml. It reuses the scan-production + scoring split of the other targets but scores against labels, not a known-vuln set.
func DiscoverRealWorld ¶
DiscoverRealWorld returns a RealWorld target for every committed corpus entry under <root>/benchmarks/realworld/*/manifest.yaml. root "" means cwd.
func NewRealWorld ¶
NewRealWorld returns a RealWorld target for one corpus entry.
func (*RealWorld) Run ¶
func (r *RealWorld) Run(ctx context.Context, result *benchmark.ScanResult) (*benchmark.BenchmarkResult, error)
Run scores result against the entry's labels. It attaches the rich RealWorldResult to the target (for the CLI's per-class + triage output) and returns the compact BenchmarkResult the baseline stores.
func (*RealWorld) Scan ¶
Scan resolves the source tree and runs fendix; loud-SKIPs a local entry with no path.
func (*RealWorld) TriageReport ¶
TriageReport renders the unknown findings + per-class FP breakdown for one entry, so labeling is incremental and the number stays defensible.
type Target ¶
type Target interface {
benchmark.BenchmarkTarget
// Scan runs fendixBin against this target and returns the raw result.
// Implementations are responsible for setup and teardown (containers,
// downloads) and must respect ctx cancellation.
Scan(ctx context.Context, fendixBin string) (*benchmark.ScanResult, error)
}
Target is a benchmark corpus that can both produce a Fendix ScanResult (running Docker / downloading the corpus as needed) and score it.