@pnpm/deps.graph-hasher 1100.2.7 → 1100.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/index.js +15 -0
  2. package/package.json +4 -4
package/lib/index.js CHANGED
@@ -197,9 +197,24 @@ export function calcGlobalVirtualStorePathWithSubdeps(fullPkgId, name, version,
197
197
  // Scoped: @scope/pkg/version/hash
198
198
  // Unscoped: @/pkg/version/hash
199
199
  function formatGlobalVirtualStorePath(name, version, hexDigest) {
200
+ // `version` is lockfile-controlled (`pkgSnapshot.version ?? parsed depPath`)
201
+ // and is inserted below as a raw path segment. Every global-virtual-store
202
+ // slot path funnels through here, and callers join the result onto
203
+ // `globalVirtualStoreDir` before passing it to `importPackage`, so a `..`
204
+ // segment in the version would let the slot escape the store root — even
205
+ // when the package name itself is valid (the name's own traversal is caught
206
+ // downstream by `safeJoinModulesDir`). Reject it at this single choke point.
207
+ assertNoPathTraversal(version);
200
208
  const prefix = name.startsWith('@') ? '' : '@/';
201
209
  return `${prefix}${name}/${version}/${hexDigest}`;
202
210
  }
211
+ function assertNoPathTraversal(version) {
212
+ if (version.split(/[/\\]/).includes('..')) {
213
+ const error = new Error(`Refusing to build a virtual-store path with the traversal version segment ${JSON.stringify(version)}`);
214
+ error.code = 'ERR_PNPM_INVALID_DEPENDENCY_NAME';
215
+ throw error;
216
+ }
217
+ }
203
218
  export function* iteratePkgMeta(lockfile, graph) {
204
219
  if (lockfile.packages == null) {
205
220
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnpm/deps.graph-hasher",
3
- "version": "1100.2.7",
3
+ "version": "1100.2.8",
4
4
  "description": "Calculates the state of a dependency",
5
5
  "keywords": [
6
6
  "pnpm",
@@ -28,17 +28,17 @@
28
28
  ],
29
29
  "dependencies": {
30
30
  "detect-libc": "^2.1.2",
31
+ "@pnpm/crypto.object-hasher": "1100.0.0",
31
32
  "@pnpm/deps.path": "1100.0.8",
32
- "@pnpm/lockfile.types": "1100.0.13",
33
33
  "@pnpm/lockfile.utils": "1100.1.1",
34
+ "@pnpm/lockfile.types": "1100.0.13",
34
35
  "@pnpm/resolving.resolver-base": "1100.5.1",
35
- "@pnpm/crypto.object-hasher": "1100.0.0",
36
36
  "@pnpm/engine.runtime.system-version": "1100.0.3",
37
37
  "@pnpm/types": "1101.3.2"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@jest/globals": "30.4.1",
41
- "@pnpm/deps.graph-hasher": "1100.2.7"
41
+ "@pnpm/deps.graph-hasher": "1100.2.8"
42
42
  },
43
43
  "engines": {
44
44
  "node": ">=22.13"