A reproducible, multi-corpus, multi-config evaluation harness. One importable
Python package (bench/) replaces the scattered scripts that used to live
under tools/secretbench/scoring/: every run produces one RunResult JSON on
a single schema, so one scorer, one report generator, and one test suite serve
every scanner × config × corpus × host combination.
The competitor tables in the top-level ../README.md are
generated by make report (between <!-- BENCH:* --> markers) - never
hand-edited.
make mirror # generate the 15k synthetic SecretBench-mirror corpus (off-git, neutral layout) make bench # run every scanner on the mirror -> results/<host>/ make report # render reports/ + inject the leaderboard into ../README.md make analyze # print top FP/FN examples for detector tuning make test # pytest the package (scorer truth, loaders, injection idempotence)
The release keyhog binary is resolved from $KEYHOG_BIN, else the cargo
target-dir in $CARGO_TARGET_DIR, else ~/.cargo/config.toml, else the repo
target dir, else keyhog on PATH. Build it first:
make keyhog or cargo build --release -p keyhog.
- Detection — TP / FP / FN → precision / recall / F1, overall and per-category, by the SecretBench containment rule (a finding's surfaced value contains or is contained-in a labeled secret).
- Speed — wall time + throughput (MB/s) + peak RSS (
/usr/bin/time -v), per run. - Host — OS / kernel / CPU / cores / RAM / GPU + VRAM, captured per run so desktop / santhserver / Windows-ThinkPad / macOS results aggregate into one matrix.
- Config — keyhog's
backend × cache × daemon × modeaxes; each competitor carries its own knob (kingfisher confidence, etc.) in the sameconfig_id.
Both were proven against the live keyhog binary, not assumed:
- The answer key is excluded from the scan tree. A scanner pointed at a
dir containing
manifest.jsonl(every labeled secret in plaintext) "finds" those secrets — betterleaks fires 9392 spurious matches on the mirror manifest, kingfisher 7581. Layout keeps the manifest a sibling of the scan tree:<home>/manifest.jsonlbeside<home>/corpus/<shards>; scanners only ever seecorpus/. - The scan dir has a neutral name (
corpus, neverfixtures/test). keyhog applies a path-context test-fixture confidence penalty under "fixtures"-shaped paths that--no-suppress-test-fixturesdoes not override — the same 15k files scored 1880 findings underfixtures/vs 2484 under a neutral name (tracked as MC-15 in../backlog/macro-coherence.md).
On the fair mirror keyhog ranks #1, well ahead of every competitor on F1
at near-top precision. The exact figures are not hand-written here — they
drift with the binary and would go stale - read them from the generated
leaderboard in the top-level ../README.md, regenerated by
make report. Always bench the freshly-built release binary (see
Reproducibility below); scoring a stale keyhog on PATH silently reports
worse recall (backlog MC-06).
benchmarks/
bench/ importable package
schema.py RunResult + nested records (the common contract)
hardware.py host capture
score.py overlap/attribution scorer (bit-identical to legacy score.py)
corpora/ mirror · homefield · creddata · perf(kernel) adapters
scanners/ keyhog (+config matrix) · betterleaks · kingfisher · trufflehog · titus · noseyparker
runner.py one (scanner,config,corpus) measurement -> RunResult
leaderboard.py the matrix: run many scanners/configs, write results/<host>/, rank
report.py results -> markdown + idempotent README injection
analyze.py top false-negative / false-positive examples from the same scorer
gate.py regression + differential gate (keyhog must lead; CI forcing function)
tests/ pytest
generators/ corpus generators (not git-ignored)
mirror/ synthetic SecretBench-shape generator (generate.py + providers/negatives/wrappers)
homefield/ competitor home-turf harvesters (harvest_betterleaks.py · harvest_kingfisher.py)
corpora/ generated data (git-ignored; reproducible via `make mirror` / `make creddata`)
results/<host>/ one RunResult JSON per run (git-ignored; regenerable)
reports/ generated markdown (committed): leaderboard.md · perf.md · gaps.md
baselines/ committed known-good scoreboard anchors (regression history)
| name | what | labels | get it |
|---|---|---|---|
mirror |
15k synthetic SecretBench-shape (3k positives / 12k negatives) | yes | make mirror |
homefield-betterleaks |
betterleaks' own tps/fps rule examples |
yes | harvested |
homefield-kingfisher |
kingfisher's own rule examples | yes | harvested |
creddata |
Samsung/CredData (~11k files, pinned commit) | yes (T=pos, F/X=neg) | make creddata |
kernel |
Linux kernel tree | no (perf only) | set KEYHOG_BENCH_KERNEL |
Benchmarked tools and datasets are credited with their licenses in
THIRD_PARTY_NOTICES.md. Competitor corpora and
CredData are gitignored / fetched locally — keyhog redistributes none of
their data.
quick— every scanner at its default config (the README leaderboard).perf— keyhog's fullbackend × cache × daemon × modematrix on one corpus, for the speed/RSS table:python -m bench.leaderboard --tier perf --corpus kernel --scanners keyhog --matrix backend,cache,daemon,mode.
python -m bench gate is the single regression + differential gate (it replaced
the retired tools/diff_bench runner). It runs — or, with --results <dir>,
consumes — a leaderboard, selects the canonical row per scanner with the same
newest-wins logic as the README table, and exits non-zero unless keyhog both:
- leads every available competitor on F1 strictly (
--no-beat-competitorsto skip), and - clears the floors you assert:
--min-f1/--min-precision/--min-recall, and/or--baseline <RunResult>+--epsilon(regression vs a committed anchor inbaselines/).
Exit codes: 0 pass · 1 violation · 2 undecidable (keyhog produced no
usable result). The differential-bench workflow runs it nightly against
TruffleHog; the bench-nightly workflow renders the leaderboard the gate reads.
make -C benchmarks loop runs the whole improvement cycle in one command:
pytest (scorer self-tests) -> ensure corpus -> leaderboard (detection + speed
for every scanner) -> calibrate (per-detector min_confidence floor overlay)
-> render reports/ -> gate (differential + regression vs baselines/)
It is the local mirror of the scheduled lanes that keep keyhog improving across vectors without manual babysitting:
- detection / differential —
differential-bench(nightly):bench gatefails red if a competitor overtakes keyhog on F1 or keyhog regresses pastbaselines/mirror-keyhog-baseline.json(the committed anchor; ratchet it up after a real gain, never down to hide one). - leaderboard + speed/RSS —
bench-nightly(nightly): renders the tables. - strict recall under evasion —
runners-nightly(the Rust strict matrix). - test depth —
ci(all_tests, property, e2e on every push).
loop deliberately does not --inject the README: the published tables are
regenerated only by make report on a machine with every competitor installed,
so a partial-scanner run can never degrade the committed leaderboard. The
calibration.toml overlay it emits is the actionable "what to tune next" signal.
cross_device.sh DEVICE=<ssh-alias> rsyncs the current tree to a device,
installs keyhog via its per-OS build (Linux: Hyperscan SIMD; macOS:
--features portable, the system-lib-free vyre CPU path), generates the corpus
on the device's local disk, runs the leaderboard there, and pulls the per-host
RunResult into results-cross-device/<device>/ — kept out of results/ so
a remote host's row can never shadow the canonical README numbers (the README
report's canonical_leaderboard picks newest-per-scanner across everything it
loads). Compare every host with python -m bench.cross_compare; the committed
snapshot is reports/cross-device.md. Windows is
POSIX-incompatible with this script — drive the ThinkPad via PowerShell.
Scoring pins KEYHOG_NO_GPU=1 for the deterministic SIMD path on the default
simd-* configs; the gpu/auto configs set KEYHOG_NO_GPU=0 to dogfood the
GPU path, and explicit gpu/megascan benchmark rows also set
KEYHOG_REQUIRE_GPU=1 so they fail instead of timing a CPU fallback. GPU↔SIMD
parity is a separate release gate. The CredData corpus is
pinned to an exact commit so a score is reproducible against a fixed dataset
revision. The scorer is bit-identical to the now-retired
tools/secretbench/scoring/score.py it replaced (its attribution + per-category
conservation rules are regression-anchored in bench/tests/test_score.py).