MEDIUM child-process-exec Extension spawns subprocesses via child_process
out/scanner.js :60
`{file_path}` imports child_process and calls exec / spawn / execFile / fork. Subprocess execution lets the extension pivot from the VSCode host into the user's shell.
}
// Add output directory
const workspaceRoot = vscode.workspace.workspaceFolders?.[0].uri.fsPath || '.';
const outputDir = path.join(workspaceRoot, '.vscode', 'security-reports');
cliArgs.push('--output-dir', outputDir, '--format', 'json');
this.outputChannel.appendLine(`Running: ${cliPath} ${cliArgs.join(' ')}`);
// Track scanners
const scanners = ['Bandit', 'Semgrep', 'Trivy', 'Nuclei'];
let currentScanner = 0;
return new Promise((resolve, reject) => {
▶ const child = cp.spawn(cliPath, cliArgs, {
cwd: workspaceRoot,
shell: true
});
if (token) {
token.onCancellationRequested(() => {
child.kill();
reject(new Error('Scan cancelled'));
});
}
let stdout = ''; Affected versions
marketplace 1.0.0