fix: Windows shell quoting + PowerShell call operator for dsh adapter - #246
Merged
Yifan Yang (Yif-Yang) merged 1 commit intoAug 23, 2026
Merged
Conversation
dsh's ctx.shell is the platform executor: on win32 the bash stack is disabled and ctx.shell is a PowerShell executor (powershell.exe 5.1 / pwsh 7), on POSIX it is bash. The plugin emitted POSIX quotes unconditionally, so every tool command failed on Windows: 'python' 'args' parses as a string-array expression and errors with 'missing call operator' (bare quoted words are not a command in PowerShell). - q(): platform-aware quoting — PowerShell single-quote escaping (doubled quote for an embedded quote) on win32, POSIX (close/reopen) elsewhere. - quoteArgv(): prepend the `&` call operator on win32 so the quoted argv runs as a command; CRLF/lone CR folded to one space, C0 stripped. - canary/audits: host-shell aware (discover PowerShell 5.1/pwsh 7 like dsh-pwsh-local, or bash); injection + control-char audits run against the real host shell. Verified: canary 40/40 (platform-aware quoting), injection 7/7 + control-char 7/7 under real Windows PowerShell, real dsh 0.1.1-rc.2 skillopt_status runs. POSIX (bash) path unchanged — existing quoting suite still passes.
Contributor
Author
|
Thanks for your detailed review, Yifan Yang (@Yif-Yang). Going through your feedback on security and engineering standards taught me a lot while implementing the DSH adapter. Much appreciated for your guidance! This follow-up fix (Windows shell quoting + PowerShell call operator) is partly a result of that - the original merged version was POSIX-only, and testing it on the actual Windows runtime surfaced the missing |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds Windows support to the dsh integration. After the original PR (#237) merged, the plugin worked on POSIX but every tool command failed on Windows - dsh's ctx.shell is a PowerShell executor on win32 (the bash stack is disabled by
!!js process.platform === 'win32'in the base profile), and the plugin emitted POSIX quoting unconditionally, so'python' 'args'was parsed as a PowerShell string-array expression and errored with "missing call operator".Changes
q(): platform-aware quoting - PowerShell single-quote escaping (an embedded quote is doubled'') on win32, POSIX ('\''close/reopen) elsewhere. CRLF/lone CR folded to one space and C0 stripped before quoting.quoteArgv(): prepend the&call operator on win32 so the quoted argv runs as a command (PowerShell needs an explicit invocation; bash treats the first quoted word as the command).canary.mjs/audit-injection.mjs/audit-control-chars.mjs: host-shell aware - the audits now run payloads against the real host shell (discover PowerShell 5.1 / pwsh 7 likedsh-pwsh-local, or bash), and the canary asserts the platform-specific escape.Verification
skillopt_statusnow returns real output through the actual PowerShell executor (was "missing call operator" before).