Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン 初心者向け
#1,606 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@liwenjie200543 がすでに取り組んでいます。

2026年10月13日 から。

  • #1607 @liwenjie200543 による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
76/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
git, python
領域
devtools, security

調査の方向性

tools/agent-guard/src/agent_guard/__init__.pyのguard_empty_rebase周辺と、既存のguardテストを読む。pushの引数から強制refspecを特定する方法と、ソースrefの解決方法をたどり、関連するguardテストを実行する。空のブランチに対してgit push origin +pr:mainが拒否され、既存のforce flagのケースも引き続き想定どおりに動作すれば完了。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Python
スター
113
フォーク
95
平均マージ
10時間 48分
マージ済み PR(30日)
348

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/magpie のほかの issue

apache/magpie の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。