Repository navigation
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
|
We've updated our contribution guidelines to indicate that we're no longer accepting unsolicited code contributions. All code contributions are by invitation only. To read more about why we've taken this step, please refer to this announcement. |
|
@etraut-openai understandable, please check the issue I linked, and, keep in mind that:
|
|
This change, broadening This is not fully safe, because
|
Summary
Fix execpolicy matching when a wrapped shell script contains redirection (for example
> /tmp/logor2>&1).Fixes #10321.
Before this change, commands like
gh run view ... > /tmp/logorxcodebuild ... 2>&1could repeatedly prompt for approval even after selecting "Yes, and don't ask again".Problem
Approval persistence relies on extracting inner command prefixes from wrapper invocations such as
zsh -lc "...".For redirected scripts,
core/src/exec_policy.rscalledparse_shell_lc_plain_commands, which rejects redirections by design. That forced fallback to the outer wrapper argv (zsh -lc ...), so saved prefix rules such as["gh", "run", "view"]did not match future runs.Root Cause
commands_for_exec_policyused a parser that only accepts "plain" word-only commands.Fix
shell-command/src/bash.rs:parse_shell_lc_commands_for_exec_policyaccepts redirected statements and command attachments needed for matching (file_redirect,variable_assignment, comments).core/src/exec_policy.rsto useparse_shell_lc_commands_for_exec_policyincommands_for_exec_policy.Why This Is Safe
Reproduction (Before vs After)
Representative command
/bin/zsh -lc "gh run view --help > /tmp/codex-gh-run-view-help.log && echo saved"Before
gh run view".After
Tests Added
core/src/exec_policy.rsevaluates_redirected_shell_script_against_prefix_rulescommands_for_exec_policy_parses_redirected_sequencesshell-command/src/bash.rsparse_shell_lc_commands_for_exec_policy_supports_redirectsparse_shell_lc_commands_for_exec_policy_rejects_substitutionscore/tests/suite/approvals.rsgh_run_view_prefix_rule_allows_redirected_command_without_promptVerification Performed
Local bug reproduction
core/src/exec_policy.rs:Local checks run
cargo test -p codex-core redirected -- --nocapturecargo test -p codex-core gh_run_view_prefix_rule_allows_redirected_command_without_prompt -- --nocapturejust fix -p codex-coreAll passed.
Related Reports
xcodebuild, even after permitting allxcodebuildcommands #10321xcodebuild ... 2>&1and repeated approval despite prior allow.Existing PRs Checked
This PR complements those by covering non-heredoc redirection command extraction.