Skip to content

fix(security): contain lockfile & manifest package names/slots against path traversal (pnpm + pacquet) - #12872

Merged
zkochan merged 12 commits into
mainfrom
fix/contain-virtual-store-package-name
Jul 9, 2026
Merged

zkochan merged 12 commits into
mainfrom
fix/contain-virtual-store-package-name

Conversation

@zkochan

@zkochan zkochan commented Jul 9, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes three related path-traversal advisories where a crafted pnpm-lock.yaml or a malicious dependency's own manifest could make pnpm install / pacquet install write package content, symlinks, or bins outside node_modules / the virtual store — in some cases even with --ignore-scripts or --frozen-lockfile --trust-lockfile. All are the same class: a lockfile- or manifest-controlled package name/version is joined into a filesystem path without validation. Rejections surface ERR_PNPM_INVALID_DEPENDENCY_NAME.

Advisory Vector Stack
GHSA-c59q-g84q-2gj5 lockfile depPath name → isolated (virtual-store) linker + PnP resolver map TypeScript
GHSA-vq4v-j7r6-jq4m dependency manifest name (from the fetched tarball, e.g. @x/../../../path) → resolver/linker TypeScript + pacquet
GHSA-2rx9-3g3h-c2jv (CAND-PNPM-027) lockfile alias / snapshot key name, and global-virtual-store version segment pacquet

This consolidates what were three separate PRs into one, per the two-stacks-one-PR parity rule.

What's included

TypeScript

  • safeJoinModulesDir(modules, pkgName) at the isolated linker (deps/graph-builder/lockfileToDepGraph.ts) and the PnP packageLocation (lockfile/to-pnp), matching the guard GHSA-fr4h-3cph-29xv already added to the hoisted linker. (c59q-g84q-2gj5)
  • Manifest-name validation in the resolver: installing/deps-resolver (+ resolvePeers) and installing/env-installer (config deps). (vq4v-j7r6-jq4m)
  • New: global-virtual-store slot containment. The name guard covers the inner node_modules/<name> join but not the GVS slot dir itself, which formatGlobalVirtualStorePath builds from raw name and version. iteratePkgsForVirtualStore now contains each computed slot dir against its store root, so a valid name with a traversal version (e.g. a snapshot version: "../../x") is rejected too.

pacquet

  • verify_lockfile_dependency_names — an offline structural check over importer aliases, snapshot package names, and snapshot dependency aliases — run unconditionally in InstallFrozenLockfile::run before any materialization and before the warm-install skip filter, so trustLockfile (which disables the resolution-policy fan-out) can't bypass it. Plus validate_virtual_store_slot_containment for the GVS version-segment escape. (2rx9-3g3h-c2jv)
  • Sink-level safe_join_modules_dir guards on the manifest-name / fresh-install paths: create_symlink_layout, create_virtual_dir_by_snapshot, hoist, install_package_from_registry, and the resolver (resolve_dependency_tree). (vq4v-j7r6-jq4m)

The two pacquet strategies are complementary: the verifier rejects a poisoned lockfile up front (and covers the trustLockfile / snapshot-key / GVS-version cases), while the sink guards also catch manifest names and the fresh-resolve path that never touch the lockfile.

Reproduced end-to-end for the pacquet lockfile case: before, pacquet install --frozen-lockfile --trust-lockfile on a ../../escaped-link dependency created a symlink outside the project; after, it aborts with ERR_PNPM_INVALID_DEPENDENCY_NAME and writes nothing outside the project.

Squash Commit Body

Contain crafted-lockfile and malicious-manifest path traversal across both
stacks. Three advisories:

- GHSA-c59q-g84q-2gj5 (TS): lockfile depPath name -> isolated linker + PnP.
- GHSA-vq4v-j7r6-jq4m (TS + pacquet): dependency manifest `name` from the
  fetched tarball (e.g. @x/../../../path) -> resolver/linker.
- GHSA-2rx9-3g3h-c2jv (pacquet): lockfile alias / snapshot key name, and the
  global-virtual-store version segment; also bypassable under trustLockfile.

TS: apply safeJoinModulesDir at lockfileToDepGraph and the PnP
packageLocation; validate manifest names in deps-resolver / resolvePeers /
env-installer; contain the global-virtual-store slot dir against its store
root in iteratePkgsForVirtualStore so a traversal version segment is rejected.

pacquet: add verify_lockfile_dependency_names (offline check over importer
aliases, snapshot package names, and snapshot dependency aliases) run
unconditionally in InstallFrozenLockfile::run so trustLockfile cannot bypass
it; add validate_virtual_store_slot_containment for the GVS version escape;
guard the sink joins (create_symlink_layout, create_virtual_dir_by_snapshot,
hoist, install_package_from_registry) and the resolver with
safe_join_modules_dir.

All rejections surface ERR_PNPM_INVALID_DEPENDENCY_NAME.

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust pacquet/ port.
  • Added a changeset (@pnpm/deps.graph-builder, @pnpm/lockfile.to-pnp, @pnpm/installing.deps-resolver, @pnpm/installing.env-installer, pnpm). pacquet is Rust and not changeset-versioned.
  • Added or updated tests. TS: deps/graph-builder (7, incl. the GVS version-escape case), installing/deps-resolver (126), installing/env-installer (34), and the deps-installer fromTarball manifest-traversal e2e (4). pacquet: pacquet-package-manager (656) + pacquet-resolving-deps-resolver (167) + pacquet-lockfile-verification (47); cargo clippy --deny warnings + cargo fmt clean.
  • Updated the documentation if needed. (No user-facing docs change.)

Written by an agent (Claude Code, claude-opus-4-8).

Summary by CodeRabbit

  • Security Fixes
    • Hardened lockfile and installer name handling to reject crafted dependency names/aliases and prevent path traversal from escaping virtual-store and resolver mappings.
    • Added virtual-store containment validation (including global virtual-store) before filesystem materialization.
    • Ensured isolated linker and symlink/virtual-directory creation validate names before writing paths.
  • Tests
    • Added/extended regression tests covering traversal attempts, invalid alias/name rejection, and virtual-store slot containment.
  • Chores
    • Updated lint/test scripts, TypeScript project references, and unified safe-join handling across affected packages.

…th traversal

The isolated (virtual-store) linker and the Plug'n'Play resolver map both
reconstruct a package name from a lockfile `packages` depPath key via
`dp.parse`, which does no validation, and join it onto the virtual store to
form the package's install directory / PnP `packageLocation`. A crafted
`pnpm-lock.yaml` with a traversal name (e.g. `../../../tmp/[email protected]`) could
therefore make `pnpm install` import package content to an arbitrary path
outside the store.

This is the same class of issue as GHSA-fr4h-3cph-29xv, whose fix added the
`safeJoinModulesDir` containment helper to the hoisted linker and to
`symlinkDependency` but not to the virtual-store linker (the default) or the
PnP path. Apply the same guard at both remaining sinks
(`lockfileToDepGraph` and `lockfileToPackageRegistry`), so a name that isn't a
valid npm package name is rejected before any fetch or filesystem work.

Reported as GHSA-c59q-g84q-2gj5.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings July 9, 2026 09:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The PR adds traversal containment checks for lockfile-derived names and virtual-store paths across graph building, PnP mapping, Rust lockfile verification, and install-time package materialization. It also updates related tests, workspace wiring, diagnostics, and release notes.

Changes

Lockfile path containment

Layer / File(s) Summary
Changeset documentation
.changeset/contain-virtual-store-package-name.md, .changeset/isolated-linker-name-traversal.md
Updates the release notes for the affected packages and records the traversal containment fix.
graph-builder containment and tests
pnpm11/deps/graph-builder/src/lockfileToDepGraph.ts, pnpm11/deps/graph-builder/src/iteratePkgsForVirtualStore.ts, pnpm11/deps/graph-builder/test/lockfileToDepGraph.test.ts, pnpm11/deps/graph-builder/package.json, pnpm11/deps/graph-builder/tsconfig.json, pnpm11/deps/graph-builder/test/tsconfig.json
Replaces direct virtual-store path joins with containment checks, wires the new dependency and TypeScript references, and adds tests for rejected traversal-shaped names and global virtual-store slot escapes.
lockfile.to-pnp containment and tests
pnpm11/lockfile/to-pnp/src/index.ts, pnpm11/lockfile/to-pnp/test/index.ts, pnpm11/lockfile/to-pnp/package.json, pnpm11/lockfile/to-pnp/tsconfig.json
Replaces direct package-location joins with a safe join, adds the shared dependency and TypeScript references, and adds a rejection test for traversal-shaped dependency names in the registry map.
lockfile dependency-name verification
pacquet/crates/lockfile-verification/src/lib.rs, pacquet/crates/lockfile-verification/src/verify_lockfile_resolutions.rs, pacquet/crates/lockfile-verification/src/verify_lockfile_resolutions/tests.rs
Adds a public verifier for invalid dependency and alias names, moves that check ahead of resolution lookups, and extends tests for traversal aliases and packages-less lockfiles.
package-manager path validation
pacquet/crates/package-manager/src/lib.rs, pacquet/crates/package-manager/src/validate_lockfile_paths.rs, pacquet/crates/package-manager/src/install_frozen_lockfile.rs, pacquet/crates/package-manager/src/validate_lockfile_paths/tests.rs, pacquet/crates/package-manager/src/create_symlink_layout.rs, pacquet/crates/package-manager/src/create_symlink_layout/tests.rs, pacquet/crates/package-manager/src/create_virtual_dir_by_snapshot.rs, pacquet/crates/package-manager/src/hoist.rs, pacquet/crates/package-manager/src/install_package_from_registry.rs, pacquet/crates/package-manager/src/install_package_from_registry/tests.rs, pacquet/crates/package-manager/src/safe_join_modules_dir.rs, pacquet/crates/package-manager/src/symlink_package.rs, pacquet/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs
Adds shared safe-join helpers and error variants, replaces direct symlink and install path joins, validates virtual-store slot containment before frozen installs, and adds tests for traversal aliases and escaping slot paths.
installer path containment
pnpm11/installing/deps-resolver/src/index.ts, pnpm11/installing/deps-resolver/src/resolvePeers.ts, pnpm11/installing/deps-resolver/package.json, pnpm11/installing/deps-resolver/tsconfig.json, pnpm11/installing/env-installer/src/installConfigDeps.ts, pnpm11/installing/env-installer/package.json, pnpm11/installing/env-installer/tsconfig.json, pnpm11/installing/deps-installer/test/install/fromTarball.ts
Updates dependency resolver and env-installer path construction to use safe joins, changes the tarball install regression test, and updates the dependency-name diagnostic code for traversal rejections.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

  • pnpm/pnpm#11169: Both PRs harden CreateVirtualDirBySnapshot around lockfile-derived alias paths.
  • pnpm/pnpm#11954: Both PRs implement the same traversal-defense pattern with safe joins and dependency-alias rejection.
  • pnpm/pnpm#12144: Both PRs extend lockfile verification around invalid dependency names and alias handling.

Suggested labels: product: pnpm@11, product: pacquet

Suggested reviewers: qodo-code-review

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/contain-virtual-store-package-name

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

fix(security): prevent lockfile path traversal in virtual-store linker and PnP map

