fix(git-gate): scan $new --not --all for every push, not $old..$new #422
Reference in New Issue
Block a user
Delete Branch "fix-git-gate-force-push-scan-range"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
git-gate's pre-receive hook scanned existing-branch updates with
$old..$new. On a rebase / non-fast-forward force-push onto a branch whose basemainhas advanced,$old(the old tip) is no longer an ancestor of$new, so$old..$newexpands to all of main's new history — including the deliberate sandbox-escape gitleaks fixtures (15f0e0b). gitleaks trips on those and rejects a push that introduced no new secret.Fix
Unify the scan range on
$new --not --allfor every non-delete push — the deferred open question from PRD 0028, which already applied it to new refs for #106. It scans only the commits the push actually introduces (not reachable from any ref the gate already holds) and is security-equivalent per PRD 0028's analysis: 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's also more correct for non-fast-forward pushes, where$old..$newcan skip commits off the direct path.Tests
Renamed/rewrote the scan-scope unit test in
tests/unit/test_git_gate.pyto assert the unified range and that neitherlog_opts="$new"(full ancestry) norlog_opts="$old..$new"(ancestry-blind delta) survives. Full git-gate suite green (37 tests).Deployment note
The running gateway in the infra firecracker VM was live-patched with the rendered hook (canonical
/etc/git-gate/pre-receive+ all bare repos'hooks/pre-receive) so in-flight bottles are unblocked immediately;git receive-packre-reads the on-disk hook per push, so no gateway restart was needed. Future bottle launches render this fixed hook from source.Fixes #421
🤖 Generated with Claude Code
https://claude.ai/code/session_01S1qRZTJC6qgBsUSjNrBdkX