Skip to content

Commit b9f92a1

Browse files
Potential fix for code scanning alert no. 22: Shell command built from environment values
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 32ed8ba commit b9f92a1

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

scripts/bundle.mjs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* Environment variables:
1717
* AGENTCORE_CDK_PATH — absolute path to the agentcore-l3-cdk-constructs repo
1818
*/
19-
import { execSync } from 'node:child_process';
19+
import { execFileSync } from 'node:child_process';
2020
import * as fs from 'node:fs';
2121
import * as path from 'node:path';
2222
import { fileURLToPath } from 'node:url';
@@ -31,9 +31,10 @@ function log(msg) {
3131
console.log(`\n[bundle] ${msg}`);
3232
}
3333

34-
function run(cmd, opts = {}) {
35-
console.log(` > ${cmd}`);
36-
execSync(cmd, { stdio: 'inherit', ...opts });
34+
function run(cmd, args = [], opts = {}) {
35+
const display = [cmd, ...args].join(' ');
36+
console.log(` > ${display}`);
37+
execFileSync(cmd, args, { stdio: 'inherit', ...opts });
3738
}
3839

3940
/**
@@ -66,9 +67,9 @@ function resolveCdkPath() {
6667

6768
if (fs.existsSync(cloneDir)) {
6869
log('Pulling latest changes...');
69-
run('git pull origin main', { cwd: cloneDir });
70+
run('git', ['pull', 'origin', 'main'], { cwd: cloneDir });
7071
} else {
71-
run(`git clone --depth 1 ${CDK_REPO_URL} ${cloneDir}`);
72+
run('git', ['clone', '--depth', '1', CDK_REPO_URL, cloneDir]);
7273
}
7374

7475
return cloneDir;

0 commit comments

Comments
 (0)