Skip to content

Commit 96eee0e

Browse files
committed
fix(ci): gitleaks empty report false positive fix
- gitleaks: Fix script treating empty report ([] 2 bytes) as secrets detected - Now checks if JSON content is actually non-empty, not just file size
1 parent 9271325 commit 96eee0e

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

.github/workflows/security.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ jobs:
4545
--redact \
4646
--report-format json \
4747
--report-path gitleaks-report.json || EXIT_CODE=$?
48-
if [ -f gitleaks-report.json ] && [ -s gitleaks-report.json ]; then
49-
echo "::error::Secrets detected by gitleaks. See report for details."
50-
cat gitleaks-report.json
51-
exit 1
52-
fi
53-
if [ "${EXIT_CODE:-0}" -ne 0 ]; then
54-
exit 1
48+
if [ -f gitleaks-report.json ]; then
49+
CONTENT=$(cat gitleaks-report.json | tr -d '[:space:]')
50+
if [ "$CONTENT" != "[]" ] && [ "$CONTENT" != "null" ] && [ -n "$CONTENT" ]; then
51+
echo "::error::Secrets detected by gitleaks. See report for details."
52+
cat gitleaks-report.json
53+
exit 1
54+
fi
5555
fi
5656
echo "✅ No secrets detected"
5757

0 commit comments

Comments
 (0)