🐞 Bug fix 🧪 Tests 🕐 20-40 Minutes

Grey Divider

AI Description

• Contain reconstructed package names when deriving virtual-store install paths from lockfile
 depPaths.
• Contain reconstructed package names when generating PnP packageLocation entries.
• Add regression tests to reject traversal/reserved names before any fetch or filesystem writes.
Diagram

graph TD
  A["pnpm-lock.yaml depPath keys"] --> B["Parse depPath -> name"] --> C["Virtual-store: lockfileToDepGraph"] --> D{"safeJoinModulesDir validates/contains"} --> E[".pnpm/.../node_modules/<name>"]
  B --> F["PnP: lockfileToPackageRegistry"] --> D --> G[".pnp.cjs packageLocation"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Validate depPath-derived names earlier (dp.parse / snapshot parsing)
  • ➕ Fails fast at a single choke point before any downstream usage
  • ➕ Reduces reliance on sink-level correctness across the codebase
  • ➖ Broader behavior change risk (dp.parse used widely)
  • ➖ Still may need sink-level containment as defense-in-depth
2. Lockfile integrity validation pass before graph/PnP generation
  • ➕ Centralized lockfile hardening; can report all invalid entries at once
  • ➕ Can enforce additional invariants beyond name validation
  • ➖ Extra complexity and runtime cost on install
  • ➖ Still needs sink-level guard to prevent future regressions
3. Containment-only check without npm-name validation (path.resolve prefix check)
  • ➕ Minimal dependency on name rules; focuses purely on filesystem escape
  • ➕ Potentially fewer false-positives for unusual-but-valid names
  • ➖ Does not block reserved pnpm layout names (e.g. .pnpm/.bin/node_modules) unless explicitly handled
  • ➖ Harder to keep consistent with npm ecosystem expectations

Recommendation: Current approach (reusing safeJoinModulesDir at both remaining sinks) is the best fit: it matches the prior hoisted-linker fix, provides defense-in-depth, and rejects traversal/reserved names before any fetch/filesystem work. Consider (separately) adding an earlier lockfile/depPath validation layer for even faster failure, but keep the sink-level guard regardless.

Files changed (11) +179 / -10

Bug fix (2) +15 / -6
lockfileToDepGraph.tsContain lockfile-derived package directory joins in virtual-store linker +6/-1

Contain lockfile-derived package directory joins in virtual-store linker

• Routes 'modulesDir + pkgName' construction through 'safeJoinModulesDir' to prevent path traversal/reserved names from escaping the virtual store when the name is reconstructed from lockfile depPath keys.

pnpm11/deps/graph-builder/src/lockfileToDepGraph.ts

index.tsContain lockfile-derived PnP packageLocation joins +9/-5

Contain lockfile-derived PnP packageLocation joins

• Constructs the per-package 'node_modules' directory and then uses 'safeJoinModulesDir' to join the lockfile-derived package name, preventing '.pnp.cjs' entries from pointing outside the virtual store.

pnpm11/lockfile/to-pnp/src/index.ts

Tests (2) +117 / -1
lockfileToDepGraph.test.tsAdd regression tests for traversal/reserved depPath names in lockfileToDepGraph +85/-0

Add regression tests for traversal/reserved depPath names in lockfileToDepGraph

• Adds Jest tests that feed crafted lockfiles containing traversal/reserved names and asserts 'ERR_PNPM_INVALID_DEPENDENCY_NAME' is thrown. Verifies no directory gets created outside the virtual store and that store controller methods are never reached.

pnpm11/deps/graph-builder/test/lockfileToDepGraph.test.ts

index.tsAdd regression test for traversal depPath names in PnP registry generation +32/-1

Add regression test for traversal depPath names in PnP registry generation

• Adds a test that supplies a crafted lockfile whose 'packages' depPath key encodes traversal and asserts 'lockfileToPackageRegistry' throws 'ERR_PNPM_INVALID_DEPENDENCY_NAME'.

pnpm11/lockfile/to-pnp/test/index.ts

Documentation (1) +7 / -0
contain-virtual-store-package-name.mdAdd changeset for lockfile name containment security fix +7/-0

Add changeset for lockfile name containment security fix

• Introduces a patch changeset for affected packages. Release note explains rejection of lockfile-crafted traversal names in the virtual-store linker and PnP resolver map.

.changeset/contain-virtual-store-package-name.md

Other (6) +40 / -3
pnpm-lock.yamlUpdate workspace lockfile for new dev/test dependencies +9/-0

Update workspace lockfile for new dev/test dependencies

• Updates the lockfile to include new workspace links and Jest globals used by newly added tests and dependencies.

pnpm-lock.yaml

package.jsonEnable Jest tests for deps.graph-builder and add symlink-dependency dependency +6/-3

Enable Jest tests for deps.graph-builder and add symlink-dependency dependency

• Extends linting to include tests, wires a Jest-based test script, and adds required dependencies/devDependencies for the new security regression tests.

pnpm11/deps/graph-builder/package.json

tsconfig.jsonAdd test tsconfig for deps.graph-builder Jest suite +18/-0

Add test tsconfig for deps.graph-builder Jest suite

• Adds a dedicated TypeScript configuration for compiling/running the new graph-builder test suite, including repository typings.

pnpm11/deps/graph-builder/test/tsconfig.json

tsconfig.jsonAdd project reference to fs/symlink-dependency +3/-0

Add project reference to fs/symlink-dependency

• Adds a TypeScript project reference so graph-builder can import 'safeJoinModulesDir' from '@pnpm/fs.symlink-dependency'.

pnpm11/deps/graph-builder/tsconfig.json

package.jsonAdd symlink-dependency dependency to lockfile.to-pnp +1/-0

Add symlink-dependency dependency to lockfile.to-pnp

• Adds '@pnpm/fs.symlink-dependency' so PnP registry generation can reuse the shared containment helper.

pnpm11/lockfile/to-pnp/package.json

tsconfig.jsonAdd project reference to fs/symlink-dependency for lockfile.to-pnp +3/-0

Add project reference to fs/symlink-dependency for lockfile.to-pnp

• Updates TypeScript references so 'lockfile.to-pnp' can import the containment helper without build ordering issues.

pnpm11/lockfile/to-pnp/tsconfig.json

@qodo-code-review

qodo-code-review Bot commented Jul 9, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (8) 📘 Rule violations (2) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 51 rules

Grey Divider


Action required

1. Fresh install hides pnpm error ✓ Resolved 📘 Rule violation ≡ Correctness
Description
The new CLI test explicitly avoids asserting ERR_PNPM_INVALID_DEPENDENCY_NAME because the
fresh-install path wraps it in an outer resolve_importer diagnostic, which likely surfaces a
non‑pnpm error code to users. This violates the requirement that pacquet error codes/messages align
with pnpm for pnpm-documented error conditions.
Code

pacquet/crates/cli/tests/install.rs[R81-90]

+    // The fresh-resolve path wraps the resolver's
+    // `ERR_PNPM_INVALID_DEPENDENCY_NAME` in an outer `resolve_importer`
+    // diagnostic, so the rendered envelope carries the wrapper's code
+    // rather than the canonical one (the frozen path surfaces the
+    // canonical code — see `lockfile_verification.rs`). Assert on the
+    // stable rejection message and the offending name instead.
+    let stderr = String::from_utf8_lossy(&output.stderr).into_owned();
+    assert!(
+        stderr.contains("../../escaped-link") && stderr.contains("invalid name"),
+        "stderr must report the rejected traversal dependency name; got:\n{stderr}",
Evidence
Rule 713473 requires pacquet to emit pnpm’s canonical error codes/messages for pnpm-documented
errors. The new test documents that the fresh-install path wraps ERR_PNPM_INVALID_DEPENDENCY_NAME
such that the outer diagnostic’s code is surfaced instead, and the package-manager fresh-install
error wrapper is explicitly tagged with pacquet_package_manager::resolve_importer rather than
ERR_PNPM_INVALID_DEPENDENCY_NAME.

Rule 713473: Align pacquet error codes and messages with pnpm
pacquet/crates/cli/tests/install.rs[81-90]
pacquet/crates/package-manager/src/install_with_fresh_lockfile.rs[264-275]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The fresh-install `pacquet install` path wraps the resolver’s `ERR_PNPM_INVALID_DEPENDENCY_NAME` in an outer diagnostic (`pacquet_package_manager::resolve_importer`), so users (and tests) don’t reliably see the canonical pnpm error code for this pnpm-documented error condition.

## Issue Context
Compliance requires pacquet to match pnpm’s documented error codes/messages for equivalent failure modes. The new test currently works around this by asserting only on a substring (`invalid name`) instead of the pnpm error code.

## Fix Focus Areas
- pacquet/crates/package-manager/src/install_with_fresh_lockfile.rs[264-275]
- pacquet/crates/cli/tests/install.rs[81-90]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. GVS slot escape remains ✓ Resolved 🐞 Bug ⛨ Security
Description
In deps-resolver extendGraph() and env-installer installOptionalSubdeps(), safeJoinModulesDir() only
protects the final node_modules/<name> join, but the enclosing global-virtual-store “slot” path is
built from opts.globalVirtualStoreDir plus a hash/relpath that embeds the raw lockfile-controlled
version segment, allowing traversal/absolute values like "../../.." to escape the store root
before the name guard runs. The resulting escaped directory is later passed into
storeController.importPackage()/store.importPackage(), enabling writes outside the intended
store directory.
Code

pnpm11/installing/deps-resolver/src/index.ts[615]

+      dir: safeJoinModulesDir(modules, node.name),
Evidence
The global virtual store path helpers/formatters (e.g., formatGlobalVirtualStorePath(...) and the
leaf helper used by calcLeafGlobalVirtualStorePath(...)) insert version as an unvalidated, raw
/-separated path component, so a crafted lockfile version can introduce traversal or absolute
segments that influence the computed slot path. deps-resolver’s extendGraph() (and env-installer’s
optional subdep flow) then joins this slot path onto opts.globalVirtualStoreDir to form the
modules/slot directory and only applies safeJoinModulesDir() to the inner node_modules/<name>
join, which is too late because the outer slot can already have escaped; that escaped dir is
subsequently used as the destination for importPackage, turning the store-escape into a write
primitive outside the configured global virtual store.

pnpm11/deps/graph-hasher/src/index.ts[252-286]
pnpm11/installing/deps-resolver/src/index.ts[590-616]
pnpm11/installing/deps-installer/src/install/link.ts[538-545]
pnpm11/installing/env-installer/src/installConfigDeps.ts[293-321]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`safeJoinModulesDir()` currently guards only the final `node_modules/<name>` join, but does not prevent the enclosing global-virtual-store “slot” path (built as `opts.globalVirtualStoreDir + hash/relpath`) from escaping the store root when that hash/relpath embeds a lockfile-controlled `version` as a raw path segment. This allows traversal/absolute version strings to resolve outside `opts.globalVirtualStoreDir` and then be passed to `storeController.importPackage()`/`store.importPackage()`, enabling writes outside the intended store directory.

## Issue Context
- `formatGlobalVirtualStorePath(name, version, hexDigest)` (and the same raw version-segment formatter used by `calcLeafGlobalVirtualStorePath(...)`) inserts `version` as an unvalidated path component.
- In deps-resolver `extendGraph()`, this formatted slot path is joined onto `opts.globalVirtualStoreDir` to build `modules` before calling `safeJoinModulesDir(modules, node.name)`.
- In env-installer `installOptionalSubdeps()`, `subdepRelPath` from `calcLeafGlobalVirtualStorePath(...)` is joined onto `opts.globalVirtualStoreDir` and later used (after an inner `safeJoinModulesDir`-style join) as the destination for `store.importPackage()`.
- Because the slot path itself can escape, guarding only `node_modules/<name>` is insufficient; the slot directory must be validated for lexical containment under `opts.globalVirtualStoreDir` before it is used.

## Fix Focus Areas
- pnpm11/installing/deps-resolver/src/index.ts[590-618]
- pnpm11/installing/env-installer/src/installConfigDeps.ts[293-321]
- pnpm11/deps/graph-hasher/src/index.ts[252-286]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. graphOpts() before first use ✗ Dismissed 📘 Rule violation ⚙ Maintainability
Description
In lockfileToDepGraph.test.ts, the top-level function declarations craftedLockfile() and
graphOpts() appear before any usage in the file. This violates the rule requiring TypeScript
function declarations to be declared only after their first usage.
Code

pnpm11/deps/graph-builder/test/lockfileToDepGraph.test.ts[R37-63]

+function graphOpts (lockfileDir: string): LockfileToDepGraphOptions {
+  const unreachable = (name: string) => () => {
+    throw new Error(`${name} must not be reached for a rejected package name`)
+  }
+  return {
+    autoInstallPeers: false,
+    engineStrict: false,
+    force: true,
+    importerIds: ['.'],
+    include: { dependencies: true, devDependencies: true, optionalDependencies: true },
+    ignoreScripts: false,
+    lockfileDir,
+    nodeVersion: process.version,
+    pnpmVersion: '0.0.0',
+    registries: { default: 'http://localhost/' },
+    sideEffectsCacheRead: false,
+    skipped: new Set(),
+    storeController: {
+      fetchPackage: unreachable('fetchPackage'),
+      getFilesIndexFilePath: unreachable('getFilesIndexFilePath'),
+    },
+    storeDir: path.join(lockfileDir, 'store'),
+    globalVirtualStoreDir: path.join(lockfileDir, 'store', 'v10'),
+    virtualStoreDir: path.join(lockfileDir, 'node_modules', '.pnpm'),
+    virtualStoreDirMaxLength: 120,
+  } as unknown as LockfileToDepGraphOptions
+}
Evidence
PR Compliance ID 713432 requires that top-level TypeScript function foo() {} declarations appear
only after their first usage in the same file. In lockfileToDepGraph.test.ts,
craftedLockfile(...) is declared at lines 17-32 and graphOpts(...) is declared at lines 37-63,
and both are first used later in the tests, meaning there is no usage before their declarations and
thus they violate the rule as written.

Rule 713432: Declare TypeScript functions only after their first usage
pnpm11/deps/graph-builder/test/lockfileToDepGraph.test.ts[37-63]
pnpm11/deps/graph-builder/test/lockfileToDepGraph.test.ts[17-32]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The top-level function declarations `craftedLockfile()` and `graphOpts()` are declared before their first usage in the same TypeScript file, violating the project rule that requires top-level `function foo() {}` declarations to appear only after their first usage.

## Issue Context
This rule applies to TypeScript `function foo() {}` declarations; function expressions/arrow functions are explicitly out of scope.

## Fix Focus Areas
- pnpm11/deps/graph-builder/test/lockfileToDepGraph.test.ts[17-32]
- pnpm11/deps/graph-builder/test/lockfileToDepGraph.test.ts[37-63]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (1)
4. path.join missing trailing comma ✗ Dismissed 📘 Rule violation ⚙ Maintainability
Description
A multi-line path.join(...) argument list ends without a trailing comma on the last argument. This
violates the trailing-comma requirement for TypeScript multi-line constructs and increases diff
churn.
Code

pnpm11/lockfile/to-pnp/src/index.ts[R109-114]

+    const pkgModulesDir = path.join(
      opts.virtualStoreDir,
      depPathToFilename(relDepPath, opts.virtualStoreDirMaxLength),
-      'node_modules',
-      name
-    )))
+      'node_modules'
+    )
+    let packageLocation = normalizePath(path.relative(opts.lockfileDir, safeJoinModulesDir(pkgModulesDir, name)))
Evidence
PR Compliance ID 713434 requires trailing commas in TypeScript multi-line constructs where items are
on their own lines. In pnpm11/lockfile/to-pnp/src/index.ts, the multi-line path.join( call ends
with 'node_modules' without a trailing comma.

Rule 713434: Require trailing commas in TypeScript collections and multi-line constructs
pnpm11/lockfile/to-pnp/src/index.ts[109-114]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The multi-line `path.join(...)` call is missing a trailing comma after the last argument, violating the project's TypeScript trailing-comma rule.

## Issue Context
The call spans multiple lines with one argument per line; the final argument should end with a comma where syntactically allowed.

## Fix Focus Areas
- pnpm11/lockfile/to-pnp/src/index.ts[109-114]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

5. Unconditional slot scan 🐞 Bug ➹ Performance ⭐ New
Description
InstallFrozenLockfile now always runs validate_virtual_store_slot_containment(), but that check only
adds security value in global-virtual-store mode; in legacy mode, slot_dir() uses an escaped flat
name so scanning every snapshot is redundant work on a hot install path.
Code

pacquet/crates/package-manager/src/install_frozen_lockfile.rs[R885-896]

+        // Reject a lockfile whose dependency names, aliases, or
+        // virtual-store slots would escape the project or the store once
+        // joined into a filesystem path. Runs before any materialization
+        // and before the warm-install skip filter, and unconditionally —
+        // so it is not bypassed by `trustLockfile`, which disables the
+        // resolution-verification fan-out where the offline name check
+        // would otherwise run. The slot-containment half needs the
+        // install-time `layout`, so it can't live in the verifier crate.
+        pacquet_lockfile_verification::verify_lockfile_dependency_names(lockfile)
+            .map_err(InstallFrozenLockfileError::LockfileVerification)?;
+        crate::validate_virtual_store_slot_containment(snapshots, &layout)
+            .map_err(InstallFrozenLockfileError::LockfileVerification)?;
Evidence
The frozen install path calls the containment scan unconditionally, and the scan walks every
snapshot key and checks is_subdir(package_store_dir, slot_dir(key)). In legacy mode the slot
suffix is produced by to_virtual_store_name(), which replaces path separators like / and \\
before joining, so the scan cannot catch anything additional and only adds extra per-snapshot work.

pacquet/crates/package-manager/src/install_frozen_lockfile.rs[885-896]
pacquet/crates/package-manager/src/validate_lockfile_paths.rs[29-49]
pacquet/crates/lockfile/src/pkg_name_ver_peer.rs[26-38]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`validate_virtual_store_slot_containment()` is invoked unconditionally during frozen installs, but its purpose (preventing a traversal in the *version-derived* path component) only applies when the global virtual store layout is enabled. When GVS is disabled, `slot_dir()` derives a flat directory name via `to_virtual_store_name()` that replaces path separators and other reserved characters, so the containment scan is effectively guaranteed to pass and adds avoidable O(n) work.

### Issue Context
- Frozen installs always call `crate::validate_virtual_store_slot_containment(snapshots, &layout)`.
- The validator loops every snapshot and calls `layout.slot_dir(key)` + `is_subdir(...)`.
- In legacy mode, `to_virtual_store_name()` replaces `/` and `\\` (and others) with `+`, preventing traversal components from being present in the suffix.

### Fix Focus Areas
- pacquet/crates/package-manager/src/install_frozen_lockfile.rs[885-896]
- pacquet/crates/package-manager/src/validate_lockfile_paths.rs[29-49]
- pacquet/crates/lockfile/src/pkg_name_ver_peer.rs[26-38]

### Suggested fix
Add a fast-path guard so the containment scan runs only when `layout.enable_global_virtual_store()` (or `config.enable_global_virtual_store`) is true, e.g.:
- in `install_frozen_lockfile.rs`, wrap the call in `if layout.enable_global_virtual_store() { ... }`.
- or inside `validate_virtual_store_slot_containment()`, early-return `Ok(())` when `!layout.enable_global_virtual_store()`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


6. Test doesn’t assert pnpm message 📘 Rule violation ≡ Correctness
Description
The new CLI test only asserts stderr contains ERR_PNPM_INVALID_DEPENDENCY_NAME and the substring
invalid name, rather than validating the pnpm-compatible primary message text. This weakens
enforcement of the required pnpm/pacquet message alignment for this error.
Code

pacquet/crates/cli/tests/install.rs[R81-91]

+    // The fresh-resolve path forwards the resolver's diagnostic
+    // transparently, so the rendered envelope carries the canonical
+    // `ERR_PNPM_INVALID_DEPENDENCY_NAME` code — matching the frozen path
+    // (see `lockfile_verification.rs`). The offending name is in the
+    // message too, but miette may wrap it across lines at narrow widths,
+    // so assert on the stable code and the unwrapped "invalid name"
+    // phrase instead.
+    let stderr = String::from_utf8_lossy(&output.stderr).into_owned();
+    assert!(
+        stderr.contains("ERR_PNPM_INVALID_DEPENDENCY_NAME") && stderr.contains("invalid name"),
+        "stderr must report the invalid-dependency-name code; got:\n{stderr}",
Evidence
Rule 713473 explicitly requires message alignment and states tests that assert on errors should
ensure expected codes/messages align with pnpm documentation. The added test asserts only a generic
substring (invalid name) rather than the pnpm-compatible message text for the same error
condition.

Rule 713473: Align pacquet error codes and messages with pnpm
pacquet/crates/cli/tests/install.rs[81-91]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The CLI regression test verifies the error code but does not strongly verify message alignment with pnpm, only checking a loose substring.

## Issue Context
Compliance requires pacquet error messages for pnpm-documented error codes to match pnpm’s canonical message text (allowing only non-semantic differences). The test should normalize wrapping/whitespace and then assert the expected pnpm-compatible message structure.

## Fix Focus Areas
- pacquet/crates/cli/tests/install.rs[81-91]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


7. Dangling escape not detected 🐞 Bug ⛨ Security
Description
The new path-traversal regression tests use Path::exists() to assert that no escaped path was
created, but exists() follows symlinks and returns false for dangling symlinks/junctions. This can
let a regression that creates an escaped dangling link outside the project/store pass CI, weakening
the security regression coverage.
Code

pacquet/crates/cli/tests/install.rs[R92-95]

+    assert!(
+        !workspace.parent().is_some_and(|parent| parent.join("escaped-link").exists()),
+        "no link may be created outside the project",
+    );
Evidence
The new tests assert non-existence of an escaped path using .exists(). Elsewhere in the same test
module, the code explicitly documents that exists() follows symlinks and can miss dangling
symlinks, recommending symlink_metadata instead—showing the current assertions are insufficient
for detecting escaped dangling links.

pacquet/crates/cli/tests/install.rs[92-95]
pacquet/crates/cli/tests/lockfile_verification.rs[298-305]
pacquet/crates/package-manager/src/hoist/tests.rs[443-444]
pacquet/crates/package-manager/src/hoist/tests.rs[382-385]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The new traversal-regression tests check for an escaped path using `Path::exists()`, which follows symlinks and can return `false` for a dangling symlink/junction. That means the test can miss the creation of an escaped link object.

### Issue Context
These tests are meant to guarantee that no filesystem entry (including dangling symlinks/junctions) is created outside the project/store when rejecting invalid dependency names.

### Fix Focus Areas
- pacquet/crates/cli/tests/install.rs[92-95]
- pacquet/crates/cli/tests/lockfile_verification.rs[298-305]
- pacquet/crates/package-manager/src/hoist/tests.rs[439-444]

### Suggested fix
Replace `...exists()` checks with `std::fs::symlink_metadata(path).is_err()` (or reuse `is_symlink_or_junction` + an existence check) so dangling links are detected too. For example:

```rust
if let Some(parent) = workspace.parent() {
 assert!(std::fs::symlink_metadata(parent.join("escaped-link")).is_err());
}
```

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (3)
8. Traversal check allocates split 🐞 Bug ➹ Performance
Description
assertNoPathTraversal() uses version.split(/[/\\]/).includes('..'), allocating an array on every
global-virtual-store path computation and adding avoidable overhead when hashing many packages. This
is on a hot path because every global virtual store slot path funnels through
formatGlobalVirtualStorePath().
Code

pnpm11/deps/graph-hasher/src/index.ts[R296-301]

+function assertNoPathTraversal (version: string): void {
+  if (version.split(/[/\\]/).includes('..')) {
+    const error = new Error(`Refusing to build a virtual-store path with the traversal version segment ${JSON.stringify(version)}`) as Error & { code: string }
+    error.code = 'ERR_PNPM_INVALID_DEPENDENCY_NAME'
+    throw error
+  }
Evidence
The new guard runs unconditionally for each GVS slot path: formatGlobalVirtualStorePath() calls
assertNoPathTraversal(version), and multiple exported helpers return
formatGlobalVirtualStorePath(...), so the split allocation occurs on every slot path computation.

pnpm11/deps/graph-hasher/src/index.ts[252-303]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`assertNoPathTraversal()` currently checks for `..` segments via `version.split(/[/\\]/).includes('..')`, which allocates on every call. This is unnecessary overhead in a function used for every global-virtual-store slot path computation.

## Issue Context
`formatGlobalVirtualStorePath()` is a single choke point for GVS slot path generation and now calls `assertNoPathTraversal(version)` for each computed slot.

## Fix Focus Areas
- pnpm11/deps/graph-hasher/src/index.ts[284-301]

Suggested change: replace the `split().includes()` with an allocation-free check such as:
- a cheap precheck `if (!version.includes('..')) return`
- then a regex boundary test like `/(^|[\/\\])\.\.([\/\\]|$)/.test(version)`
so the common case avoids array creation.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


9. Pacquet invalid-name message diverges 📘 Rule violation ⌂ Architecture
Description
Pacquet’s InvalidDependencyName error message includes additional guidance text inline, while pnpm
TypeScript surfaces that guidance as a separate hint. This creates an undocumented user-visible
behavior divergence between pnpm and pacquet for the same error code.
Code

pacquet/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs[R216-222]

    /// A dependency alias contained a path-separator segment that would
    /// escape the intended `node_modules` directory when joined onto a
-    /// modules path, raised with the `INVALID_DEPENDENCY_NAME` code.
+    /// modules path, raised with the `ERR_PNPM_INVALID_DEPENDENCY_NAME` code.
    #[display(
        "{parent} contains a dependency with an invalid name: {alias:?}. Dependency names must be a single package name or \"@scope/name\" — they cannot contain path-separator segments such as \"..\"."
    )]
-    #[diagnostic(code(INVALID_DEPENDENCY_NAME))]
+    #[diagnostic(code(ERR_PNPM_INVALID_DEPENDENCY_NAME))]
Evidence
The pacquet error message for InvalidDependencyName includes an extra explanatory sentence in the
#[display(...)] string, while pnpm TypeScript throws INVALID_DEPENDENCY_NAME with the guidance
in a separate hint field. This violates the sync requirement for user-visible error
text/structure.

Rule 713428: Keep pnpm TypeScript and pacquet Rust user-visible behavior changes in sync
pacquet/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs[216-227]
pnpm11/installing/deps-resolver/src/validateDependencyAlias.ts[22-28]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Pacquet’s `ResolveDependencyTreeError::InvalidDependencyName` currently embeds additional guidance text directly in the displayed error message, diverging from pnpm TypeScript’s user-visible structure (message + separate hint).

## Issue Context
Compliance requires pnpm TypeScript and pacquet Rust user-visible behavior changes (including error message structure) to remain in sync unless explicitly called out.

## Fix Focus Areas
- pacquet/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs[216-227]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


10. Unneeded symlink-dir load 🐞 Bug ➹ Performance
Description
lockfileToDepGraph and lockfileToPackageRegistry now import safeJoinModulesDir from the
@pnpm/fs.symlink-dependency package root, which executes that package’s entrypoint and eagerly
loads symlink-dir at module init. This adds avoidable startup/dependency weight on hot install /
PnP generation paths even though only the standalone helper is required.
Code

pnpm11/deps/graph-builder/src/lockfileToDepGraph.ts[10]

+import { safeJoinModulesDir } from '@pnpm/fs.symlink-dependency'
Evidence
The changed packages now import @pnpm/fs.symlink-dependency. That package’s root entrypoint
imports symlink-dir at top-level, so any import from the root will load it even when only
safeJoinModulesDir is used; additionally, the package export map currently exposes only . which
prevents a narrower helper-only import.

pnpm11/deps/graph-builder/src/lockfileToDepGraph.ts[1-12]
pnpm11/lockfile/to-pnp/src/index.ts[1-10]
pnpm11/fs/symlink-dependency/src/index.ts[1-6]
pnpm11/fs/symlink-dependency/package.json[16-21]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`safeJoinModulesDir` is currently consumed via `@pnpm/fs.symlink-dependency`’s main entrypoint, which has top-level imports of `symlink-dir` and loggers. This means code paths that only need name validation/containment still pay the cost of loading symlink functionality.

## Issue Context
This PR added new imports in the virtual-store graph builder and the lockfile-to-pnp generator, both of which are on common install/generation paths.

## Fix Focus Areas
- pnpm11/fs/symlink-dependency/package.json[16-21]
- pnpm11/fs/symlink-dependency/src/index.ts[1-8]
- pnpm11/deps/graph-builder/src/lockfileToDepGraph.ts[1-12]
- pnpm11/lockfile/to-pnp/src/index.ts[1-10]

## Suggested fix
1) Add a subpath export for the helper (e.g. `"./safeJoinModulesDir": "./lib/safeJoinModulesDir.js"`) so consumers can import it without evaluating the package root.
2) Update the new call sites to import from the subpath export.
3) (Optional alternative) Refactor `@pnpm/fs.symlink-dependency` so `symlink-dir` is only loaded when calling symlink functions (not at module initialization), but the subpath export is the simplest and most explicit solution.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational

