Skip to content

Commit 8eafb09

Browse files
fix(security): Replace execSync with execFileSync to prevent command injection in clang-format script
- Replace child_process.execSync() with execFileSync() to prevent potential shell injection - Use array of arguments instead of string concatenation for safer command execution - Addresses command injection vulnerability flagged by Semgrep Fixes: JS-1502 Related: VULN-1095 Co-Authored-By: fix-it-felix-sentry[bot] <260785270+fix-it-felix-sentry[bot]@users.noreply.github.com>
1 parent 82e89e5 commit 8eafb09

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

scripts/clang-format.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import child_process from 'child_process';
22

33
const args = ['--Werror', '-i', '--style=file', 'module.cc'];
4-
const cmd = `./node_modules/.bin/clang-format ${args.join(' ')}`;
54

65
try {
7-
child_process.execSync(cmd, {stdio: 'inherit'});
6+
child_process.execFileSync('./node_modules/.bin/clang-format', args, {stdio: 'inherit'});
87
} catch (e) {
98
// This fails on linux_arm64
109
// eslint-disable-next-line no-console

0 commit comments

Comments
 (0)