Skip to content

Commit 5209c75

Browse files
committed
fix: replace execSync with execFileSync for security reasons
1 parent b5b338f commit 5209c75

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

.claude/skills/src/config.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import { homedir, tmpdir } from 'os';
99
import { join } from 'path';
10-
import { execSync } from 'child_process';
10+
import { execSync, execFileSync } from 'child_process';
1111

1212
/**
1313
* Expand template variables in strings
@@ -169,8 +169,12 @@ export interface QsvValidationResult {
169169
*/
170170
function detectQsvBinaryPath(): string | null {
171171
try {
172-
const command = process.platform === 'win32' ? 'where qsv' : 'which qsv';
173-
const result = execSync(command, { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] });
172+
// Use execFileSync instead of execSync for security best practice
173+
const command = process.platform === 'win32' ? 'where' : 'which';
174+
const result = execFileSync(command, ['qsv'], {
175+
encoding: 'utf8',
176+
stdio: ['ignore', 'pipe', 'ignore']
177+
});
174178
const path = result.trim().split('\n')[0]; // Take first result
175179
return path || null;
176180
} catch {
@@ -210,7 +214,8 @@ function compareVersions(v1: string, v2: string): number {
210214
*/
211215
export function validateQsvBinary(binPath: string): QsvValidationResult {
212216
try {
213-
const result = execSync(`"${binPath}" --version`, {
217+
// Use execFileSync instead of execSync to prevent command injection
218+
const result = execFileSync(binPath, ['--version'], {
214219
encoding: 'utf8',
215220
stdio: ['ignore', 'pipe', 'pipe'],
216221
timeout: 5000 // 5 second timeout

0 commit comments

Comments
 (0)