Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Improve binary run safety" #4527

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.