Repository navigation
Conversation
There was a problem hiding this comment.
1 issue found across 3 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
The cubic review flagged that getRunnerPackageTargets put -p/--package in the blind skip list, so a package specified via 'npx -p <pkg>' had its value skipped and was never typosquat-checked. Move those flags out of RUNNER_FLAGS_WITH_VALUES and capture their values (including --package=foo) as package targets; with an explicit package flag the trailing positional is the binary to run, not a package. Non-package flags (-c, --registry, etc.) are still skipped. Adds tests for both cases.
|
Both open points here are stale, so a re-run should clear this. cubic's P2 on On Could someone re-run the checks? Happy to rebase onto current main first if that is easier. |
`npm install lodash@npm:lodahs` installs lodahs, but the version strip cut at the first @ and checked lodash. Read the target after @npm: instead.
Summary
The @continuedev/terminal-security package already recognizes package-manager install commands (npm/yarn/pnpm install/add) via isHighRiskPackageManager and routes them to allowedWithPermission, but it only answers 'is this an install?' not 'what is being installed?'. A command like
npm install lodahs(one edit away fromlodash) is treated identically to a legitimate install, with no typosquat signal for the reviewer.Changes
Extend evaluateTerminalCommandSecurity.ts to parse the target package name(s) out of recognized install/runner commands and compare each against a small bundled allowlist of popular packages using an edit-distance (Levenshtein <= 1-2, excluding exact matches) heuristic. Add npx/bunx/pnpm dlx/yarn dlx runner forms to the set of commands whose first non-flag argument is treated as a package target. When a near-miss is detected, attach a structured typosquat warning to the existing evaluation result (new optional field on the result type in types.ts) and ensure such commands stay at allowedWithPermission rather than silently auto-running, surfacing the suspected canonical name. Keep the allowlist and distance logic self-contained so it remains offline and dependency-free, matching the existing rule style in this file.
Fixes #12573
Summary by cubic
Add typosquat-target detection to
@continuedev/terminal-securitypackage-manager rule to flag suspicious install/runner targets and keep them permission-gated. Fixes #12573.npm|yarn|pnpm install/add/iand runnersnpx,bunx,pnpm dlx,yarn dlx; check-p/--package(incl.--package=foo) as package targets and ignore non-package runner flags.typosquat-targetwarnings withpackageName,suspectedPackageName, anddistance; any warning forces at leastallowedWithPermission.evaluateTerminalCommandSecurity(..., { includeWarnings: true })orevaluateTerminalCommandSecurityDetailed; tests cover exact hits, typos, scoped/versions, runners and-p/--packagecases, and negatives.Written for commit f2197a2. Summary will update on new commits.