Skip to content

Commit 9d74024

Browse files
Potential fix for code scanning alert no. 4: Unsafe shell command constructed from library input (#1037)
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent e4cec5b commit 9d74024

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

packages/publish-flat/src/PublishFlat.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {execSync} from 'node:child_process';
1+
import {execFileSync} from 'node:child_process';
22
import os from 'node:os';
33
import path from 'node:path';
44
import Arborist from '@npmcli/arborist';
@@ -100,11 +100,9 @@ export class PublishFlat {
100100
const executor = this.options.useYarn ? 'yarn' : 'npm';
101101
const args = ['publish', `"${tempDir}"`].concat(this.options.publishArguments || []);
102102

103-
const command = `${executor} ${args.join(' ')}`;
103+
this.logger.info(`Running "${executor} ${args.join(' ')}" ...`);
104104

105-
this.logger.info(`Running "${command}" ...`);
106-
107-
const stdout = execSync(command).toString().trim();
105+
const stdout = execFileSync(executor, args).toString().trim();
108106

109107
if (stdout) {
110108
this.logger.info(stdout);

0 commit comments

Comments
 (0)