Skip to content

Commit

Permalink
Merge pull request #99 from snyk/fix/disable-shell-for-child-processes
Browse files Browse the repository at this point in the history
fix: disable shell for child processes
  • Loading branch information
danlucian authored Aug 17, 2022
2 parents 8fa65dc + 6cce106 commit d8dfc11
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions lib/sub-process.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import * as childProcess from 'child_process';

export function execute(command: string, args: string[], options?: { cwd?: string, env?: any }): Promise<string> {
const spawnOptions: childProcess.SpawnOptions = {shell: true};
export function execute(command: string,
args: string[],
options?: { cwd?: string, env?: any },
shell: boolean = false): Promise<string> {
const spawnOptions: childProcess.SpawnOptions = { shell };
if (options?.cwd) {
spawnOptions.cwd = options.cwd;
}
Expand Down
4 changes: 2 additions & 2 deletions test/with-symlink.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ test('with nested GOPATH/src/proj symlink-ing to ../..', async(t) => {
const cmd = `cd ${cwd} && ${exportEnvVarCmd} && ${execPluginCmd}`;
return subProcess.execute(
cmd,
[])
[], {}, true)
.then((result) => {
const resultJson = jsonParse(result);

Expand Down Expand Up @@ -143,7 +143,7 @@ test('package with broken symlink', async (t) => {
const cmd = `cd ${cwd} && ${exportEnvVarCmd} && ${execPluginCmd}`;
return subProcess.execute(
cmd,
[])
[], {}, true)
.then((result) => {
const resultJson = jsonParse(result);

Expand Down

0 comments on commit d8dfc11

Please sign in to comment.