Repository navigation
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7ef0c5ccbd
ℹ️ 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".
| return arg; | ||
|
|
||
| // Escape inner double quotes and wrap | ||
| return "\"" + arg.Replace("\"", "\\\"") + "\""; |
There was a problem hiding this comment.
Escape embedded quotes with PowerShell rules
QuoteArgIfNeeded currently escapes inner " before wrapping in double quotes, but BuildProcessArgs feeds the result to powershell.exe/pwsh -Command, where backslash is not a quote-escape character. Any argv element containing a literal " (for example JSON snippets or prompts with quotes) will be parsed incorrectly by PowerShell and can fail command execution or alter the argument value. This regression is introduced by the new quote-handling path and needs shell-correct escaping for PowerShell commands.
Useful? React with 👍 / 👎.
7ef0c5c to
914e815
Compare
When system.run receives a command as an argv array, BuildProcessArgs joins the args with spaces before passing to the shell. Args containing spaces (e.g. a -p prompt like 'List all files') would be split into separate tokens by the shell, causing tools like GitHub Copilot CLI to report 'too many arguments'. Added QuoteArgIfNeeded() that wraps args containing spaces, quotes, or tabs in double quotes with proper escaping.
914e815 to
3ab7eda
Compare
The gateway's nodes 'run' action requires system.run.prepare to build an execution plan before the actual run. Without it, the only path is the 'invoke' action which has a hardcoded 30s gateway timeout — too short for long-running tools like Copilot CLI. system.run.prepare echoes back the argv, cwd, rawCommand, agentId, and sessionKey without executing anything, enabling the gateway to use its configurable timeout path for the actual execution.
d5c8a58 to
4f8c387
Compare
Address review findings from PRs #29 and #32: - QuoteArgIfNeeded: check all shell metacharacters (& | ; < > etc.), not just whitespace/quotes — prevents command injection - cmd.exe: use doubled-quote escaping (%"%") instead of backslash which cmd doesn't recognize - FormatExecCommand: align metacharacter checks with QuoteArgIfNeeded so system.run.prepare shows the same command that actually executes - StringBuilder: add lock around stdout/stderr event handlers and ToString() reads to prevent concurrent-access corruption Co-authored-by: danedane <[email protected]> Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Copilot <[email protected]>
|
Hey @danedane — great catch on the argv space-splitting bug and nice addition of system.run.prepare! Really appreciate the contribution. This work has been cherry-picked into #38 along with the IPC hang fix from #29. During review we hardened the quoting (all shell metacharacters, fixed cmd.exe escaping to use doubled quotes), extracted a shared ShellQuoting helper class, and added 43 unit tests. Thanks for kicking this off! |
|
Thanks Scott. Have you found a way to keep the gateway open past 30s from WSL to Windows Node? I added this PR but maybe there's a simpler approach. openclaw/openclaw#42590 |
Changes
Problem: When system.run receives a command as an argv array, BuildProcessArgs joins args with spaces but doesn't quote args containing spaces. Multi-word arguments (e.g. -p "List all files") get split into separate tokens.
Fix: Added QuoteArgIfNeeded() with shell-aware escaping:
• cmd.exe: double quotes with backslash-escaped inner quotes
• PowerShell: single quotes with doubled inner quotes
PowerShell requires single quotes because double quotes in ProcessStartInfo.Arguments are stripped by the Windows CRT argv parser before PowerShell receives the -Command string.
Problem: The gateway's nodes run action requires system.run.prepare to build an execution plan before the actual run. Without it, the only path is the invoke action which has a hardcoded 30s gateway timeout — too short for long-running tools like GitHub Copilot CLI.
Fix: Added system.run.prepare handler to SystemCapability that echoes back the execution plan (argv, cwd, rawCommand, agentId, sessionKey) without executing anything. Includes FormatExecCommand() helper that matches the gateway's argv formatting for consistency validation.
Testing
Verified on Windows node:
• ✅ Args with spaces preserved: Write-Output 'hello world' → single arg
• ✅ Copilot CLI with multi-word -p prompt runs successfully via nodes run
• ✅ system.run.prepare enables configurable timeout path (tested 120s+)
• ✅ Gateway rawCommand/command consistency validation passes no