(args, platform = process.platform)
| 62 | } |
| 63 | |
| 64 | export function assertSafeWindowsShellArgs(args, platform = process.platform) { |
| 65 | if (platform !== "win32") { |
| 66 | return; |
| 67 | } |
| 68 | const unsafeArg = args.find((arg) => WINDOWS_UNSAFE_SHELL_ARG_PATTERN.test(arg)); |
| 69 | if (!unsafeArg) { |
| 70 | return; |
| 71 | } |
| 72 | // SECURITY: `shell: true` routes through cmd.exe; reject risky metacharacters |
| 73 | // in forwarded args to prevent shell control-flow/env-expansion injection. |
| 74 | throw new Error( |
| 75 | `Unsafe Windows shell argument: ${unsafeArg}. Remove shell metacharacters (" & | < > ^ % !).`, |
| 76 | ); |
| 77 | } |
| 78 | |
| 79 | function createSpawnOptions(cmd, args, envOverride) { |
| 80 | const useShell = shouldUseShellForCommand(cmd); |
no test coverage detected