gitleaks: fetch the parent of a single scanned commit in shallow checkouts (v3)
A dispatch or cron run has no before-sha, so one commit is scanned; in a depth-1 checkout it has no parent and gitleaks diffed it as a root commit, reporting the whole tree (corescope: 3 upstream files). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9591a27e59
commit
67a711fe3c
2 files changed
+11
-4
No files matched your search
+8
-1
@@ -83,7 +83,14 @@ runs:
|
||||
opts="--first-parent --diff-merges=off $BEFORE..$SHA"
|
||||
fi
|
||||
fi
|
||||
[ -n "$opts" ] || opts="--diff-merges=off -1 ${SHA:-HEAD}"
|
||||
if [ -z "$opts" ]; then
|
||||
# One commit (dispatch/cron). In a depth-1 checkout it has no
|
||||
# parent and would be diffed as a root commit, i.e. the whole
|
||||
# tree (upstream files of a fork included): fetch its parent.
|
||||
head="${SHA:-HEAD}"
|
||||
git rev-parse -q --verify "$head^" >/dev/null 2>&1 || git fetch -q --deepen=1 origin 2>/dev/null || true
|
||||
opts="--diff-merges=off -1 $head"
|
||||
fi
|
||||
fi
|
||||
if [ -n "$CONFIG" ] && [ -f "$CONFIG" ]; then
|
||||
cfg=(--config "$CONFIG")
|
||||
|
||||
Reference in new issue
Block a user