fix(amazonq): make cmd.exe builtin detection locale-independent#2790
Open
peschuster wants to merge 1 commit into
Open
fix(amazonq): make cmd.exe builtin detection locale-independent#2790peschuster wants to merge 1 commit into
peschuster wants to merge 1 commit into
Conversation
resolveWindowsCommand probed 'cmd.exe /c help <cmd>' and looked for the English 'not supported by the help utility' marker. That string is localized, so on non-English Windows (e.g. German) every unknown command was treated as a valid builtin and passed validation. Replace the probe with a static set of cmd.exe internal commands and check it before falling back to 'where' for external commands.
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.
Problem
On non-English Windows systems,
executeBashcommand validation is broken:every unknown command passes validation as a supposed cmd.exe builtin.
resolveWindowsCommandprobescmd.exe /c help <cmd>and checks the outputfor the English marker
"This command is not supported by the help utility".That string is localized, so e.g. on a German-locale system the marker never
matches and any command that
wherecannot find is accepted as a builtin.This is visible in the existing test suite:
"whichCommand cannot find the first arg"(executeBash.test.ts) fails on a de-DE Windows machine againstcurrent
mainwithMissing expected rejection, becausenoSuchCmdincorrectly passes validation.
Solution
Replace the locale-dependent
helpprobe with a static set of cmd.exeinternal commands, checked before falling back to
wherefor externalcommands. As a side effect this saves one child-process spawn when
validating non-builtin commands.
Added a win32-gated test asserting that a builtin without an executable on
PATH (
assoc) passes validation.Testing: ran the full
executeBash.test.tssuite on German-localeWindows 11: 57 passing with this change; without it, the existing
noSuchCmdtest fails as described above.License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.