Skip to content

Commit ee995db

Browse files
committed
fix: fix shell injection in task spawning
closes #9058
1 parent 020610f commit ee995db

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

editors/code/src/tasks.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export async function buildCargoTask(
8080
throwOnError: boolean = false
8181
): Promise<vscode.Task> {
8282

83-
let exec: vscode.ShellExecution | undefined = undefined;
83+
let exec: vscode.ProcessExecution | vscode.ShellExecution | undefined = undefined;
8484

8585
if (customRunner) {
8686
const runnerCommand = `${customRunner}.buildShellExecution`;
@@ -105,13 +105,13 @@ export async function buildCargoTask(
105105

106106
if (!exec) {
107107
// Check whether we must use a user-defined substitute for cargo.
108-
const cargoCommand = definition.overrideCargo ? definition.overrideCargo : toolchain.cargoPath();
108+
// Split on spaces to allow overrides like "wrapper cargo".
109+
const overrideCargo = definition.overrideCargo ?? definition.overrideCargo;
110+
const cargoCommand = overrideCargo?.split(" ") ?? [toolchain.cargoPath()];
109111

110-
// Prepare the whole command as one line. It is required if user has provided override command which contains spaces,
111-
// for example "wrapper cargo". Without manual preparation the overridden command will be quoted and fail to execute.
112-
const fullCommand = [cargoCommand, ...args].join(" ");
112+
const fullCommand = [...cargoCommand, ...args];
113113

114-
exec = new vscode.ShellExecution(fullCommand, definition);
114+
exec = new vscode.ProcessExecution(fullCommand[0], fullCommand.slice(1), definition);
115115
}
116116

117117
return new vscode.Task(

0 commit comments

Comments
 (0)