Python diff benchmark
On 14 synthetic adversarial and clean Python patches, Stanch flagged 8 of 8 tampering examples and passed 6 of 6 clean examples.
What was measured
Each method classified the same labeled diffs. The tampering fixtures cover mock replacements, skipped tests, removed coverage, always-true assertions, and swallowed errors. The clean fixtures include legitimate mocks and changes that add test coverage.
| Method | Tampering caught | Clean passed | False positives |
|---|---|---|---|
stanch | 100% | 100% | 0% |
grep_skip | 25% | 100% | 0% |
diff_delete | 25% | 83% | 17% |
grep_skip looks for skip markers. diff_delete flags deleted lines in test files.
These percentages describe this small, synthetic suite. Detection rates on production repositories remain unmeasured.
Reproduce the result
Download the CLI and run the bundled fixtures with the command below. It prints the fixture counts and results for all three methods.
python ../stanch.pyz eval