fix(git-gate): scan $new --not --all for every push, not $old..$new #422

Merged
didericis merged 1 commits from fix-git-gate-force-push-scan-range into main 2026-07-18 16:51:34 -04:00

1 Commits

Author SHA1 Message Date
didericis bcc0bb3c41 fix(git-gate): scan $new --not --all for every push, not $old..$new
test / integration (pull_request) Successful in 10s
tracker-policy-pr / check-pr (pull_request) Successful in 7s
lint / lint (push) Successful in 42s
test / unit (pull_request) Successful in 33s
test / coverage (pull_request) Successful in 39s
The pre-receive hook scanned existing-branch updates with the delta range
$old..$new. On a rebase / non-fast-forward force-push onto an advanced main,
$old is no longer an ancestor of $new, so $old..$new expands to all of main's
new history — including the deliberate sandbox-escape gitleaks fixtures — and
the push is rejected on commits that belong to main, not the branch.

Unify the range on `$new --not --all` for every non-delete push (this is the
deferred open question from PRD 0028, which already applied it to new refs
for #106). It scans only the commits the push introduces and is
security-equivalent: the bare repo's refs come only from trusted upstream
mirror-fetch and gitleaks-gated pushes, so an excluded commit is
already-upstream or already-scanned. It is also more correct for
non-fast-forward pushes, where $old..$new can skip commits off the direct path.

Fixes #421

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S1qRZTJC6qgBsUSjNrBdkX
2026-07-18 16:45:15 -04:00