Compare commits

...

1 Commits

Author SHA1 Message Date
didericis-codex 272e4eb776 fix(git-gate): reject AGit review refs
test / integration-macos (pull_request) Has been skipped
test / integration-docker (pull_request) Successful in 33s
test / unit (pull_request) Successful in 54s
lint / lint (push) Successful in 1m0s
tracker-policy-pr / check-pr (pull_request) Successful in 8s
test / integration-firecracker (pull_request) Successful in 3m59s
test / coverage (pull_request) Successful in 16s
test / publish-infra (pull_request) Has been skipped
2026-07-26 17:51:43 +00:00
2 changed files with 32 additions and 0 deletions
+17
View File
@@ -252,6 +252,23 @@ cat > "$refs_file"
zero=0000000000000000000000000000000000000000
# AGit creates pull requests by pushing to refs/for/* (with refs/draft/*
# and refs/for-review/* aliases). Those server-owned review refs are not
# ordinary repository branches and leave the resulting PR without a
# branch that the bottle can update later. Require the normal
# push-branch-then-open-PR workflow instead. Deletion remains allowed so
# operators can clean up refs created before this guard existed.
while IFS=' ' read -r old new ref; do
[ -z "$ref" ] && continue
[ "$new" = "$zero" ] && continue
case "$ref" in
refs/for/*|refs/draft/*|refs/for-review/*)
echo "git-gate: AGit review refs are disabled; push to refs/heads/<branch> and open the pull request from that branch" >&2
exit 1
;;
esac
done < "$refs_file"
supervise_gitleaks_allow() {
log_opts=$1
ref=$2
+15
View File
@@ -181,6 +181,21 @@ class TestHookRender(unittest.TestCase):
self.assertNotIn('log_opts="$new"', hook)
self.assertNotIn('log_opts="$old..$new"', hook)
def test_agit_review_refs_are_rejected_before_scanning(self):
hook = git_gate_render_hook()
guard = "refs/for/*|refs/draft/*|refs/for-review/*"
self.assertIn(guard, hook)
self.assertIn(
"AGit review refs are disabled; push to refs/heads/<branch>",
hook,
)
self.assertLess(hook.index(guard), hook.index("# Phase 1: gitleaks"))
# Ref deletion must remain possible for cleanup.
self.assertLess(
hook.index('[ "$new" = "$zero" ] && continue'),
hook.index(guard),
)
def test_forward_ssh_is_non_interactive_and_bounded(self):
# No prompt (BatchMode) and a connect timeout, so an unreachable
# upstream fails fast instead of hanging the receive-pack.