-
Notifications
You must be signed in to change notification settings - Fork 7.9k
fix(core): canonicalize wrapper approvals and support heredoc prefix … #10941
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(core): canonicalize wrapper approvals and support heredoc prefix … #10941
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3964f175be
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "word" | "number" => { | ||
| words.push(child.utf8_text(src.as_bytes()).ok()?.to_owned()); | ||
| } | ||
| // Allow shell constructs that attach IO to a single command without | ||
| // changing argv matching semantics for the executable prefix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure non-heredoc
<< scripts don’t bypass approvals
This parser accepts any word nodes verbatim, and parse_shell_lc_single_command_prefix is gated only by script.contains("<<"). That combination means scripts that merely contain << (e.g., arithmetic shift echo $((1<<2)) or a here‑string with command substitution like python3 <<< "$(rm -rf /)") can be reduced to a simple argv prefix and matched by prefix_rule, skipping approvals that previously triggered when word‑only parsing failed. This is a regression in safety: << in non‑heredoc contexts can now be used to bypass the intended “complex script” fallback. Consider verifying that the AST actually contains a heredoc redirect, and/or rejecting words that include expansions before returning a prefix.
Useful? React with 👍 / 👎.
…cy-heredoc-canonicalization # Conflicts: # codex-rs/core/src/exec_policy.rs
Summary
Fixes
python3 <<'PY' ... PYmatch rules such asprefix_rule(["python3"], ...).Edge Cases Covered
/bin/bashvsbash,/bin/zshvszsh.-cand-lc.<<'PY') and unquoted delimiter (<< PY).>, etc.) are not treated as heredoc prefix matches.