11. Alias check allocates strings 🐞 Bug ➹ Performance ⭐ New
Description
The new verify_lockfile_dependency_names path validates aliases by calling alias.to_string()
before checking is_valid_old_npm_package_name, which allocates a new String for every alias even
when valid; on large lockfiles this adds avoidable allocation churn to install-time validation.
Code

pacquet/crates/lockfile-verification/src/verify_lockfile_resolutions.rs[R332-385]

+/// Collect every lockfile-controlled dependency name that isn't a valid
+/// npm package name. Three sources, each of which becomes a
+/// `node_modules/<name>` path component at install time:
+///
+/// - every importer's direct-dependency aliases,
+/// - every snapshot's own package name (the `snapshots:` map key), and
+/// - every snapshot's `dependencies` / `optionalDependencies` aliases.
+///
+/// A name carrying a `..` traversal, a `/`, or a reserved value such as
+/// `node_modules` / `.bin` / `.pnpm` could make an install write outside
+/// the intended directory or overwrite pnpm-owned layout.
+fn collect_invalid_dependency_names(lockfile: &Lockfile) -> std::collections::BTreeSet<String> {
+    let mut invalid = std::collections::BTreeSet::new();
+    for importer in lockfile.importers.values() {
+        for deps in
+            [&importer.dependencies, &importer.dev_dependencies, &importer.optional_dependencies]
+        {
+            push_invalid_aliases(deps.iter().flatten().map(|(alias, _)| alias), &mut invalid);
+        }
+    }
+    if let Some(snapshots) = lockfile.snapshots.as_ref() {
+        for (key, snapshot) in snapshots {
+            push_invalid_aliases(std::iter::once(&key.name), &mut invalid);
+            for deps in [&snapshot.dependencies, &snapshot.optional_dependencies] {
+                push_invalid_aliases(deps.iter().flatten().map(|(alias, _)| alias), &mut invalid);
+            }
+        }
+    }
+    invalid
+}
+
+/// Reject a lockfile whose dependency names or aliases are not valid npm
+/// package names.
+///
+/// This is an offline, network-free structural check — it does **not**
+/// depend on the resolution-policy verifiers, so it must run on every
+/// install, **including under `trustLockfile`**, which disables the
+/// policy fan-out. A crafted lockfile alias becomes a filesystem path
+/// (`node_modules/<alias>`, a virtual-store slot's inner
+/// `node_modules/<name>`, a bin, a hoisted link), and pacquet's
+/// [`PkgName`] parser does not validate against npm's package-name
+/// rules, so an unchecked `..`/`/`-bearing name escapes the intended
+/// directory.
+///
+/// Surfaces [`VerifyError::InvalidDependencyAlias`]
+/// (`ERR_PNPM_INVALID_DEPENDENCY_NAME`) listing every offender.
+pub fn verify_lockfile_dependency_names(lockfile: &Lockfile) -> Result<(), VerifyError> {
+    let invalid = collect_invalid_dependency_names(lockfile);
+    if invalid.is_empty() {
+        return Ok(());
+    }
+    let invalid: Vec<String> = invalid.into_iter().collect();
+    Err(VerifyError::invalid_dependency_aliases(&invalid))
+}
Evidence
verify_lockfile_dependency_names() now iterates every alias-bearing map (importers + snapshots),
and push_invalid_aliases() allocates a String for each alias via to_string() prior to
validation, even if the alias is valid and never added to the invalid set.

