You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
socket pnpm add / socket yarn add scan the alias name instead of the aliased package #1655
The shadow pnpm and yarn wrappers check packages with the Socket API before they install them. For an npm alias spec, the check looks up the alias name instead of the package that gets installed.
safeParseNpmSpec in src/utils/npm-spec.mts reads name and version from the npm-package-arg result. For an alias, npm-package-arg returns type: 'alias', sets name to the alias, and puts the real package in subSpec. The function has no branch for alias, so it returns the alias name with no version.
Command argument
PURL sent for scanning
Package installed
my-lodash@npm:lodash@4.17.21
pkg:npm/my-lodash
lodash@4.17.21
node-types@npm:@types/node@20.0.0
pkg:npm/node-types
@types/node@20.0.0
As a result, the installed package never gets checked. If an unrelated package has the alias name, its alerts are reported instead. socket yarn install has the same problem with aliased package.json dependencies such as "my-lodash": "npm:lodash@^4", because it builds name@version from each entry and passes the result to the same function.
Steps to reproduce
Run SOCKET_CLI_DEBUG=1 socket pnpm add my-lodash@npm:lodash@4.17.21.
safeParseNpmSpec doesn't handle npm-package-arg's alias type, so an alias gets scanned under its label, not the package that installs. For my-lodash@npm:lodash@4.17.21 the scan sees my-lodash instead of lodash. It now resolves the alias to its subSpec before building the purl, so add, dlx, and the package.json install path all scan the real package.
I can't open a PR (collaborators only), so it's on the branch above if it's useful.
Activity
shivanij1203 commentedon Nov 26, 2026
I pushed a fix for this, with tests: v1.x...shivanij1203:socket-cli:fix-alias-scanning
safeParseNpmSpecdoesn't handle npm-package-arg'saliastype, so an alias gets scanned under its label, not the package that installs. Formy-lodash@npm:lodash@4.17.21the scan seesmy-lodashinstead oflodash. It now resolves the alias to its subSpec before building the purl, so add, dlx, and the package.json install path all scan the real package.I can't open a PR (collaborators only), so it's on the branch above if it's useful.
jdalton commentedon Dec 2, 2026
Thanks for reporting this. I opened a PR with a possible fix.