Share Git safe-command logic on Windows#21275
Merged
iceweasel-oai merged 1 commit intomainfrom May 6, 2026
Merged
Conversation
evawong-oai
approved these changes
May 6, 2026
Contributor
evawong-oai
left a comment
There was a problem hiding this comment.
This PR makes the shared Git classifier the Windows source of truth, but that classifier need to also consider pager options when they appear before the subcommand.
Examples:
git --paginate log -1
git -p log -1
The current check rejects --paginate only after the matched subcommand. Git treats this as a global option too, so find_git_subcommand skips it, then the read only arg check never sees it.
Since the PR is specifically consolidating Git safety logic, I think we should either reject -p and --paginate as unsafe global Git options in this PR, or create a clear follow up before landing.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Why
BUGB-15601 showed that the Windows safe-command path had drifted from the generic Git classifier. The Windows-specific Git parser could classify a PowerShell-wrapped
gitcommand as safe as soon as it found a safelisted subcommand, without applying the generic checks for unsafe subcommand options such as--output,--ext-diff,--textconv,--paginate, orcat-file --filters.The generic classifier already models the Git command boundary and the read-only argument checks more carefully, so Windows should reuse that logic instead of maintaining a smaller parallel parser.
What Changed
is_safe_git_command.windows_safe_commands.rsto call that shared helper for parsed PowerShellgitcommands.cat-fileallowance that was part of the reported bypass.pwsh.exepath.Verification
cargo test -p codex-shell-command rejects_git_subcommand_options_with_side_effectscargo test -p codex-shell-command git_global_override_flags_are_not_safecargo test -p codex-shell-command windows_powershell_full_path_is_safe -- --nocapture