pacquet/crates/lockfile-verification/src/verify_lockfile_resolutions.rs[315-360]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`push_invalid_aliases()` currently stringifies every `PkgName` (`alias.to_string()`) before validation, even though only invalid aliases need to be retained for error reporting. With `verify_lockfile_dependency_names()` now used as an unconditional structural gate, this introduces per-alias heap allocations on the install hot path.

### Issue Context
- `verify_lockfile_dependency_names()` scans every importer alias, snapshot package name, and snapshot dependency alias.
- `push_invalid_aliases()` performs `alias.to_string()` for each alias just to pass a `&str` into `is_valid_old_npm_package_name()`.

### Fix Focus Areas
- pacquet/crates/lockfile-verification/src/verify_lockfile_resolutions.rs[320-360]

### Suggested fix
Avoid allocating for valid aliases by validating directly over the `PkgName` parts:
- Add a new helper like `is_valid_old_npm_package_name_parts(scope: Option<&str>, bare: &str) -> bool` (or similar) that mirrors the rules in `is_valid_old_npm_package_name` without requiring a joined string.
- In `push_invalid_aliases`, run the parts-based validation first; only if invalid, then call `alias.to_string()` once to record the offender for the error breakdown.

This keeps the same error payload (strings for invalid aliases) while removing allocations for the (common) valid case.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


