Skip to content

Commit

Permalink
Avoid shell injection in tests (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
s0 authored Sep 1, 2024
1 parent 3e95bf4 commit b2cfce1
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/test/integration/git.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
ROOT_TEST_BRANCH_PREFIX,
log,
} from "./env";
import { exec } from "child_process";
import { execFile } from "child_process";
import { getOctokit } from "@actions/github";
import { commitChangesFromRepo } from "../../git";
import { getRefTreeQuery } from "../../github/graphql/queries";
Expand Down Expand Up @@ -163,8 +163,9 @@ describe("git", () => {

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

// Clone the git repo locally usig the git cli and child-process
await new Promise<void>((resolve, reject) => {
const p = exec(
`git clone ${process.cwd()} repo-2`,
const p = execFile(
"git",
["clone", process.cwd(), "repo-2"],
{ cwd: testDir },
(error) => {
if (error) {
Expand Down

0 comments on commit b2cfce1

Please sign in to comment.