Skip to content

Commit bd9b5ea

Browse files
fix: report all bandit findings in SARIF, fail only on HIGH severity
- Remove -ll severity filter so LOW/MEDIUM/HIGH all appear in SARIF - Check SARIF for HIGH severity (level=error) to decide pass/fail - Move scan targets into .bandit config so new Python directories can be added without editing the workflow
1 parent cc18fe9 commit bd9b5ea

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

.bandit

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Bandit configuration
22
# https://bandit.readthedocs.io/en/latest/config.html
33

4+
# Python directories to scan (add new entries here instead of
5+
# editing the workflow file)
6+
targets:
7+
- scripts/aidlc-evaluator
8+
49
# Exclude test directories (test code often has intentional patterns
510
# that trigger false positives like assert, subprocess in fixtures)
611
exclude_dirs:

.github/workflows/security-scanners.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,16 @@ jobs:
223223
pip install -r requirements.txt
224224
rm requirements.txt
225225
set +e
226-
bandit -c .bandit -r scripts/aidlc-evaluator -ll -f sarif -o bandit-report_sarif.json
226+
bandit -c .bandit -f sarif -o bandit-report_sarif.json
227227
BANDIT_EXIT=$?
228228
set -e
229-
echo "exit_code=$BANDIT_EXIT" >> "$GITHUB_OUTPUT"
229+
# Fail only if HIGH severity findings exist (level=error in SARIF)
230+
HIGH_COUNT=$(jq '[.runs[0].results[] | select(.level == "error")] | length' bandit-report_sarif.json 2>/dev/null || echo 0)
231+
if [ "$HIGH_COUNT" -gt 0 ]; then
232+
echo "exit_code=1" >> "$GITHUB_OUTPUT"
233+
else
234+
echo "exit_code=0" >> "$GITHUB_OUTPUT"
235+
fi
230236
exit 0
231237
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
232238
if: always()

0 commit comments

Comments
 (0)