12. No backslash traversal test 🐞 Bug ⚙ Maintainability
Description
The new traversal tests only cover '/' separators, but the implementation explicitly treats both '/'
and '\\' as path separators. Without a '\\'-based test vector, a Windows-specific regression in
separator handling could go unnoticed.
Code

pnpm11/deps/graph-hasher/test/calcLeafGlobalVirtualStorePath.test.ts[R10-19]

+  // The version segment is lockfile-controlled and inserted raw into the slot
+  // path; a `..` segment would let the slot escape the global virtual store
+  // root once joined onto `globalVirtualStoreDir`. All GVS slot builders funnel
+  // through `formatGlobalVirtualStorePath`, so the rejection happens here.
+  it.each(['../../../escape', '..', 'a/../../b', 'x/..'])(
+    'rejects a traversal version segment %p',
+    (version) => {
+      expect(() => calcLeafGlobalVirtualStorePath('[email protected]:sha512-abc', 'foo', version))
+        .toThrow(expect.objectContaining({ code: 'ERR_PNPM_INVALID_DEPENDENCY_NAME' }))
+    }
Evidence
The test table includes only '/' cases, while the implementation explicitly splits on both '/' and
'\\', so the '\\' branch is currently untested.

pnpm11/deps/graph-hasher/test/calcLeafGlobalVirtualStorePath.test.ts[10-20]
pnpm11/deps/graph-hasher/src/index.ts[296-301]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new `calcLeafGlobalVirtualStorePath` tests validate traversal rejection only for forward-slash inputs. The implementation splits on both `/` and `\\`, so tests should also include backslash-based traversal strings.

## Issue Context
This is a cross-platform security regression test; adding `\\` vectors makes it harder to accidentally break Windows behavior.

## Fix Focus Areas
- pnpm11/deps/graph-hasher/test/calcLeafGlobalVirtualStorePath.test.ts[10-20]

Suggested additions to `it.each([...])`:
- `"..\\"`
- `"..\\..\\escape"`
- `"x\\.."`
- `"a\\..\\..\\b"`

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


13. Duplicate name validation scan 🐞 Bug ➹ Performance
Description
In the frozen-lockfile install path, dependency-name validation now runs twice: once before any
materialization, and again inside verify_lockfile_resolutions(). This adds an extra full lockfile
walk on a hot path for large lockfiles without changing the verdict.
Code

pacquet/crates/lockfile-verification/src/verify_lockfile_resolutions.rs[R70-75]

+    // Offline structural gate first: reject invalid dependency names
+    // before the `packages`-absent short-circuit and the cache lookup,
+    // so a lockfile that carries a path-traversal alias but no
+    // `packages:` section (e.g. only `link:` deps) is still rejected.
+    verify_lockfile_dependency_names(lockfile)?;
+
Evidence
verify_lockfile_resolutions() now runs verify_lockfile_dependency_names(lockfile)?; before any
other short-circuiting. The frozen-lockfile install path also calls the same verifier
unconditionally before creating the virtual store, so with resolution verifiers enabled the same
scan happens twice in a single run.

pacquet/crates/lockfile-verification/src/verify_lockfile_resolutions.rs[65-78]
pacquet/crates/package-manager/src/install_frozen_lockfile.rs[885-897]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`verify_lockfile_resolutions()` now unconditionally calls `verify_lockfile_dependency_names(lockfile)` at function entry. The frozen-lockfile install path already calls `verify_lockfile_dependency_names(lockfile)` before starting any fetch/materialization, so when resolution verifiers are enabled the same O(lockfile) scan runs twice.

### Issue Context
- The early call in the frozen path is important (it must happen before any materialization/fetch can act on a poisoned lockfile).
- The call inside `verify_lockfile_resolutions()` is also important for other callers that do not perform the early structural validation themselves.

### Fix Focus Areas
- pacquet/crates/lockfile-verification/src/verify_lockfile_resolutions.rs[65-78]
- pacquet/crates/package-manager/src/install_frozen_lockfile.rs[885-896]

### Suggested fix
Add an option to `VerifyLockfileResolutionsOptions` (e.g. `skip_dependency_name_check: bool` or `dependency_names_already_verified: bool`, default `false`).

- Keep the default behavior: `verify_lockfile_resolutions()` should still run `verify_lockfile_dependency_names()` when the flag is not set.
- In the frozen-lockfile path, after running the early `verify_lockfile_dependency_names(lockfile)` gate, set the flag when constructing `VerifyLockfileResolutionsOptions` for the later verifier fan-out so the second scan is skipped.

This preserves the security property (fail before materialization) while removing redundant work.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (1)
14. Missing intermediate containment assert 🐞 Bug ⚙ Maintainability
Description
The traversal regression test only asserts that the final computed path (escaped) falls outside
the virtual store, but it never asserts that the intermediate dirInVirtualStore is still inside
the virtual store. If depPathToFilename() ever regresses to emit path separators (or any earlier
step escapes), this test could still pass while failing to detect that a different escape sink has
reappeared.
Code

pnpm11/deps/graph-builder/test/lockfileToDepGraph.test.ts[R83-91]

+  // Reconstruct the exact install directory the unguarded code would derive:
+  // `depPathToFilename` folds the depPath key into a single (contained) store
+  // subdir, but the separately-parsed `pkgName` is joined onto its
+  // `node_modules` raw — that raw join is what escapes.
+  const dirInVirtualStore = path.join(opts.virtualStoreDir, depPathToFilename(`${name}@1.0.0`, opts.virtualStoreDirMaxLength))
+  const escaped = path.join(dirInVirtualStore, 'node_modules', name)
+  // Guard against the test asserting on a non-escaping path: the derived
+  // directory must genuinely fall outside the virtual store.
+  expect(escaped.startsWith(opts.virtualStoreDir + path.sep)).toBe(false)
Evidence
The test computes dirInVirtualStore and escaped, but only asserts that escaped is outside the
store. Separately, depPathToFilename() explicitly replaces path separators, which is an invariant
the test is relying on but not asserting.

pnpm11/deps/graph-builder/test/lockfileToDepGraph.test.ts[83-91]
pnpm11/deps/path/src/index.ts[172-183]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The test intends to prove that the escape happens specifically at the `path.join(..., 'node_modules', name)` sink, but it currently only asserts that the final derived path is outside the virtual store. Add an assertion that `dirInVirtualStore` itself is inside `opts.virtualStoreDir`, so the test fails if containment regresses earlier.

## Issue Context
`depPathToFilename()` is expected to sanitize separators (e.g. replacing `/` and `\\`), but the test should explicitly lock in that invariant to ensure it is testing the intended escape vector.

## Fix Focus Areas
- pnpm11/deps/graph-builder/test/lockfileToDepGraph.test.ts[83-91]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

Comment thread pnpm11/lockfile/to-pnp/src/index.ts Resolved
@qodo-code-review

qodo-code-review Bot commented Jul 9, 2026 •

Copy link
Copy Markdown

PR Code Suggestions ✨

Latest suggestions up to 21e5aca

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

CategorySuggestion                                                                                                                                    Impact
Security
Guard exposed symlink alias

Use safe_join_modules_dir for alias when creating the symlink path.

pacquet/crates/package-manager/src/install_package_from_registry.rs [154-157]

 let save_path = safe_join_modules_dir(&slot_dir.join("node_modules"), &real_name)
     .map_err(InstallPackageFromRegistryError::InvalidAlias)?;
 
-let symlink_path = node_modules_dir.join(alias);
+let symlink_path = safe_join_modules_dir(node_modules_dir, alias)
+    .map_err(InstallPackageFromRegistryError::InvalidAlias)?;
  • Apply / Chat
Suggestion importance[1-10]: 8

__

Why: Applying safe_join_modules_dir to the alias ensures defense-in-depth, preventing potential path traversal escapes when the alias is derived from an untrusted source.

Medium
  • More

Previous suggestions

Suggestions up to commit e317ca5
CategorySuggestion                                                                                                                                    Impact
Security
Validate all raw slot segments

Validate the name argument in formatGlobalVirtualStorePath to prevent potential
path-traversal vulnerabilities.

pnpm11/deps/graph-hasher/src/index.ts [283-302]

 function formatGlobalVirtualStorePath (name: string, version: string, hexDigest: string): string {
-  // `version` is lockfile-controlled (`pkgSnapshot.version ?? parsed depPath`)
-  // and is inserted below as a raw path segment. Every global-virtual-store
-  // slot path funnels through here, and callers join the result onto
-  // `globalVirtualStoreDir` before passing it to `importPackage`, so a `..`
-  // segment in the version would let the slot escape the store root — even
-  // when the package name itself is valid (the name's own traversal is caught
-  // downstream by `safeJoinModulesDir`). Reject it at this single choke point.
-  assertNoPathTraversal(version)
+  assertNoPathTraversal('package name', name)
+  assertNoPathTraversal('version', version)
   const prefix = name.startsWith('@') ? '' : '@/'
   return `${prefix}${name}/${version}/${hexDigest}`
 }
 
-function assertNoPathTraversal (version: string): void {
-  if (version.split(/[/\\]/).includes('..')) {
-    const error = new Error(`Refusing to build a virtual-store path with the traversal version segment ${JSON.stringify(version)}`) as Error & { code: string }
+function assertNoPathTraversal (field: string, value: string): void {
+  if (value.split(/[/\\]/).includes('..')) {
+    const error = new Error(`Refusing to build a virtual-store path with the traversal ${field} segment ${JSON.stringify(value)}`) as Error & { code: string }
     error.code = 'ERR_PNPM_INVALID_DEPENDENCY_NAME'
     throw error
   }
 }
Suggestion importance[1-10]: 5

__

Why: While the PR explicitly notes that name validation is handled downstream by safeJoinModulesDir, adding the check here provides defense-in-depth and prevents returning unsafe relative paths.

Low
Suggestions up to commit 59603c6
CategorySuggestion                                                                                                                                    Impact
Security
Validate package key names

Validate lockfile.packages keys for invalid names.

pacquet/crates/lockfile-verification/src/verify_lockfile_resolutions.rs [343-361]

 fn collect_invalid_dependency_names(lockfile: &Lockfile) -> std::collections::BTreeSet<String> {
     let mut invalid = std::collections::BTreeSet::new();
     for importer in lockfile.importers.values() {
         for deps in
             [&importer.dependencies, &importer.dev_dependencies, &importer.optional_dependencies]
         {
             push_invalid_aliases(deps.iter().flatten().map(|(alias, _)| alias), &mut invalid);
+        }
+    }
+    if let Some(packages) = lockfile.packages.as_ref() {
+        for key in packages.keys() {
+            push_invalid_aliases(std::iter::once(&key.name), &mut invalid);
         }
     }
     if let Some(snapshots) = lockfile.snapshots.as_ref() {
         for (key, snapshot) in snapshots {
             push_invalid_aliases(std::iter::once(&key.name), &mut invalid);
             for deps in [&snapshot.dependencies, &snapshot.optional_dependencies] {
                 push_invalid_aliases(deps.iter().flatten().map(|(alias, _)| alias), &mut invalid);
             }
         }
     }
     invalid
 }
Suggestion importance[1-10]: 9

__

Why: Addresses a critical security gap by ensuring crafted package keys in lockfile.packages are validated against path traversals, matching the protection applied to snapshots.

High
Validate all slot keys

Extend virtual-store slot containment checks to packages keys.

pacquet/crates/package-manager/src/validate_lockfile_paths.rs [29-49]

 pub fn validate_virtual_store_slot_containment(
     snapshots: Option<&HashMap<PackageKey, SnapshotEntry>>,
+    packages: Option<&HashMap<PackageKey, PackageMetadata>>,
     layout: &VirtualStoreLayout,
 ) -> Result<(), VerifyError> {
-    let Some(snapshots) = snapshots else {
-        return Ok(());
-    };
     let mut escaped: BTreeSet<String> = BTreeSet::new();
-    for key in snapshots.keys() {
+    for key in snapshots.into_iter().flat_map(HashMap::keys).chain(packages.into_iter().flat_map(HashMap::keys)) {
         // Lexical containment: the slot does not exist yet, so this must
         // not touch the filesystem.
         if !is_subdir(layout.package_store_dir(), &layout.slot_dir(key)) {
             escaped.insert(key.to_string());
         }
     }
     if escaped.is_empty() {
         return Ok(());
     }
     let escaped: Vec<String> = escaped.into_iter().collect();
     Err(VerifyError::invalid_dependency_aliases(&escaped))
 }
Suggestion importance[1-10]: 9

__

Why: Enhances security by extending the slot containment validation to include packages entries, preventing potential traversal escapes if snapshots are omitted.

High
Contain global store slots

Apply virtual-store root containment validation to the modules directory path.

pnpm11/installing/deps-resolver/src/index.ts [611-616]

-const modules = path.join(opts.globalVirtualStoreDir, hash, 'node_modules')
+const dirInGlobalVirtualStore = containVirtualStoreDir(opts.globalVirtualStoreDir, path.join(opts.globalVirtualStoreDir, hash))
+const modules = path.join(dirInGlobalVirtualStore, 'node_modules')
 const node = graph[depPath]
 Object.assign(node, {
   modules,
   dir: safeJoinModulesDir(modules, node.name),
 })
Suggestion importance[1-10]: 8

__

Why: Correctly identifies a missing security fix for global store slot traversals during fresh resolutions, though the suggested containVirtualStoreDir function needs to be imported or defined for the code to compile.

Medium
Suggestions
CategorySuggestion                                                                                                                                    Impact
Security
Validate before async work

Precompute package directories synchronously before starting async tasks to fail
fast on invalid package names.

pnpm11/deps/graph-builder/src/lockfileToDepGraph.ts [189-238]

 const promises: Array<Promise<void>> = []
 const pkgSnapshotsWithLocations = iteratePkgsForVirtualStore(lockfile, opts)
+  .map(({ dirInVirtualStore, pkgMeta }) => ({
+    dirInVirtualStore,
+    pkgMeta,
+    dir: safeJoinModulesDir(path.join(dirInVirtualStore, 'node_modules'), pkgMeta.name),
+  }))
 
-for (const { dirInVirtualStore, pkgMeta } of pkgSnapshotsWithLocations) {
+for (const { dirInVirtualStore, pkgMeta, dir } of pkgSnapshotsWithLocations) {
   promises.push((async () => {
     const { pkgIdWithPatchHash, name: pkgName, version: pkgVersion, depPath, pkgSnapshot } = pkgMeta
     ...
-    const modules = path.join(dirInVirtualStore, 'node_modules')
-    // `pkgName` is reconstructed from the (attacker-controllable) lockfile
-    // depPath key via `dp.parse`, which does no validation. Contain it here so
-    // a traversal name (e.g. `../../../tmp/x`) can't make the package import
-    // escape the virtual store. Mirrors the guard on the hoisted linker.
-    const dir = safeJoinModulesDir(modules, pkgName)
Suggestion importance[1-10]: 2

__

Why: Failing fast provides only a marginal improvement since the vulnerability is already mitigated, and if iteratePkgsForVirtualStore returns an iterator, .map() evaluates lazily which defeats the suggestion's stated purpose.

Low

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pnpm11/deps/graph-builder/test/lockfileToDepGraph.test.ts`:
- Around line 78-85: The regression test is checking the wrong path, so it does
not verify the actual containment behavior. Update lockfileToDepGraph does not
create a directory outside the virtual store for a traversal name to assert the
computed package directory stays within the virtual store boundary, using the
path derived by lockfileToDepGraph/graphOpts rather than the synthetic escaped
path. If you keep the filesystem assertion, point it at the real escape target
that the code would derive, and keep the ERR_PNPM_INVALID_DEPENDENCY_NAME
expectation in place.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 46309efa-a641-48ba-b0e5-956c41f19d43

📥 Commits

Reviewing files that changed from the base of the PR and between 508b8c2 and 7158b67.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !pnpm-lock.yaml
📒 Files selected for processing (10)
  • .changeset/contain-virtual-store-package-name.md
  • pnpm11/deps/graph-builder/package.json
  • pnpm11/deps/graph-builder/src/lockfileToDepGraph.ts
  • pnpm11/deps/graph-builder/test/lockfileToDepGraph.test.ts
  • pnpm11/deps/graph-builder/test/tsconfig.json
  • pnpm11/deps/graph-builder/tsconfig.json
  • pnpm11/lockfile/to-pnp/package.json
  • pnpm11/lockfile/to-pnp/src/index.ts
  • pnpm11/lockfile/to-pnp/test/index.ts
  • pnpm11/lockfile/to-pnp/tsconfig.json

…rsal test

The containment regression test computed a synthetic escaped path that did not
match what the linker actually derives: `depPathToFilename` folds the depPath
key into a single contained store subdir, while the separately-parsed package
name is what escapes when joined onto that subdir's node_modules. Reconstruct
that exact directory (and assert it genuinely falls outside the virtual store)
so the filesystem check verifies the boundary the guard enforces.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings July 9, 2026 09:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 9, 2026
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 1c14ca8

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

CategorySuggestion                                                                                                                                    Impact
Security
Validate before async work

Precompute package directories synchronously before starting async tasks to fail
fast on invalid package names.

pnpm11/deps/graph-builder/src/lockfileToDepGraph.ts [189-238]

 const promises: Array<Promise<void>> = []
 const pkgSnapshotsWithLocations = iteratePkgsForVirtualStore(lockfile, opts)
+  .map(({ dirInVirtualStore, pkgMeta }) => ({
+    dirInVirtualStore,
+    pkgMeta,
+    dir: safeJoinModulesDir(path.join(dirInVirtualStore, 'node_modules'), pkgMeta.name),
+  }))
 
-for (const { dirInVirtualStore, pkgMeta } of pkgSnapshotsWithLocations) {
+for (const { dirInVirtualStore, pkgMeta, dir } of pkgSnapshotsWithLocations) {
   promises.push((async () => {
     const { pkgIdWithPatchHash, name: pkgName, version: pkgVersion, depPath, pkgSnapshot } = pkgMeta
     ...
-    const modules = path.join(dirInVirtualStore, 'node_modules')
-    // `pkgName` is reconstructed from the (attacker-controllable) lockfile
-    // depPath key via `dp.parse`, which does no validation. Contain it here so
-    // a traversal name (e.g. `../../../tmp/x`) can't make the package import
-    // escape the virtual store. Mirrors the guard on the hoisted linker.
-    const dir = safeJoinModulesDir(modules, pkgName)

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 2

__

Why: Failing fast provides only a marginal improvement since the vulnerability is already mitigated, and if iteratePkgsForVirtualStore returns an iterator, .map() evaluates lazily which defeats the suggestion's stated purpose.

Low
  • More

zkochan and others added 2 commits July 9, 2026 12:21
…x9-3g3h-c2jv)

A crafted pnpm-lock.yaml could carry a dependency alias, snapshot package
name, or virtual-store slot with path-traversal segments (e.g.
`../../escaped-link`). During `pacquet install` — notably
`--frozen-lockfile --trust-lockfile` — those lockfile-controlled strings
were joined into filesystem paths and could create symlinks, directories,
or bins outside the project / node_modules boundary (CWE-22 / CWE-59).

The lockfile verifier already validated dependency aliases, but the check
only ran inside the resolution-policy fan-out, which `trustLockfile`
disables — and it never covered snapshot package names or packages-less
(`link:`-only) lockfiles.

- Add `verify_lockfile_dependency_names`, an offline structural check over
  importer aliases, snapshot package names, and snapshot dependency
  aliases, and run it in `verify_lockfile_resolutions` before the
  `packages`-absent short-circuit and the cache lookup.
- Call it unconditionally from `InstallFrozenLockfile::run` — before any
  materialization and the warm-install skip filter — so `trustLockfile`
  cannot bypass it.
- Add `validate_virtual_store_slot_containment` to reject a
  global-virtual-store slot whose version-derived segment escapes the
  store root, the one escape name validation alone cannot catch.

Rejections surface `ERR_PNPM_INVALID_DEPENDENCY_NAME`.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The isolated-linker name guard (safeJoinModulesDir on the inner package
name) does not cover the global-virtual-store slot directory, which is
built from the lockfile-controlled package name and version via
`formatGlobalVirtualStorePath` — inserting both as raw `/`-separated path
segments. A snapshot with a valid name but a traversal `version` (e.g.
`version: "../../x"`) escapes the store root before the inner name join
runs, so the name guard passes and the package materializes outside the
store.

Contain the computed slot directory against its store root in
`iteratePkgsForVirtualStore`, throwing ERR_PNPM_INVALID_DEPENDENCY_NAME
when it escapes. Applied to the legacy slot too (already single-segment
via depPathToFilename) as a uniform final guarantee.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings July 9, 2026 10:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@zkochan zkochan changed the title fix(security): contain virtual-store and PnP package names against path traversal fix(security): contain lockfile package names/slots against path traversal (pnpm + pacquet) Jul 9, 2026
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit b44dc7e

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

Auto-approved notes - no code suggestions found
- 'approve_pr_on_self_review' flag enabled

@github-actions

github-actions Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                          main                                   pr
-----                          ----                                   --
tarball/download_dependency    1.00      4.2±0.28ms  1030.2 KB/sec    1.00      4.2±0.31ms  1029.9 KB/sec

A tarball, git, or file dependency whose own package.json `name` was a
scoped path traversal (e.g. `@x/../../../<path>`) was used verbatim as
the directory name for the package inside the virtual store. The
isolated linker built its import target with a raw
`path.join(modules, name)`, without the `safeJoinModulesDir`
containment guard already applied on the hoisted/symlink paths, and the
resolve-time name gate only rejected unscoped names. As a result the
package's files were extracted outside node_modules to an
attacker-chosen absolute path, and could overwrite existing files
there, during `pnpm install` — even with `--ignore-scripts`. This is
GHSA-vq4v-j7r6-jq4m.

Route the resolved package name through `safeJoinModulesDir` at every
isolated-linker sink (resolvePeers, the GVS graph builder in
deps-resolver, and graph-builder's lockfileToDepGraph), and at the
env-installer config-subdep sinks, so a traversal name is rejected with
`ERR_PNPM_INVALID_DEPENDENCY_NAME` before any write and legitimate
scoped names are unaffected.

The Rust pacquet port shared the vulnerability: the unpack target in
install_package_from_registry, the snapshot import target in
create_virtual_dir_by_snapshot, and the hoist symlink source now go
through pacquet's existing `safe_join_modules_dir`. Its env-installer
path was already covered by `verify_env_lockfile`.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 5ba0e45

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

Auto-approved notes - no code suggestions found
- 'approve_pr_on_self_review' flag enabled

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 5ba0e45d6213

Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD.

Scenario: Isolated linker: fresh restore, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.121 ± 0.173 3.944 4.463 2.13 ± 0.16
pacquet@main 4.018 ± 0.114 3.878 4.227 2.07 ± 0.15
pnpr@HEAD 1.938 ± 0.125 1.745 2.158 1.00
pnpr@main 1.939 ± 0.136 1.784 2.181 1.00 ± 0.10
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.121403453,
      "stddev": 0.1725690288843961,
      "median": 4.0390349578,
      "user": 4.35762884,
      "system": 2.2970904000000005,
      "min": 3.9435398768,
      "max": 4.4629389728,
      "times": [
        4.3290072148,
        4.4629389728,
        4.2317016218,
        4.0280402878,
        4.0252888798,
        3.9918241918,
        4.0500296278,
        4.1770258738,
        3.9435398768,
        3.9746379828
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.0175266898999995,
      "stddev": 0.11360169848515259,
      "median": 3.9955802983,
      "user": 4.372096340000001,
      "system": 2.3186188000000003,
      "min": 3.8780315898000004,
      "max": 4.2270221828,
      "times": [
        3.8780315898000004,
        3.8839160258,
        4.1287959508,
        3.9676891608000004,
        4.0348922618,
        4.023471435799999,
        3.9410834598,
        3.9665240328,
        4.1238407988,
        4.2270221828
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.9378362380999998,
      "stddev": 0.12528376986556708,
      "median": 1.9258303713,
      "user": 2.97714254,
      "system": 1.9725393,
      "min": 1.7448716517999998,
      "max": 2.1581971868000003,
      "times": [
        1.9811688578,
        1.8875915468,
        1.8360543507999998,
        1.9480536188,
        1.9036071237999999,
        1.7448716517999998,
        1.8301786998,
        1.9935037598,
        2.1581971868000003,
        2.0951355848
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.9390326137999998,
      "stddev": 0.13617612568771517,
      "median": 1.9005132757999998,
      "user": 3.00690604,
      "system": 1.9714416999999997,
      "min": 1.7840774888,
      "max": 2.1811368238,
      "times": [
        2.1811368238,
        2.0743305468,
        1.8417889658,
        2.1020024028,
        1.8211400058,
        1.7840774888,
        1.9491454758,
        1.8666143947999998,
        1.9344121568,
        1.8356778768
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 511.9 ± 6.6 502.0 520.4 1.03 ± 0.02
pacquet@main 498.0 ± 7.6 489.5 511.8 1.00
pnpr@HEAD 598.0 ± 100.8 522.4 788.1 1.20 ± 0.20
pnpr@main 556.7 ± 10.6 541.1 569.9 1.12 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.5119168754000001,
      "stddev": 0.006577492384443104,
      "median": 0.5130737490999999,
      "user": 0.40292034,
      "system": 0.82499048,
      "min": 0.5020408791000001,
      "max": 0.5203708451,
      "times": [
        0.5075253341,
        0.5184607391,
        0.5108153591,
        0.5203708451,
        0.5153321391,
        0.5159786331,
        0.5042571791,
        0.5181123691,
        0.5062752771,
        0.5020408791000001
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.4979749481000001,
      "stddev": 0.007614156684202578,
      "median": 0.4960513521,
      "user": 0.39959353999999997,
      "system": 0.81392968,
      "min": 0.4895423131,
      "max": 0.5117892581,
      "times": [
        0.5024468831,
        0.49088735910000003,
        0.5092070551,
        0.49136954110000003,
        0.4895423131,
        0.4954970771,
        0.4945423761,
        0.4966056271,
        0.4978619911,
        0.5117892581
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.5980122017,
      "stddev": 0.10081840159856847,
      "median": 0.5546206516000001,
      "user": 0.4105380399999999,
      "system": 0.85703788,
      "min": 0.5224387071000001,
      "max": 0.7880812261000001,
      "times": [
        0.5481953551000001,
        0.5340775921,
        0.5532968141,
        0.5224387071000001,
        0.7865716671,
        0.7880812261000001,
        0.5711273801,
        0.5559444891,
        0.5511055531,
        0.5692832331000001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.5566588962000001,
      "stddev": 0.010634556517302177,
      "median": 0.5564296981000001,
      "user": 0.4168607399999999,
      "system": 0.8566713800000001,
      "min": 0.5411131311,
      "max": 0.5698592471,
      "times": [
        0.5505901681,
        0.5535348581,
        0.5656098781000001,
        0.5441634181,
        0.5411131311,
        0.5698592471,
        0.5478613221,
        0.5593245381,
        0.5650815771000001,
        0.5694508241
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.262 ± 0.035 4.208 4.330 2.10 ± 0.11
pacquet@main 4.267 ± 0.042 4.191 4.335 2.10 ± 0.11
pnpr@HEAD 2.043 ± 0.171 1.868 2.270 1.01 ± 0.10
pnpr@main 2.029 ± 0.106 1.865 2.258 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.26163732888,
      "stddev": 0.034667308479452055,
      "median": 4.257242723680001,
      "user": 4.30585756,
      "system": 2.25240916,
      "min": 4.20816756468,
      "max": 4.33049987868,
      "times": [
        4.33049987868,
        4.259058967680001,
        4.22551433868,
        4.29203804668,
        4.277047591680001,
        4.20816756468,
        4.2421325026800005,
        4.27585269468,
        4.2554264796800005,
        4.250635223680001
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.266955831980001,
      "stddev": 0.04194053015409888,
      "median": 4.253132000680001,
      "user": 4.268454459999999,
      "system": 2.25858506,
      "min": 4.19098230068,
      "max": 4.33488361968,
      "times": [
        4.244629557680001,
        4.2511307266800005,
        4.30043242368,
        4.305859932680001,
        4.25097388168,
        4.23891067968,
        4.25513327468,
        4.33488361968,
        4.296621922680001,
        4.19098230068
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.0432067593799994,
      "stddev": 0.17050266733507385,
      "median": 1.99761015668,
      "user": 2.7922448600000003,
      "system": 1.8971653599999996,
      "min": 1.86780594768,
      "max": 2.27019403768,
      "times": [
        2.27019403768,
        2.11894858568,
        1.8756648086799999,
        1.9084547996799999,
        1.86780594768,
        1.8749834566799999,
        2.2604073796799997,
        1.98050093268,
        2.01471938068,
        2.26038826468
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.02940153518,
      "stddev": 0.1062689006032878,
      "median": 2.00008614918,
      "user": 2.7868064599999993,
      "system": 1.90803696,
      "min": 1.86533871968,
      "max": 2.25838339268,
      "times": [
        1.99469901368,
        1.86533871968,
        2.06177817968,
        1.98288681368,
        2.00547328468,
        2.11707848968,
        2.25838339268,
        1.9878628166799999,
        2.07006537468,
        1.95044926668
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, hot cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.289 ± 0.019 1.257 1.324 2.45 ± 0.04
pacquet@main 1.313 ± 0.050 1.281 1.454 2.50 ± 0.10
pnpr@HEAD 0.537 ± 0.022 0.522 0.600 1.02 ± 0.04
pnpr@main 0.525 ± 0.005 0.517 0.530 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.2886906798200002,
      "stddev": 0.01885679787975631,
      "median": 1.28951589442,
      "user": 1.4548180599999998,
      "system": 1.08640942,
      "min": 1.25654846242,
      "max": 1.32363349342,
      "times": [
        1.2825432624200002,
        1.27589100442,
        1.3055845804200001,
        1.28994934442,
        1.29297916642,
        1.29977974942,
        1.27091529042,
        1.32363349342,
        1.28908244442,
        1.25654846242
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.3133058011199998,
      "stddev": 0.04995643196761544,
      "median": 1.30110624292,
      "user": 1.46939096,
      "system": 1.0930548199999996,
      "min": 1.28101773142,
      "max": 1.45397014342,
      "times": [
        1.30592850342,
        1.29722853742,
        1.29268857942,
        1.29364415542,
        1.30381279742,
        1.30250669342,
        1.45397014342,
        1.30255507742,
        1.2997057924200002,
        1.28101773142
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.53707631542,
      "stddev": 0.02248175827388987,
      "median": 0.53139639792,
      "user": 0.3599643599999999,
      "system": 0.79816442,
      "min": 0.52223458942,
      "max": 0.60010140542,
      "times": [
        0.53484897142,
        0.53151101842,
        0.52913752742,
        0.52223458942,
        0.5261914894199999,
        0.53230418542,
        0.52824937242,
        0.53490281742,
        0.60010140542,
        0.5312817774199999
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.52521812572,
      "stddev": 0.0047183103242666195,
      "median": 0.52624205392,
      "user": 0.35425576000000003,
      "system": 0.79669492,
      "min": 0.51706965242,
      "max": 0.53025934742,
      "times": [
        0.52930729142,
        0.53025934742,
        0.52968713342,
        0.52477533742,
        0.52728090242,
        0.51706965242,
        0.52259002442,
        0.52520320542,
        0.52803885542,
        0.51796950742
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.097 ± 0.049 3.020 3.188 5.73 ± 0.12
pacquet@main 3.061 ± 0.025 3.006 3.095 5.66 ± 0.09
pnpr@HEAD 0.541 ± 0.007 0.529 0.556 1.00
pnpr@main 0.544 ± 0.011 0.533 0.569 1.01 ± 0.02
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.09732791624,
      "stddev": 0.049267354387338994,
      "median": 3.08214961874,
      "user": 2.0289960799999998,
      "system": 1.32726914,
      "min": 3.02006498274,
      "max": 3.18785209074,
      "times": [
        3.10745483774,
        3.07986861074,
        3.07314115374,
        3.02006498274,
        3.08443062674,
        3.07157938674,
        3.06484648674,
        3.16214086174,
        3.18785209074,
        3.1219001247400002
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 3.0609837877400006,
      "stddev": 0.024970660333319634,
      "median": 3.06508907174,
      "user": 1.9945824799999996,
      "system": 1.30450524,
      "min": 3.00575048874,
      "max": 3.09450417074,
      "times": [
        3.07995666774,
        3.03989243574,
        3.09450417074,
        3.00575048874,
        3.06353473474,
        3.04683651574,
        3.07130107874,
        3.06543927874,
        3.07788364174,
        3.0647388647400002
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.54069005964,
      "stddev": 0.0071848260649293675,
      "median": 0.5398425207400002,
      "user": 0.37534108,
      "system": 0.8105960399999999,
      "min": 0.5292491917400001,
      "max": 0.55583865974,
      "times": [
        0.5403058327400001,
        0.54065997174,
        0.5482483127400001,
        0.53752749574,
        0.5361009987400001,
        0.5423020567400001,
        0.5292491917400001,
        0.55583865974,
        0.5372888677400001,
        0.5393792087400001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.5440282005399999,
      "stddev": 0.011268449838782819,
      "median": 0.54325760974,
      "user": 0.36271857999999996,
      "system": 0.8076234399999999,
      "min": 0.53273728874,
      "max": 0.5691519787400001,
      "times": [
        0.53537457974,
        0.53327087474,
        0.54326054574,
        0.53273728874,
        0.5691519787400001,
        0.54325467374,
        0.5352331897400001,
        0.5512727847400001,
        0.5518916367400001,
        0.5448344527400001
      ]
    }
  ]
}

Scenario: Isolated linker: fresh resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 720.5 ± 12.8 698.3 740.1 6.89 ± 0.13
pacquet@main 722.3 ± 5.0 710.8 726.8 6.91 ± 0.06
pnpr@HEAD 104.6 ± 1.0 103.0 108.6 1.00 ± 0.01
pnpr@main 104.6 ± 0.5 102.9 105.8 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.7205192172000001,
      "stddev": 0.012763158687024276,
      "median": 0.7172548032,
      "user": 0.70850254,
      "system": 0.10897766,
      "min": 0.6982927932,
      "max": 0.7400878092000001,
      "times": [
        0.7087776402,
        0.7290609252,
        0.7164917392,
        0.6982927932,
        0.7139288922,
        0.7163934022,
        0.7400878092000001,
        0.7358465372,
        0.7180178672,
        0.7282945662
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.7222791092,
      "stddev": 0.004973429513426707,
      "median": 0.7238778502000001,
      "user": 0.70418144,
      "system": 0.11456446000000002,
      "min": 0.7107868552000001,
      "max": 0.7268161862,
      "times": [
        0.7235169942,
        0.7178158002,
        0.7268161862,
        0.7236880932,
        0.7258692572000001,
        0.7192209142,
        0.7258721852,
        0.7240676072,
        0.7107868552000001,
        0.7251371992
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.10460991281538462,
      "stddev": 0.001024861088782478,
      "median": 0.10458994370000001,
      "user": 0.02839114,
      "system": 0.013240706153846152,
      "min": 0.1030341422,
      "max": 0.1086426162,
      "times": [
        0.1047412372,
        0.1040364792,
        0.1053998322,
        0.10493135020000001,
        0.1042048612,
        0.1044759452,
        0.10440395620000001,
        0.1048116292,
        0.1030341422,
        0.1041387042,
        0.1037043772,
        0.10527674620000001,
        0.10405352720000001,
        0.10470394220000001,
        0.1033724542,
        0.10482391020000001,
        0.1042963442,
        0.1047863842,
        0.1036609492,
        0.1054330962,
        0.1047909312,
        0.1048149772,
        0.1086426162,
        0.1037967712,
        0.1051502502,
        0.10437231920000001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.104578108162963,
      "stddev": 0.0005459073477616083,
      "median": 0.1046866802,
      "user": 0.028319436296296293,
      "system": 0.013804452592592588,
      "min": 0.1028983262,
      "max": 0.1057773882,
      "times": [
        0.1028983262,
        0.1047585862,
        0.1047215202,
        0.1047570792,
        0.1044898612,
        0.1041589512,
        0.1047513152,
        0.1049130942,
        0.1049039922,
        0.1042575772,
        0.10454126820000001,
        0.1046934962,
        0.1057773882,
        0.1054285102,
        0.10490693820000001,
        0.1039422962,
        0.10453204320000001,
        0.1040558002,
        0.1046184482,
        0.1051096982,
        0.1043404592,
        0.10432024320000001,
        0.1048028882,
        0.1046866802,
        0.10374082720000001,
        0.1045128312,
        0.10498880120000001
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 6.899 ± 0.096 6.799 7.118 1.41 ± 0.03
pacquet@main 6.918 ± 0.091 6.748 7.083 1.41 ± 0.03
pnpr@HEAD 4.943 ± 0.126 4.826 5.251 1.01 ± 0.03
pnpr@main 4.898 ± 0.077 4.754 5.045 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 6.89895112378,
      "stddev": 0.09604422550059201,
      "median": 6.89011649428,
      "user": 4.59114814,
      "system": 2.5305112800000003,
      "min": 6.79923952078,
      "max": 7.11804591978,
      "times": [
        6.88855714178,
        6.79923952078,
        6.845638774779999,
        6.91002897978,
        6.89167584678,
        6.84722812378,
        6.99583304278,
        6.89360878778,
        6.79965509978,
        7.11804591978
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 6.9181110207800005,
      "stddev": 0.09120861932777319,
      "median": 6.90626751728,
      "user": 4.66111264,
      "system": 2.54031298,
      "min": 6.74762528978,
      "max": 7.08295503678,
      "times": [
        6.84761602578,
        6.89272831278,
        6.91450437478,
        7.08295503678,
        6.74762528978,
        6.89803065978,
        6.882240600779999,
        6.96748276678,
        6.93763967878,
        7.01028746178
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 4.94274949678,
      "stddev": 0.12626017225403485,
      "median": 4.92136553028,
      "user": 3.16554424,
      "system": 2.2136630800000003,
      "min": 4.82572906378,
      "max": 5.25056965478,
      "times": [
        4.91346976178,
        4.92926129878,
        4.93375218778,
        5.01759308078,
        4.85833500478,
        4.82830694578,
        4.99836655778,
        5.25056965478,
        4.82572906378,
        4.87211141178
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 4.8979047933799995,
      "stddev": 0.07724356715949693,
      "median": 4.886623356279999,
      "user": 3.14732244,
      "system": 2.21467588,
      "min": 4.75401876078,
      "max": 5.04490981878,
      "times": [
        4.75401876078,
        4.90761012978,
        4.8756547777799994,
        4.87354421578,
        4.83988364978,
        4.95613842078,
        4.89105514878,
        4.88219156378,
        4.95404144778,
        5.04490981878
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12872
Testbedpacquet
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
🚷 view threshold
4,261.64 ms
(+0.32%)Baseline: 4,247.87 ms
5,097.45 ms
(83.60%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
3,097.33 ms
(+2.10%)Baseline: 3,033.52 ms
3,640.23 ms
(85.09%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
1,288.69 ms
(-4.71%)Baseline: 1,352.41 ms
1,622.89 ms
(79.41%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
720.52 ms
(+12.70%)Baseline: 639.32 ms
767.18 ms
(93.92%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
4,121.40 ms
(+3.33%)Baseline: 3,988.61 ms
4,786.34 ms
(86.11%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
6,898.95 ms
(+1.18%)Baseline: 6,818.71 ms
8,182.45 ms
(84.31%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
511.92 ms
(-20.17%)Baseline: 641.24 ms
769.48 ms
(66.53%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12872
Testbedpnpr

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

Click to view all benchmark results
BenchmarkLatencymilliseconds (ms)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,043.21 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
540.69 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
537.08 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
104.61 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,937.84 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
4,942.75 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
598.01 ms
🐰 View full continuous benchmarking report in Bencher

@zkochan
zkochan merged commit 51300fd into main Jul 9, 2026
33 checks passed
@zkochan
zkochan deleted the fix/contain-virtual-store-package-name branch July 9, 2026 13:46
zkochan added a commit that referenced this pull request Jul 9, 2026
…v10 (#12890)

Backports the TypeScript portion of 51300fd (#12872) to release/10.
Two advisories:

- GHSA-c59q-g84q-2gj5: lockfile depPath name -> isolated linker + PnP.
- GHSA-vq4v-j7r6-jq4m: dependency manifest `name` from the fetched
  tarball (e.g. @x/../../../path) -> resolver/linker.

Apply safeJoinModulesDir at lockfileToDepGraph (deps/graph-builder) and
the PnP packageLocation (lockfile-to-pnp); validate manifest names in
resolve-dependencies (extendGraph + resolvePeers); contain the
global-virtual-store slot dir by rejecting a traversal version segment
in iterateHashedGraphNodes (calc-dep-state), the single point every GVS
slot path funnels through.

The pacquet and env-installer changes from the original commit do not
apply to v10 (no pacquet stack; installConfigDeps has no GVS subdep
installation and config-dependency names are already validated by
assertValidConfigDepName from #12504).

All rejections surface ERR_PNPM_INVALID_DEPENDENCY_NAME.

Co-authored-by: Claude Fable 5 <[email protected]>
zkochan added a commit that referenced this pull request Jul 26, 2026
…rtual-store slot (#13383)

Installing a `file:` directory dependency with the global virtual store
enabled crashed the headless install:

    TypeError: Cannot read properties of undefined (reading 'split')
        at assertNoPathTraversal
        at formatGlobalVirtualStorePath
        at calcGraphNodeHash

pnpm omits `version` from a directory snapshot, so `nameVerFromPkgSnapshot`
hands the hasher `undefined` and the traversal guard added in
#12872 dereferences it. Directory snapshots now use a fixed
`directory` segment in place of the version. That also settles a
disagreement between the two install paths: the resolver reads the version
off the manifest and the headless install off the lockfile, where there is
none, so the same package landed on two different slots.

The crash hid a worse defect. A directory resolution is the one resolution
with no integrity — it is a path relative to the lockfile — so `file:dep`
hashed identically in every project that depended on a directory of that
name, and all of them linked to whichever project installed first. Since
the source directory is mutable, pnpm re-imports it on every install, so
the projects went on overwriting each other's copy. The lockfile directory
now joins the hash payload for directory resolutions, giving each project
its own slot; every other resolution hashes exactly as before.

`iterateHashedGraphNodes` takes an options object now — it was up to five
positional parameters before this change added a sixth.

Closes #13335
kairosci added a commit to kairosci/pnpm that referenced this pull request Jul 27, 2026
…rtual-store slot (pnpm#13383)

Installing a `file:` directory dependency with the global virtual store
enabled crashed the headless install:

    TypeError: Cannot read properties of undefined (reading 'split')
        at assertNoPathTraversal
        at formatGlobalVirtualStorePath
        at calcGraphNodeHash

pnpm omits `version` from a directory snapshot, so `nameVerFromPkgSnapshot`
hands the hasher `undefined` and the traversal guard added in
pnpm#12872 dereferences it. Directory snapshots now use a fixed
`directory` segment in place of the version. That also settles a
disagreement between the two install paths: the resolver reads the version
off the manifest and the headless install off the lockfile, where there is
none, so the same package landed on two different slots.

The crash hid a worse defect. A directory resolution is the one resolution
with no integrity — it is a path relative to the lockfile — so `file:dep`
hashed identically in every project that depended on a directory of that
name, and all of them linked to whichever project installed first. Since
the source directory is mutable, pnpm re-imports it on every install, so
the projects went on overwriting each other's copy. The lockfile directory
now joins the hash payload for directory resolutions, giving each project
its own slot; every other resolution hashes exactly as before.

`iterateHashedGraphNodes` takes an options object now — it was up to five
positional parameters before this change added a sixth.

Closes pnpm#13335
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pacquet product: pnpm@11 reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants