diff --git a/README.md b/README.md index 057a302..3eac144 100644 --- a/README.md +++ b/README.md @@ -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). diff --git a/gitleaks/action.yml b/gitleaks/action.yml index 41f15f0..b60b2ea 100644 --- a/gitleaks/action.yml +++ b/gitleaks/action.yml @@ -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")