Skip to content

Commit

Permalink
Merge pull request #4527 from Shopify/revert-4401-improve-binary-run-…
Browse files Browse the repository at this point in the history
…safety

Revert "Improve binary run safety"
  • Loading branch information
MitchDickinson authored Sep 25, 2024
2 parents f0318f3 + b36935f commit 2f10595
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 27 deletions.
2 changes: 0 additions & 2 deletions packages/cli-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@
"tempy": "3.0.0",
"terminal-link": "3.0.0",
"ts-error": "1.0.6",
"which": "4.0.0",
"zod": "3.22.3"
},
"devDependencies": {
Expand All @@ -174,7 +173,6 @@
"@types/node": "18.19.3",
"@types/react": "18.2.0",
"@types/semver": "^7.5.2",
"@types/which": "3.0.4",
"@vitest/coverage-istanbul": "^1.6.0",
"node-stream-zip": "^1.15.0",
"ts-morph": "^17.0.1",
Expand Down
17 changes: 2 additions & 15 deletions packages/cli-kit/src/public/node/system.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import {AbortSignal} from './abort.js'
import {AbortError, ExternalError} from './error.js'
import {cwd, dirname} from './path.js'
import {ExternalError} from './error.js'
import {cwd} from './path.js'
import {treeKill} from './tree-kill.js'
import {isTruthy} from './context/utilities.js'
import {renderWarning} from './ui.js'
import {shouldDisplayColors, outputDebug} from '../../public/node/output.js'
import {execa, ExecaChildProcess} from 'execa'
import which from 'which'
import type {Writable, Readable} from 'stream'

export interface ExecOptions {
Expand Down Expand Up @@ -99,7 +97,6 @@ function buildExec(command: string, args: string[], options?: ExecOptions): Exec
if (shouldDisplayColors()) {
env.FORCE_COLOR = '1'
}
checkCommandSafety(command)
const commandProcess = execa(command, args, {
env,
cwd: options?.cwd,
Expand All @@ -120,16 +117,6 @@ Running system process:
return commandProcess
}

function checkCommandSafety(command: string) {
const commandDirectory = dirname(which.sync(command))
if (commandDirectory === cwd()) {
const headline = ['Skipped run of unsecure binary', {command}, 'found in the current directory.']
const body = 'Please remove that file or review your current PATH.'
renderWarning({headline, body})
throw new AbortError(headline, body)
}
}

/**
* Waits for a given number of seconds.
*
Expand Down
12 changes: 2 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2f10595

Please sign in to comment.