Skip to content

Commit b2cfce1

Browse files
authored
Avoid shell injection in tests (#22)
1 parent 3e95bf4 commit b2cfce1

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Diff for: src/test/integration/git.test.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
ROOT_TEST_BRANCH_PREFIX,
88
log,
99
} from "./env";
10-
import { exec } from "child_process";
10+
import { execFile } from "child_process";
1111
import { getOctokit } from "@actions/github";
1212
import { commitChangesFromRepo } from "../../git";
1313
import { getRefTreeQuery } from "../../github/graphql/queries";
@@ -163,8 +163,9 @@ describe("git", () => {
163163

164164
// Clone the git repo locally using the git cli and child-process
165165
await new Promise<void>((resolve, reject) => {
166-
const p = exec(
167-
`git clone ${process.cwd()} repo-1`,
166+
const p = execFile(
167+
"git",
168+
["clone", process.cwd(), "repo-1"],
168169
{ cwd: testDir },
169170
(error) => {
170171
if (error) {
@@ -218,8 +219,9 @@ describe("git", () => {
218219

219220
// Clone the git repo locally usig the git cli and child-process
220221
await new Promise<void>((resolve, reject) => {
221-
const p = exec(
222-
`git clone ${process.cwd()} repo-2`,
222+
const p = execFile(
223+
"git",
224+
["clone", process.cwd(), "repo-2"],
223225
{ cwd: testDir },
224226
(error) => {
225227
if (error) {

0 commit comments

Comments
 (0)