Repository navigation
feat(vetted-ops): let the ~ spelling reach Codex rules safely - #1670
Merged
Merged
Conversation
Skills invoke the dispatcher as uv run --project ~/.claude/magpie/vetted-ops, which Codex execpolicy never matches: its plain-command parser rejects any word containing ~. A ~ rule would be unsafe rather than a fix, because the shell resolves ~ from a reassignable HOME and uv treats a literal ~ as a relative directory the agent can create, so every read-only vetted op prompted instead. A Codex-only PreToolUse hook now rewrites a command that is exactly one vetted-op-read call in that spelling to the absolute stable path fixed at render time, the same path the rules name, before the rules run. Write entry points and anything chained, redirected or substituted are never rewritten, so the hook can at most let through the lone read the rules already allow. Generated-by: Claude Opus 5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Skills invoke the dispatcher as
uv run --project ~/.claude/magpie/vetted-ops vetted-op-read …, which the Codex rules added in #1649 never match, so every read-only vetted operation prompts under Codex. Allowing~in the rules would not be a fix:~(codex-rs/shell-command/src/bash.rs), so a shell-string command with~never reaches a prefix rule at all.~in an argv-form command would be worse:uvdoes not expand it and treats~/…as a relative directory, so an agent-created./~/.claude/magpie/vetted-opswould run with anallowand a sandbox bypass. In shell form,~followsHOME, which an earlier command can reassign.So the rules stay absolute-only, and the
~is resolved before they run:vetted-ops-codex-rules --hookprints a Codex-onlyPreToolUsehook registration with the same absolute stable path the rules name (--stable-path, fixed at render time). It goes in the user's~/.codex/config.toml, after review, like the rules.vetted-op-readcall in the~spelling, with plain or simply quoted arguments. Write entry points (vetted-op,vetted-op-tracker) and anything chained, redirected, substituted or multi-line are left untouched.allowonly carriesupdatedInput: a hook result is either continue (with an optional rewrite) or blocked, and the rewritten command then goes through the native rules and approval. Even ifallowwere read as an approval, the hook could only let through the lone read the rules already allow.allowas a permission grant, so the hook is registered in Codex config only, and as a backstop stays silent unless the event carries Codex'sturn_idandmodelfields.Tests cover the rewrite, 24 inputs it must leave alone (writes,
;/&&/pipes, redirection,$(…), backticks, heredocs, quoted/escaped/lookalike paths), theHOME-independent fallback, the output contract (including a Claude-style event that must stay silent), and a round trip through the realcodex execpolicy check: the skill's~command matches nothing, and its rewrite matches the absoluteallowrule.Not verified end to end in a live Codex session (that needs a model run); the hook/approval interaction is from the 0.163.0 source.
Second read: roborev (claude-code), iterated until it passed; a background security review shaped the lone-read restriction.
Generated-by: Claude Opus 5
🤖 Generated with Claude Code