Conversation
|
Plz update the lint_driver and trunk.yaml node versions as well, i.e. https://github.com/search?q=repo%3Atrunk-io%2Fplugins%20node%40&type=code |
|
|
|
|
|
| encoding: "utf8" as const, | ||
| windowsHide: options.windowsHide, | ||
| }; | ||
| const printConfig = execSync([executable, ...args].join(" "), execOptions); |
Check warning
Code scanning / CodeQL
Shell command built from environment values Medium test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 month ago
In general, to fix this class of issue you should avoid constructing a single shell command string that mixes executable paths and arguments; instead, pass the executable and arguments as separate parameters to execFileSync/execFile (or the platform equivalent). This prevents environment-controlled values (paths, args) from being interpreted by the shell.
For this concrete code, the best fix is to change getFullTrunkConfig so it no longer calls execSync with [executable, ...args].join(" "). We already have buildExecArgs returning the executable, arguments array, and options suitable for execFileSync. So in getFullTrunkConfig we can:
- Keep using
buildExecArgs(["config", "print"])to get[executable, args, options]. - Replace the
execSynccall withexecFileSync(executable, args, execOptions), whereexecOptionsis built as it is now (without specifyingshell: true). - This removes the need to join into a single string, so no shell interpretation occurs, and any spaces or special characters in
ARGS.cliPathor args are handled safely.
The only file needing modification is tests/driver/driver.ts, within the getFullTrunkConfig method. No new imports or helpers are required because execFileSync is already imported at the top of the file.
| @@ -310,7 +310,7 @@ | ||
| encoding: "utf8" as const, | ||
| windowsHide: options.windowsHide, | ||
| }; | ||
| const printConfig = execSync([executable, ...args].join(" "), execOptions); | ||
| const printConfig = execFileSync(executable, args, execOptions); | ||
| return YAML.parse(printConfig.replaceAll("\r\n", "\n")); | ||
| }; | ||
|
|
No description provided.