Skip to content

Commit 68ce4e6

Browse files
committed
🔒️ use array argument to avoid injection
Issue: CLDSRV-860
1 parent b15c6e8 commit 68ce4e6

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

.github/scripts/check-diff-async.mjs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Usage: node scripts/check-diff-async.mjs
66
* In CI: runs against the current PR diff (files changed vs base branch)
77
*/
8-
import { execSync } from 'node:child_process';
8+
import { execFileSync } from 'node:child_process';
99
import { Project, SyntaxKind } from 'ts-morph';
1010

1111
const CALLBACK_PARAM_PATTERN = /^(cb|callback|next|done)$/i;
@@ -14,9 +14,14 @@ function getChangedJsFiles() {
1414
const base = process.env.GITHUB_BASE_REF
1515
? `origin/${process.env.GITHUB_BASE_REF}`
1616
: 'HEAD';
17-
const output = execSync(`git diff --name-only --diff-filter=ACMR ${base} -- '*.js'`, {
18-
encoding: 'utf8',
19-
}).trim();
17+
const output = execFileSync('git', [
18+
'diff',
19+
'--name-only',
20+
'--diff-filter=ACMR',
21+
base,
22+
'--',
23+
'*.js',
24+
], { encoding: 'utf8' }).trim();
2025

2126
return output ? output.split('\n').filter(f => f.endsWith('.js')) : [];
2227
}
@@ -28,7 +33,7 @@ function getAddedLineNumbers(filePath) {
2833
const base = process.env.GITHUB_BASE_REF
2934
? `origin/${process.env.GITHUB_BASE_REF}`
3035
: 'HEAD';
31-
const diff = execSync(`git diff ${base} -- ${filePath}`, { encoding: 'utf8' });
36+
const diff = execFileSync('git', ['diff', base, '--', filePath], { encoding: 'utf8' });
3237
const addedLines = new Set();
3338
let currentLine = 0;
3439

.github/scripts/count-async-functions.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ let totalFunctions = 0;
3434
let callbackFunctions = 0;
3535
let thenChains = 0;
3636

37-
const CALLBACK_PARAM_PATTERN = /^(cb|callback|next|done|err)$/i;
37+
const CALLBACK_PARAM_PATTERN = /^(cb|callback|next|done)$/i;
3838

3939
for (const sourceFile of project.getSourceFiles()) {
4040
const functions = [

0 commit comments

Comments
 (0)