You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@magpie.apache.org by "AmirF194 (via GitHub)" <gi...@apache.org> on 2026/09/22 12:35:21 UTC
[I] agent-guard: git guards are bypassed by an ordinary global flag before the subcommand [magpie]
AmirF194 opened a new issue, #1329:
URL: https://github.com/apache/magpie/issues/1329
## What's broken
`guard_commit_trailer` and `guard_empty_rebase` (the two bundled `git` guards) check `seg.argv[:2] == ["git", "commit"]` / `["git", "push"]`. Any ordinary global `git` option before the subcommand shifts it to `argv[2]`, so the check is never true and the guard denies nothing. The dispatcher's own `command_kinds` pre-filter has the same shape (`seg.argv[1]`), and the bundled example contributed guard `guards.d/no_verify_commit.py` copies the same `argv[:2]` check, so all three fail the same way.
## Which layer
`tools/agent-guard/src/agent_guard/__init__.py`: `guard_commit_trailer` (~line 354), `guard_empty_rebase` (~line 369), `command_kinds` (~line 542). `tools/agent-guard/src/agent_guard/guards.d/no_verify_commit.py`: `guard` (~line 42).
## How to reproduce
```python
from agent_guard import dispatch
dispatch('git commit -m "x\n\nCo-Authored-By: a"') # denied
dispatch('git -C /tmp commit -m "x\n\nCo-Authored-By: a"') # None -- bypassed
dispatch('git -c core.editor=true commit -m "x\n\nCo-Authored-By: a"') # None
dispatch('git --no-pager commit -m "x\n\nCo-Authored-By: a"') # None
```
Same shape for `guard_empty_rebase` (`git -C <dir> push --force ...`) and for the bundled `no-verify` guard (`git -C <dir> commit --no-verify`, which also silently skips `guard()` entirely because `command_kinds` never adds the `git:commit` tag the guard's `TRIGGERS` filters on).
## Expected vs actual
Expected: all three deny regardless of a global flag before the subcommand, the same way `gh_subcommand` already walks past `gh`'s global flags (`gh --repo o/r pr create` is still caught).
Actual: `git -C <dir> commit ...`, `git -c <k>=<v> commit ...`, and `git --no-pager commit ...` bypass `guard_commit_trailer`; the equivalent `push` forms bypass `guard_empty_rebase`; and `git -C <dir> commit --no-verify` bypasses the bundled `no-verify` guard both at the `TRIGGERS` pre-filter and inside `guard()` itself. `git -C <dir>` in particular is an everyday pattern, not a crafted input: it is how this framework's own multi-clone tooling invokes git from outside the target checkout.
## Surface area (optional)
Any future skill-contributed guard that declares `TRIGGERS = ["git:commit"]` / `["git:push"]` inherits the `command_kinds` bug at the dispatch pre-filter, before its own `guard(ctx)` ever runs.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@magpie.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] agent-guard: git guards are bypassed by an ordinary global flag before the subcommand [magpie]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk closed issue #1329: agent-guard: git guards are bypassed by an ordinary global flag before the subcommand
URL: https://github.com/apache/magpie/issues/1329
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@magpie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org