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

Conversation

hallipr
Copy link
Member

@hallipr hallipr commented May 21, 2024

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

@@ -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

Copy link

You may test this build by running autorest --reset and then either:


Add the following CLI flags
Pacakge Flag Description
@autorest/core --version:https://tinyurl.com/2639ambr For changes to autorest core.
@autorest/modelerfour --use:https://tinyurl.com/2dj6wno3 For changes to modelerfour.

Or with all

autorest --version:https://tinyurl.com/2639ambr --use:https://tinyurl.com/2dj6wno3

or use the following in your autorest configuration:
# For changes to autorest core
version: "https://tinyurl.com/2639ambr"

# For changes to modelerfour
use-extension:
  "@autorest/modelerfour": "https://tinyurl.com/2dj6wno3"

If this build is good for you, give this comment a thumbs up. (👍) And you should run `autorest --reset` again once you're finished testing to remove it.

Copy link
Member

@timotheeguerin timotheeguerin left a comment

Choose a reason for hiding this comment

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

As said in my last comment this should be ok but it will not fix anything for user of autorest, it only affect eng scripts of the repo

@hallipr hallipr closed this May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants