[codex] Reject unlowered PowerShell AST regions - #24092
Merged
Merged
Conversation
Contributor
|
Closing this pull request because it has had no updates for more than 14 days. If you plan to continue working on it, feel free to reopen or open a new PR. |
bookholt-oai
force-pushed
the
dev/bookholt/reject-powershell-param-blocks
branch
from
June 9, 2026 22:03
a68d68e to
c8674c3
Compare
bookholt-oai
marked this pull request as ready for review
June 9, 2026 22:19
viyatb-oai
reviewed
Jun 12, 2026
viyatb-oai
approved these changes
Jun 22, 2026
viyatb-oai
left a comment
Contributor
There was a problem hiding this comment.
Re-reviewed head 0726c1c. The original unlowered PowerShell AST findings are addressed, including named blocks, using preambles, and trap handlers, with parser and end-to-end regression coverage.
viyatb-oai
enabled auto-merge (squash)
June 22, 2026 23:15
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
On Windows, Codex uses a PowerShell safe-command classifier to decide whether a command is read-only enough to run without additional approval. The classifier lowers
EndBlock.Statementsinto argv-like command words and checks those words against a safelist.PowerShell can execute code stored elsewhere in the AST. Parameter defaults, named blocks,
usingpreambles, and top-leveltraphandlers are not represented in the lowered statement list. Ignoring those regions can make a side-effecting script look like a read-only command.What
Fail closed whenever a PowerShell script contains executable AST content that the current lowering does not represent.
How
unsupportedfor parameter, dynamic-parameter, begin, process, and clean blocks.unsupportedforusing moduleandusing assemblypreambles.unsupportedfor non-emptyEndBlock.Trapscollections.CleanBlockdynamically.unsupportedas a failure to prove that the command is safe, routing it through the normal approval path.This does not make these PowerShell forms invalid or prevent them from running. It prevents automatic safe-command approval when the classifier cannot account for all executable behavior.
Testing
just test -p codex-shell-command