Reproducible benchmarks for the Lafke CLI and its analysis engine: speed and memory, and detection accuracy on public suites whose vulnerable and safe cases are labeled. Every measurement runs against source pinned to an exact commit, so anyone can repeat it and compare the numbers.
A fast run says nothing about what was found, so read speed and accuracy together.
You need Go (the version in go.mod), git, and lafke with an engine installed
(curl -fsSL https://lafke.sh/install | sh). Run the commands from the repository root.
go run ./cmd/bench # every corpus, 1 warm-up and 5 timed runs where timed
go run ./cmd/bench -only juliet-java # one corpus (repeatable)
go run ./cmd/bench -runs 0 # accuracy only, no timing: the fast mode
go run ./cmd/bench -jobs 8 # parallel git operations and lafke runs
go run ./cmd/bench -lafke ./lafke # a specific executable
go run ./cmd/bench -list # the corpus namesThe program fetches each corpus into .cache/ at the revision in corpora.json,
fails if the checkout does not match it, and writes a JSON result to results/. A corpus that is
already at its revision is not fetched again.
| Corpus | Source | Cases | Scored how |
|---|---|---|---|
owasp-benchmark-java, owasp-benchmark-python |
OWASP BenchmarkJava, BenchmarkPython | 2,740 and 1,230 | the rule of the case's category reports in its file |
juliet-java |
NIST Juliet Test Suite, Java, from a copy | the bad and good parts of the test cases whose CWE is in scope | a finding with the CWE inside a bad* or good* method |
benchproctor-<language> |
BenchProctor, standalone cases of Go, Java, JavaScript, PHP, Python, Ruby and TypeScript | 40 cases per category and framework | a finding with the case's CWE in its file |
snyk-vulnbench |
Snyk VulnBench, fixtures with an attacker-reachable answer key | 108 vulnerabilities | a finding of the type near the source-to-sink flow |
The corpora are downloaded when you run the program. Their source is not copied here and keeps its own license: OWASP Benchmark is GPL, BenchProctor and VulnBench are Apache-2.0 and Juliet is a NIST work.
A case is vulnerable or safe, and belongs to a category.
| Term | Meaning |
|---|---|
| TP (true positive) | a vulnerable case that lafke reports |
| FP (false positive) | a safe case that lafke reports |
| FN (false negative) | a vulnerable case that lafke does not report |
| TN (true negative) | a safe case that lafke does not report |
| Recall | TP / (TP + FN): the share of vulnerable cases found |
| Precision | TP / (TP + FP): the share of reports that are vulnerable |
| F1 | 2 x recall x precision / (recall + precision) |
| J | Youden's J: recall minus the false-positive rate FP / (FP + TN). 0 is no better than flagging everything or nothing |
Every label is in the denominator, including a case lafke could not analyze. The JSON holds the
number of sast:analysis-incomplete findings, and of units where lafke did not finish in time
(-unit-timeout); such a unit has no findings, so its vulnerable cases are false negatives.
- OWASP Benchmark: each category maps to one lafke rule in
corpora.json. A case is a hit when that rule reports a finding in the case's file. - BenchProctor: each framework folder is analyzed as a unit (with its dependency manifest next
to
testcode/). A case is a hit when a finding in its file has the case's CWE, or one of the same group. Categories lafke does not attempt (null_deref,intoverflow) are left out and counted as excluded. The official scorer requires the exact CWE. lafke reports one generic CWE per rule (CWE-327 for every weak cipher or hash, CWE-338 for weak randomness), so exact matching would count a correct finding as a miss. The numbers are therefore not comparable with scores from the official scorer. - Juliet: a test case has a bad part (methods named
bad*) and a good part (good*). A case can be spread over several files (flow variant 54a to 54e, or the base, bad and good classes of 81); its files are scored as one. A finding with the CWE of the directory inside a bad method makes the vulnerable case a hit; inside a good method it is a false positive for the safe case. Only CWEs in a group are scored; the other directories are counted as excluded. Each CWE directory (orsNNsubdirectory) is a unit, so they run in parallel. - VulnBench: this is lafke's own reading of the answer key, not the VulnBench scorer. A vulnerability is found when a finding whose rule name equals its type (or an alias) lies within 3 lines of a location of its source-to-sink flow. The key names no safe cases, so only recall is defined; precision, F1 and J are shown as a dash.
CWE groups. cwe_groups in corpora.json lists the CWEs that mean the same weakness for these
comparisons, such as 79, 80 and 87 for cross-site scripting. A corpus that uses them only scores the
CWEs that are in a group.
- Most suites are synthetic, and their ratio of vulnerable to safe cases differs from a real repository. The scores do not predict accuracy on an arbitrary application.
- Lafke's analysis is developed against suites like these, so this is not a held-out evaluation.
- A score only means something next to another tool that ran on the same revisions and the same cases, scored the same way.
Speed is measured, and accuracy is scored, with different parts of the program:
- Corpora are fetched at the same time, and the units of all corpora (
-jobs, half the CPUs by default) are analyzed on one pool. The accuracy of the whole set takes about as long as the slowest unit. - Wall time and peak memory are only measured for a corpus that is one tree, in fresh processes one after the other, after one discarded warm-up run. Parallel runs would disturb each other.
- Wall time is the elapsed time of the whole command, including starting the engine. Peak
memory is the maximum resident set size of
lafkeand the processes it started. It is not measured on Windows and reported as 0. - The result records min, median, mean and standard deviation, every raw sample, and the
environment: OS, architecture, CPU count, Go,
lafkeand engine versions.
The Benchmark workflow runs every Monday, on pushes that change it,
and on demand (Actions > Benchmark > Run workflow, where you can set the number of runs, the
lafke version and which corpora to run). One job per corpus runs on its own runner, so the timed
corpora do not share a machine and the whole set takes as long as the slowest corpus. The fetched
corpora are cached. A final job merges the results and writes:
- a table of speed and memory, and a table of TP, FP, FN, TN, recall, precision, F1 and J with a breakdown by category, in the job summary,
- every JSON result, as the
benchmark-resultsartifact.
Shared runners are noisy, so compare runs of the same workflow with each other, not with your own
machine. Accuracy does not depend on the machine, only on the lafke and engine versions.
Add an entry to corpora.json with its kind, the repository URL, the full
40-character commit hash (never a branch or tag) and the lafke command, then run it once. A new
kind of labels needs a suite in cmd/bench that fetches the corpus, splits it into units and
scores their findings.
Apache-2.0, for the code in this repository.