Skip to content

Commit 5312aa7

Browse files
committed
fix(utils): quote shell arguments to prevent malicious injection
1 parent bbe113a commit 5312aa7

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

package-lock.json

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"parse-lcov": "^1.0.4",
3939
"rimraf": "^6.0.1",
4040
"semver": "^7.6.3",
41+
"shell-quote": "^1.8.3",
4142
"simple-git": "^3.26.0",
4243
"ts-morph": "^24.0.0",
4344
"tslib": "^2.6.2",
@@ -76,6 +77,7 @@
7677
"@types/node": "^22.13.4",
7778
"@types/react": "18.3.1",
7879
"@types/react-dom": "18.3.0",
80+
"@types/shell-quote": "^1.7.5",
7981
"@vitejs/plugin-react": "^5.0.0",
8082
"@vitest/coverage-v8": "1.3.1",
8183
"@vitest/eslint-plugin": "^1.1.38",

packages/utils/src/lib/execute-process.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
spawn,
77
} from 'node:child_process';
88
import type { Readable, Writable } from 'node:stream';
9+
import { quote } from 'shell-quote';
910
import { isVerbose } from './env.js';
1011
import { formatCommandLog } from './format-command-log.js';
1112
import { ui } from './logging.js';
@@ -157,8 +158,10 @@ export function executeProcess(cfg: ProcessConfig): Promise<ProcessResult> {
157158
);
158159
}
159160

161+
const bin = [command, quote(args ?? [])].join(' ');
162+
160163
return new Promise((resolve, reject) => {
161-
const spawnedProcess = spawn(command, args ?? [], {
164+
const spawnedProcess = spawn(bin, {
162165
windowsHide: true,
163166
...options,
164167
}) as ChildProcessByStdio<Writable, Readable, Readable>;

0 commit comments

Comments
 (0)