Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ jobs:
EVENT: ${{ github.event_name }}
PR_BASE: ${{ github.event.pull_request.base.sha }}
PR_HEAD: ${{ github.event.pull_request.head.sha }}
PUSH_BEFORE: ${{ github.before }}
PUSH_AFTER: ${{ github.after }}
PUSH_BEFORE: ${{ github.event.before }}
PUSH_AFTER: ${{ github.event.after }}
run: |
set -euo pipefail
gitleaks version
Expand All @@ -116,7 +116,15 @@ jobs:
range="${PR_BASE}..${PR_HEAD}"
;;
push)
if [ -z "${PUSH_BEFORE:-}" ] || [ "$PUSH_BEFORE" = "0000000000000000000000000000000000000000" ]; then
# Both ends have to be real commits in this checkout. A branch
# deletion sends an all-zero "after", and a force-push can send a
# "before" that no ref reaches any more, so git log would exit 128
# and the job would scan nothing. Either case scans full history.
zero="0000000000000000000000000000000000000000"
if [ -z "${PUSH_BEFORE:-}" ] || [ -z "${PUSH_AFTER:-}" ] \
|| [ "$PUSH_BEFORE" = "$zero" ] || [ "$PUSH_AFTER" = "$zero" ] \
|| ! git cat-file -e "${PUSH_BEFORE}^{commit}" 2>/dev/null \
|| ! git cat-file -e "${PUSH_AFTER}^{commit}" 2>/dev/null; then
range=""
else
range="${PUSH_BEFORE}..${PUSH_AFTER}"
Expand All @@ -128,6 +136,10 @@ jobs:
;;
esac

if [ "$EVENT" = "push" ] && [ -z "$range" ]; then
echo "::warning::gitleaks is scanning FULL HISTORY on a push instead of the changed commit range. The before/after SHAs were empty, all-zero or unreachable (a branch deletion or a force-push) - check that PUSH_BEFORE/PUSH_AFTER use github.event.before / github.event.after, not github.before / github.after (those are not github-context properties, so they expand to empty and silently blind the scanner to new leaks)."
fi

report="${RUNNER_TEMP:-/tmp}/gitleaks-report.json"
rm -f "$report"

Comment thread
swu-rob[bot] marked this conversation as resolved.
Resolved
Expand Down
Loading