Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shell=true when spawning cmd files in windows #4969

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions eng/scripts/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ function run(command, args, options) {

if (process.platform === "win32" && isCmdOnWindows.includes(command)) {
command += ".cmd";
// When spawning .bat or .cmd files on windows, node will now error with EINVAL if shell is not set to true.
// https://nodejs.org/en/blog/vulnerability/april-2024-security-releases-2
options.shell = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be careful with this, you need to escape the args yourself if you pass some

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm... how deep do you think the change will go then?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is 3 options:

  1. One this isn't used anywhere where it is a problem so we can keep it
  2. Anywhere it is a problem we escape manually
  3. We use cross-spawn pacakge instead but autorest still using rush it is very anoying to have top level dev dependency for scripts.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was there something in particular that broke here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we push the escaping requirement to the caller and error here if they haven't already set shell=true?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was there something in particular that broke here?

Autorest regeneration fails consistently on a single project in azure-sdk-for-net:

https://dev.azure.com/azure-sdk/internal/_build/results?buildId=3806494&view=logs&j=22d114d9-e1b7-5381-70ab-ddaabfa32a9d&t=1eb743b7-6600-5425-47d2-d44920e345d6&l=2235

  fatal   | Process() cancelled due to failure 
EXEC : error   | error : spawn EINVAL [D:\a\_work\1\s\azure-sdk\sdk\resourcehealth\Azure.ResourceManager.ResourceHealth\src\Azure.ResourceManager.ResourceHealth.csproj]
  error   | Autorest completed with an error. If you think the error message is unclear, or is a bug, please declare an issues at https://github.com/Azure/autorest/issues with the error message you are seeing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we push the escaping requirement to the caller and error here if they haven't already set shell=true?

yeah we could do that,

so I doubt this will fix the error above. This file is only used for intenral scripts

}

const proc = (options.sync ? spawnSync : spawn)(command, args, options);
Expand Down
Loading