Files
ResearchMethods_Project/validation/sast_tools

SAST tool results

Generated with:

python3 validation/export_sast_tools.py

Files

File Contents
findings.csv Every raw finding from both tools and all three conditions
bandit_findings.csv Bandit raw findings
semgrep_findings.csv Semgrep raw findings
tools_long.csv 1,200 rows: 2 tools × 3 conditions × 200 samples
tools_summary.csv Aggregate metrics by tool and condition
sast_tools.sps SPSS import and crosstab syntax
codebook.md Mapping and variable documentation

Definition of “flagged”

flagged = 1 means the tool produced at least one finding mapped to one of the benchmark’s fourteen target categories. Findings outside those categories are kept in findings.csv but do not set the flag.

Bandit is mapped by rule ID; Semgrep is mapped from its CWE metadata. See codebook.md for the exact mapping.

Results

In-scope samples: 200 (all fourteen BenchmarkPython categories).

Tool Condition TP FP TN FN Accuracy Precision Recall F1
Bandit Original 30 26 107 37 0.685 0.536 0.448 0.488
Bandit Obfuscated v2 29 24 109 38 0.690 0.547 0.433 0.483
Bandit Comments removed 30 26 107 37 0.685 0.536 0.448 0.488
Semgrep Original 12 14 119 55 0.655 0.462 0.179 0.258
Semgrep Obfuscated v2 11 13 120 56 0.655 0.458 0.164 0.242
Semgrep Comments removed 12 14 119 55 0.655 0.462 0.179 0.258

All true positives had the correct mapped category, so strict accuracy equals flag accuracy for both tools. Both tools have much lower recall than the LLM. This is expected: Bandit and Semgrep are pattern-based, do not implement the benchmark’s full dataflow semantics, and do not cover all fourteen categories.

Obfuscation effects

Bandit:

  • Original: 89 findings
  • Obfuscated v2: 86 findings
  • Comments removed: 89 findings
  • The only missing findings are the three B608 SQL-pattern findings (00192, 00284, 00286). The SQL sink and data flow remain.
  • Target TP changes from 30 to 29 under full obfuscation; comments-only is identical to the original (TP=30, FP=26).

Semgrep (p/python):

  • Original: 27 findings
  • Obfuscated v2: 24 findings
  • Comments removed: 27 findings
  • Three findings disappear under full obfuscation:
    • request-data-write (CWE-93) in 00472 — out of scope
    • avoid-insecure-deserialization (CWE-502) in 00508 — false positive
    • path-traversal-open (CWE-22) in 01196 — true positive
  • Target TP changes from 12 to 11 under full obfuscation; comments-only is identical to the original (TP=12, FP=14).

The Semgrep path-traversal loss is a concrete example of full obfuscation breaking a pattern that depends on identifier/request structure.

SPSS

Set the SPSS working directory to this folder and run:

sast_tools.sps

The syntax imports tools_long.csv, filters to in_scope = 1, and runs tool-by-condition crosstabs and finding-count descriptives.

If you want to combine these tool results with the LLM results, use the combined file validation/spss_all/sast_all_long.csv, which already includes both tools and all LLM runs.

Caveats

  • Category mapping is approximate and rule-based; audit findings.csv before treating a tool’s category as ground truth.
  • Bandit XML import warnings (B405/B406/B408) are not mapped to XXE; only B313–B320 are.
  • Bandit B102/B307 map to code injection and B324 maps to weak hash. B404 (subprocess import) remains a raw finding only.
  • Semgrep’s p/python ruleset does not cover every benchmark category. In particular, it produced no secure-cookie, open-redirect, or LDAP-injection findings in this sample.
  • The flagged variable is intentionally any-target-finding. Alternative definitions can be derived from findings.csv.