Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

agent-guard: the +refspec force spelling bypasses the empty-rebase guard

Aperta Adatta ai principianti
#1,606 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@liwenjie200543 ci sta già lavorando.

Dal 13/10/2026.

  • #1607 di @liwenjie200543 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
76/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
git, python
Ambito
devtools, security

Direzione di ricerca

Leggi tools/agent-guard/src/agent_guard/__init__.py nella sezione intorno a guard_empty_rebase e i test esistenti del guard. Segui il modo in cui gli argomenti di push identificano i refspec forzati e come viene risolta la ref sorgente, quindi esegui i test pertinenti del guard. Il lavoro è completato quando git push origin +pr:main viene rifiutato per un branch vuoto e i casi esistenti con force flag continuano a comportarsi come previsto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

What's broken

The bundled empty-rebase guard recognizes only -f, --force and --force-with-lease[=...] as a force-push. git-push(1) documents a + refspec prefix as equivalent to --force for that refspec, so git push origin +empty-branch:main — a standard force-push spelling — reaches the push without the guard firing. The guard exists because force-pushing a branch with 0 commits over its base to a PR head auto-closes the PR and revokes maintainer write access.

Where

guard_empty_rebase in tools/agent-guard/src/agent_guard/__init__.py (line ~882 on main @ dadb315c): the forced check scans only flags, and the src-ref resolution keeps the leading +, so even recognizing the flag alone would not be enough.

Reproduce

Repo with a bare origin (origin/HEAD -> main), empty branch pr:

git push --force origin pr:main   # denied by the guard
git push origin +pr:main          # allowed — same semantics, no deny

Both spellings have identical push semantics; the second one is allowed through.

Suggested fix

Treat any refspec positional starting with + as forced, and strip the prefix before resolving src (git rev-parse +ref fails and would fail open). Patch and tests ready; happy to send a PR.

Lingua principale
Python
Stelle
113
Fork
95
Merge medio
11h 17m
PR unite (30g)
332

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/magpie

Tutte le issue di apache/magpie

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.