Add Bandit and Semgrep per-sample comparison exports
- Run Semgrep p/python on original and obfuscated samples - Add raw Bandit/Semgrep findings and per-sample target-category flags - Add SPSS-ready tool-by-condition long file and summary - Document tool mappings, coverage limits, and obfuscation effects
This commit is contained in:
14 files changed
+2143
-1
No files matched your search
+54
-1
@@ -59,6 +59,46 @@ and data flow remain. With B608 skipped, both directories produce exactly
|
||||
See `bandit_comparison.txt` for the full report and `bandit/*.json` for raw
|
||||
Bandit output.
|
||||
|
||||
## Semgrep comparison
|
||||
|
||||
Semgrep 1.185.0 was run with the `p/python` ruleset:
|
||||
|
||||
```bash
|
||||
.venv/bin/semgrep scan --config p/python --json \
|
||||
--output validation/semgrep/samples.json Samples
|
||||
.venv/bin/semgrep scan --config p/python --json \
|
||||
--output validation/semgrep/obfuscated_v2.json Samples_Obfuscated_v2
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
- Original: **27 findings**
|
||||
- Obfuscated v2: **24 findings**
|
||||
- Three findings disappear after obfuscation:
|
||||
- `request-data-write` (CWE-93) in `BenchmarkTest00472` — out of scope
|
||||
- `avoid-insecure-deserialization` (CWE-502) in `BenchmarkTest00508` — false positive
|
||||
- `path-traversal-open` (CWE-22) in `BenchmarkTest01196` — true positive
|
||||
|
||||
Semgrep’s path-traversal finding is lost because the obfuscator changes the
|
||||
identifier/request structure the pattern depends on. Raw JSON is in `semgrep/`.
|
||||
|
||||
## SAST tool comparison
|
||||
|
||||
`export_sast_tools.py` combines the Bandit and Semgrep findings into per-sample
|
||||
and SPSS-ready files under `sast_tools/`:
|
||||
|
||||
- `findings.csv` — all raw findings
|
||||
- `tools_long.csv` — 800 rows: tool × condition × sample
|
||||
- `tools_summary.csv` — aggregate metrics
|
||||
- `sast_tools.sps` — SPSS import/analysis syntax
|
||||
- `codebook.md`
|
||||
|
||||
```bash
|
||||
python3 validation/export_sast_tools.py
|
||||
```
|
||||
|
||||
See `sast_tools/README.md` for the mapping rules and results.
|
||||
|
||||
## DeepSeek comparison
|
||||
|
||||
Two runs were executed with `opencode-go/deepseek-v4.1-flash` and
|
||||
@@ -112,16 +152,29 @@ See `spss/README.md` for import instructions and suggested analyses.
|
||||
```text
|
||||
validation/
|
||||
├── test_pipeline.py # mock-API end-to-end test
|
||||
├── export_spss.py # generate SPSS-ready CSVs/syntax
|
||||
├── export_spss.py # generate SPSS-ready LLM CSVs/syntax
|
||||
├── export_sast_tools.py # generate Bandit/Semgrep CSVs/syntax
|
||||
├── bandit_comparison.txt # human-readable Bandit diff
|
||||
├── bandit/
|
||||
│ ├── samples.json # raw Bandit JSON, original
|
||||
│ └── obfuscated_v2.json # raw Bandit JSON, obfuscated
|
||||
├── semgrep/
|
||||
│ ├── samples.json # raw Semgrep JSON, original
|
||||
│ └── obfuscated_v2.json # raw Semgrep JSON, obfuscated
|
||||
├── deepseek_comparison.md # original vs obfuscated analysis
|
||||
├── deepseek/
|
||||
│ ├── deepseek-original.csv # per-sample original results
|
||||
│ ├── deepseek-v4.1-flash.csv # per-sample obfuscated results
|
||||
│ └── summary.csv # comparison metrics
|
||||
├── sast_tools/
|
||||
│ ├── findings.csv
|
||||
│ ├── bandit_findings.csv
|
||||
│ ├── semgrep_findings.csv
|
||||
│ ├── tools_long.csv
|
||||
│ ├── tools_summary.csv
|
||||
│ ├── codebook.md
|
||||
│ ├── sast_tools.sps
|
||||
│ └── README.md
|
||||
└── spss/
|
||||
├── sast_long.csv
|
||||
├── sast_wide.csv
|
||||
|
||||
Reference in new issue
Block a user