@pnpm/exec.prepare-package 1100.0.14 → 1100.0.16

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.
package/lib/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import type { AllowBuild } from '@pnpm/types';
2
2
  export interface PreparePackageOptions {
3
3
  allowBuild?: AllowBuild;
4
4
  ignoreScripts?: boolean;
5
+ pkgResolutionId: string;
5
6
  unsafePerm?: boolean;
6
7
  userAgent?: string;
7
8
  }
package/lib/index.js CHANGED
@@ -23,12 +23,16 @@ export async function preparePackage(opts, gitRootDir, subDir) {
23
23
  if (opts.ignoreScripts)
24
24
  return { shouldBeBuilt: true, pkgDir };
25
25
  // Check if the package is allowed to run build scripts
26
- // If allowBuild is undefined or returns false, block the build
27
- if (!opts.allowBuild?.(manifest.name, manifest.version)) {
26
+ // If allowBuild is undefined or returns false, block the build.
27
+ // The depPath is synthesized from the resolution id rather than read from
28
+ // a lockfile; resolution ids of git and tarball artifacts are never
29
+ // semver-shaped, so the policy derives an untrusted package identity.
30
+ const depPath = `${manifest.name}@${opts.pkgResolutionId}`;
31
+ if (!opts.allowBuild?.(depPath)) {
28
32
  throw new PnpmError('GIT_DEP_PREPARE_NOT_ALLOWED', `The git-hosted package "${manifest.name}@${manifest.version}" needs to execute build scripts but is not in the "allowBuilds" allowlist.`, {
29
33
  hint: `Add the package to "allowBuilds" in your project's pnpm-workspace.yaml to allow it to run scripts. For example:
30
34
  allowBuilds:
31
- ${manifest.name}: true`,
35
+ ${depPath}: true`,
32
36
  });
33
37
  }
34
38
  const pm = (await preferredPM(gitRootDir))?.name ?? 'npm';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnpm/exec.prepare-package",
3
- "version": "1100.0.14",
3
+ "version": "1100.0.16",
4
4
  "description": "Prepares a Git-hosted package",
5
5
  "keywords": [
6
6
  "pnpm",
@@ -8,7 +8,10 @@
8
8
  ],
9
9
  "license": "MIT",
10
10
  "funding": "https://opencollective.com/pnpm",
11
- "repository": "https://github.com/pnpm/pnpm/tree/main/exec/prepare-package",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/pnpm/pnpm/tree/main/exec/prepare-package"
14
+ },
12
15
  "homepage": "https://github.com/pnpm/pnpm/tree/main/exec/prepare-package#readme",
13
16
  "bugs": {
14
17
  "url": "https://github.com/pnpm/pnpm/issues"
@@ -29,16 +32,16 @@
29
32
  "preferred-pm": "^5.0.0",
30
33
  "ramda": "npm:@pnpm/ramda@0.28.1",
31
34
  "@pnpm/error": "1100.0.0",
32
- "@pnpm/exec.lifecycle": "1100.0.14",
33
- "@pnpm/types": "1101.2.0",
34
- "@pnpm/pkg-manifest.reader": "1100.0.5"
35
+ "@pnpm/exec.lifecycle": "1100.0.16",
36
+ "@pnpm/pkg-manifest.reader": "1100.0.7",
37
+ "@pnpm/types": "1101.3.1"
35
38
  },
36
39
  "devDependencies": {
37
40
  "@jest/globals": "30.3.0",
38
41
  "@types/ramda": "0.31.1",
39
42
  "load-json-file": "^7.0.1",
40
- "@pnpm/exec.prepare-package": "1100.0.14",
41
- "@pnpm/prepare": "1100.0.11",
43
+ "@pnpm/exec.prepare-package": "1100.0.16",
44
+ "@pnpm/prepare": "1100.0.14",
42
45
  "@pnpm/test-fixtures": "1100.0.0",
43
46
  "@pnpm/test-ipc-server": "1100.0.0"
44
47
  },