Repository navigation
Studio: ask before running Python fed to Terminal through a heredoc - #17256
Conversation
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 66d1a7b35d
ℹ️ 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".
| for heredoc in _HEREDOC_TO_INTERPRETER_RE.finditer(command): | ||
| if not heredoc.group(1).startswith("python") or _depth >= 3: | ||
| return True |
There was a problem hiding this comment.
Restrict heredoc matches to executable shell positions
In auto mode, echo 'node <<EOF' now requires approval even though it only prints its argument (Bash's help echo: “Write arguments to the standard output.”). finditer(command) searches quoted arguments and other heredoc bodies, and the non-Python branch immediately returns True for these non-executable mentions. A quoted cat heredoc containing a Node script example reproduces the same regression, so ordinary documentation/script generation is needlessly interrupted. Restrict this check to executable shell positions and exclude quoted data and other heredoc bodies.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
This only adds an approval prompt for a quoted mention, so it fails closed. The herestring check right above it works the same way (echo 'python3 <<<x' already asks), and I'd rather keep the two consistent than add a quote-aware scanner here.
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 66d1a7b35d
ℹ️ 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".
| if line == heredoc.group(4): | ||
| break | ||
| body.append(line) | ||
| if _inline_python_is_high_risk("\n".join(body)): |
There was a problem hiding this comment.
Fail closed if heredoc analysis exceeds the recursion limit
On Python 3.12 with its default recursion limit, a harmless python3 - <<'PY' heredoc assigning a sum of 600 literal 1s (~1.2 KB) now raises RecursionError in _check_signal_escape_patterns's recursive AST visitor. The same command is accepted by the parent classifier and runs successfully, but this new call lets the exception propagate through state/tool_policy.py::_classify, aborting the auto-mode tool turn before an approval card or execution. Catch analyzer recursion failures and fail closed with a high-risk result.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The RecursionError comes from the shared Python analyzer, not the heredoc path: python3 -c with the same 600-term sum and the python tool itself hit it on this head too. Worth fixing in the analyzer in its own PR rather than wrapping just this call.
… more interpreters [skip ci]
…nly Python stdin programs [skip ci]
…, any redirect order) and honour python -i [skip ci]
…er is named but the heredoc owner or terminator is unresolved [skip ci]
Terminal asks before
python3 -c "...shutil.rmtree('build')", but the same code as a heredoc (python3 - <<'PY' ... PY) ran with no approval card. Heredoc Python now goes through the same check aspython -c, andnode/ruby/perl/phpheredocs always ask, likenode -e. Harmless scripts andcatheredocs are unchanged.Before / after
Terminal running a
python3 - <<'PY'heredoc that callsshutil.rmtree('build'): main runs it with no card, this PR asks.