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

[dev-tool] react to NodeJS spawn security fix #29414

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 8 additions & 5 deletions common/tools/dev-tool/src/commands/run/vendored.ts
Expand Up @@ -18,22 +18,25 @@ const log = createPrinter("vendored");

const DOT_BIN_PATH = path.resolve(__dirname, "..", "..", "..", "node_modules", ".bin");

function isWindows() {
return process.platform === "win32";
}

/**
* Wraps a command in an executor that satisfies the dev-tool command interface.
*
* @param commandName - name of the command to run from DOT_BIN_PATH
* @returns a function that executes the command and returns a boolean status
*/
function makeCommandExecutor(commandName: string): (...args: string[]) => Promise<boolean> {
const commandPath =
process.platform !== "win32"
? path.join(DOT_BIN_PATH, commandName)
: path.join(DOT_BIN_PATH, `${commandName}.CMD`);
const commandPath = isWindows()
? path.join(DOT_BIN_PATH, `${commandName}.CMD`)
: path.join(DOT_BIN_PATH, commandName);

return (...args: string[]) =>
new Promise<boolean>((resolve, reject) => {
log.debug("Running vendored command:", commandPath);
const command = spawn(commandPath, args, { stdio: "inherit" });
const command = spawn(commandPath, args, { stdio: "inherit", shell: isWindows() });

// If the command exited 0, then we treat that as a success
command.on("exit", (code) => {
Expand Down