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
@@ -101,6 +101,6 @@ binary is verified by SHA-256.
|
||||
|
||||
## Versions
|
||||
|
||||
Tags without dots only (`v1`, `v2`): the act-based Gitea runner mangles a
|
||||
dotted ref of a sub-path action (`gitleaks@v1.2` -> "Unable to resolve
|
||||
v1.2.2"). `v2` = fs scans, binary runtime, misconfig, gitleaks.
|
||||
`v1` image gate + SBOM; `v2` fs scans, binary runtime, misconfig, gitleaks;
|
||||
`v3` gitleaks fetches the parent of a single commit in a depth-1 checkout
|
||||
(dispatch/cron runs scanned the whole tree as a root commit before).
|
||||
+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