git-gate: rebase/force-push scans main history ($old..$new drags in fixture secrets), rejecting clean pushes #421
Reference in New Issue
Block a user
Delete Branch "%!s()"
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?
Summary
git-gate's pre-receive hook scans an existing-branch update with the delta range
$old..$new. For a rebase / non-fast-forward force-push onto a branch whose base (main) has advanced,$old(the old branch tip) is no longer an ancestor of$new, so$old..$newresolves to every commit reachable from the new tip but not from the old tip — which pulls in all of main's new history, including the deliberate sandbox-escape gitleaks fixtures (e.g.15f0e0b). gitleaks then trips on those historical fixtures and the push is rejected, even though the push itself introduces no new secret.This is the exact failure mode that PRD 0028 fixed for new branches (#106) via
$new --not --all, but the existing-branch/force-push path was left on$old..$new— called out as a deferred open question in PRD 0028:Repro
main, push through the gate (succeeds).mainadvances upstream to include a commit containing a gitleaks-shaped fixture.mainandgit push --force-with-lease.gitleaks rejected pushon fixture commits that belong tomain, not to the branch.Fix
Unify the scan range on
$new --not --allfor every non-delete push (new refs and updates alike). This scans only the commits the push actually introduces — those not reachable from any ref the gate already holds — and is security-equivalent per PRD 0028's analysis: the bare repo's refs are populated only by trusted upstream mirror-fetch and gitleaks-gated pushes, so an excluded commit is already-upstream or already-scanned and cannot smuggle a new secret. It is also strictly more correct for non-fast-forward pushes, where$old..$newcan miss commits off the direct path.Notes
Distinct from #346 (matching the bottle's injected known secrets vs. gitleaks patterns) — this is purely about the commit range scanned. Related: #106, PRD 0028.