aws / aws-toolkit-vscode

Amazon Q, CodeCatalyst, Local Lambda debug, SAM/CFN syntax, ECS Terminal, AWS resources
https://marketplace.visualstudio.com/items?itemName=AmazonWebServices.amazon-q-vscode
Apache License 2.0
1.46k stars 403 forks source link

Notification of breaking api change with v1.92 release of VS Code #5292

Closed deepak1556 closed 1 month ago

deepak1556 commented 1 month ago

Hello from the VS Code team 👋

In our next release v1.92, we will update to Electron 30 which includes Node.js 20.14.0. This Node version contains a breaking change, in response to a CVE, which may affect you if you execute .bat or .cmd files on Windows. Based on a simple scan of your extension's source code, you may be impacted by this change. The stable VS Code that contains this update will be released in early August.

Action: please try out your extension on this month's VS Code Insiders on Windows. If you are affected by this change, you will encounter an EINVAL error when you try to spawn a bat/cmd file.

Node.js has added a section on batch file spawning to their documentation. To fix any issues:

  1. Find locations where you call child_process.spawn to execute a batch file on Windows
  2. Add shell: true or shell: process.platform === 'win32' to the options object
  3. If the batch script path may contain spaces, you will also need to wrap the path in quotation marks.

Please let us know if you run into issues or if you need clarification.

Happy coding!

justinmk3 commented 1 month ago

If SAM CLI is a .cmd file on Windows, this likely affects all of the related ChildProcess invocations. Example: https://github.com/aws/aws-toolkit-vscode/blob/80e715bbf3e6eb354a9b6e5e327c732b89df38e3/packages/core/src/shared/sam/cli/samCliInfo.ts#L17

This shouldn't affect EC2 connect nor CodeCatalyst connect, since the .ps1 files are part of the sshconfig ProxyCommand and not directly invoked by us.

jpinkney-aws commented 1 month ago

It looks like sam is for sure a .cmd on windows:

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     sam.cmd                                            0.0.0.0    C:\Program Files\Amazon\AWSSAMCLI\bin\sam.cmd
jpinkney-aws commented 1 month ago

I tried this out on:

Version: 1.92.0-insider (user setup)
Commit: 4d17e85cfd911fb6b116e08a4d7c37cd725a966a
Date: 2024-07-26T13:12:28.318Z
Electron: 30.1.2
ElectronBuildId: 9870757
Chromium: 124.0.6367.243
Node.js: 20.14.0
V8: 12.4.254.20-electron.0
OS: Windows_NT x64 10.0.19045

Things I tried:

  1. ✔️ I used sam init to create a node 20 project.
    1. ✔️ Created launch config
      1. ✔️ Invoking template worked
      2. ✔️ Invoking API worked
  2. ✔️ I used sam init to create a python 3.11 project.
    1. ✔️ Created launch config
      1. ✔️ Invoking template worked
      2. ✔️ Invoking API worked
  3. ✔️ Invoked "AWS: Detect SAM CLI"
  4. ✔️ Successfully connected to a codecatalyst workspace
  5. ✔️ Successfully tried Amazon Q
    1. ✔️ Including the new workspace feature

I looked a deeper look into how we wrap our child process calls. Turns on we use crossSpawn which takes care of commands with spaces and seems to ensure the correct execution of commands if a shell is needed for windows

I guess that makes sense why none of our tests were failing