Skip to content

Commit 30615fd

Browse files
fix: semgrep reports all findings, fails only on ERROR severity
Match the bandit pattern: report all severity levels in SARIF for GitHub Code Scanning visibility, but only fail the build when ERROR-level findings exist.
1 parent bd9b5ea commit 30615fd

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

.github/workflows/security-scanners.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ jobs:
114114
--sarif-output semgrep-report_sarif.json $BASELINE_ARGS
115115
SEMGREP_EXIT=$?
116116
set -e
117-
echo "exit_code=$SEMGREP_EXIT" >> "$GITHUB_OUTPUT"
118117
exit 0
119118
- name: Fix SARIF for GitHub compatibility
120119
continue-on-error: true
@@ -148,6 +147,16 @@ jobs:
148147
else . end
149148
]
150149
' semgrep-report_sarif.json > semgrep.sarif.tmp.json && mv semgrep.sarif.tmp.json semgrep-report_sarif.json
150+
- name: Check for ERROR severity findings
151+
id: semgrep
152+
run: |
153+
# Fail only if ERROR severity findings exist (level=error in SARIF)
154+
HIGH_COUNT=$(jq '[.runs[0].results[] | select(.level == "error")] | length' semgrep-report_sarif.json 2>/dev/null || echo 0)
155+
if [ "$HIGH_COUNT" -gt 0 ]; then
156+
echo "exit_code=1" >> "$GITHUB_OUTPUT"
157+
else
158+
echo "exit_code=0" >> "$GITHUB_OUTPUT"
159+
fi
151160
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
152161
with:
153162
name: semgrep.sarif

0 commit comments

Comments
 (0)