Skip to content

Commit 170d14a

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

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

.github/workflows/security-scanners.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ jobs:
277277
python-version: '3.x'
278278
cache: 'pip'
279279
- name: Run checkov
280-
id: checkov
281280
run: |
282281
pip install -r requirements.txt
283282
rm requirements.txt
@@ -286,8 +285,17 @@ jobs:
286285
CHECKOV_EXIT=$?
287286
mv results_sarif.sarif checkov-report_sarif.json || true
288287
set -e
289-
echo "exit_code=$CHECKOV_EXIT" >> "$GITHUB_OUTPUT"
290288
exit 0
289+
- name: Check for ERROR severity findings
290+
id: checkov
291+
run: |
292+
# Fail only if ERROR severity findings exist (level=error in SARIF)
293+
HIGH_COUNT=$(jq '[.runs[0].results[] | select(.level == "error")] | length' checkov-report_sarif.json 2>/dev/null || echo 0)
294+
if [ "$HIGH_COUNT" -gt 0 ]; then
295+
echo "exit_code=1" >> "$GITHUB_OUTPUT"
296+
else
297+
echo "exit_code=0" >> "$GITHUB_OUTPUT"
298+
fi
291299
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
292300
if: always()
293301
with:

0 commit comments

Comments
 (0)