feat: Add typosquat-target detection to terminal-security package-manager rule
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 from lodash) 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-security package-manager rule to flag suspicious install/runner targets and keep them permission-gated. Fixes #12573.
- New Features
- Parse package targets from
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. - Detect near-miss names against a small bundled list of popular packages using bounded Levenshtein (<=2), skipping exact matches.
- Attach
typosquat-targetwarnings withpackageName,suspectedPackageName, anddistance; any warning forces at leastallowedWithPermission. - Optional warnings via
evaluateTerminalCommandSecurity(..., { includeWarnings: true })orevaluateTerminalCommandSecurityDetailed; tests cover exact hits, typos, scoped/versions, runners and-p/--packagecases, and negatives.
- Parse package targets from