-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix: harden allowBuilds artifact approvals #12294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
24fa6f8
fix: harden allowBuilds artifact approvals
zkochan 6e13638
fix: dedupe allowBuilds identity logic and detect revoked artifact ap…
zkochan b4366f4
style: avoid a non-dictionary word in the log-drain test comment
zkochan 7227a1d
test: approve the dlx git-hosted package by depPath
zkochan 1dbfad8
fix: match rebuild depPath selectors with allowBuilds normalization
zkochan 32422ac
refactor: identify packages by depPath in the AllowBuild policy
zkochan d86964d
style(package-manager): drop trailing comma in single-line assert
zkochan c194a8e
refactor: derive allowBuilds identity trust from the dependency path
zkochan 429e434
fix: restore valid JSON in during-install tsconfig
zkochan b72ea3f
docs: include local directory artifacts in the allowBuilds changeset
zkochan 1f896a9
refactor: fold the resolution-shape pass into the candidate walk
zkochan af4e687
refactor: normalize rebuild selectors once at the edges
zkochan 3478af8
test: pin the GVS rebuild fallback for approvals granted after install
zkochan 41f0b16
fix: carry the shape-check identity in fresh-resolve verification rec…
zkochan eca97f8
docs: link the GVS in-place-rebuild fallback to its tracking issue
zkochan f415118
fix: gate resolution-shape trust on the tarball URL, exempt custom re…
zkochan f38b7bd
fix: require http(s) registry tarballs; don't mangle scheme'd git repos
zkochan b085d5b
fix: match git-hosted tarball URLs case-insensitively
zkochan 13ef6c8
test: reword case-insensitivity test to satisfy spellcheck
zkochan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| --- | ||
| "@pnpm/building.after-install": patch | ||
| "@pnpm/building.during-install": patch | ||
| "@pnpm/building.policy": patch | ||
| "@pnpm/deps.graph-builder": patch | ||
| "@pnpm/deps.graph-hasher": patch | ||
| "@pnpm/exec.prepare-package": patch | ||
| "@pnpm/fetching.git-fetcher": patch | ||
| "@pnpm/fetching.tarball-fetcher": patch | ||
| "@pnpm/installing.deps-installer": patch | ||
| "@pnpm/installing.deps-resolver": patch | ||
| "@pnpm/installing.deps-restorer": patch | ||
| "@pnpm/types": patch | ||
| "pnpm": patch | ||
| --- | ||
|
|
||
| Require trusted package identity before package-name `allowBuilds` entries can approve lifecycle scripts for git, git-hosted tarball, direct tarball, and local directory artifacts. To approve one of those artifacts explicitly, use its peer-suffix-free lockfile depPath as the `allowBuilds` key. Lockfile verification now rejects lockfiles where a registry-style dependency path (`name@semver`) is backed by a git, directory, or git-hosted tarball resolution (`ERR_PNPM_RESOLUTION_SHAPE_MISMATCH`), so the dependency path is a reliable artifact identity by the time scripts can run. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,6 +47,7 @@ test('rebuilds dependencies', async () => { | |
| '@pnpm.e2e/[email protected]', | ||
| 'test-git-fetch@https://codeload.github.com/pnpm/test-git-fetch/tar.gz/8b333f12d5357f4f25a654c305c826294cb073bf', | ||
| ]) | ||
| const gitDepPath = modules!.pendingBuilds[1] | ||
|
|
||
| const modulesManifest = project.readModulesManifest() | ||
| await rebuild.handler({ | ||
|
|
@@ -56,7 +57,7 @@ test('rebuilds dependencies', async () => { | |
| pending: false, | ||
| registries: modulesManifest!.registries!, | ||
| storeDir, | ||
| allowBuilds: { '@pnpm.e2e/pre-and-postinstall-scripts-example': true, 'test-git-fetch': true }, | ||
| allowBuilds: { '@pnpm.e2e/pre-and-postinstall-scripts-example': true, [gitDepPath]: true }, | ||
| }, []) | ||
|
|
||
| modules = project.readModulesManifest() | ||
|
|
@@ -329,14 +330,15 @@ test('rebuilds specific dependencies', async () => { | |
| ]) | ||
|
|
||
| const modulesManifest = project.readModulesManifest() | ||
| const gitDepPath = modulesManifest!.pendingBuilds.find((depPath) => depPath.startsWith('install-scripts-example-for-pnpm@'))! | ||
| await rebuild.handler({ | ||
| ...DEFAULT_OPTS, | ||
| cacheDir, | ||
| dir: process.cwd(), | ||
| pending: false, | ||
| registries: modulesManifest!.registries!, | ||
| storeDir, | ||
| allowBuilds: { 'install-scripts-example-for-pnpm': true }, | ||
| allowBuilds: { [gitDepPath]: true }, | ||
| }, ['install-scripts-example-for-pnpm']) | ||
|
|
||
| project.hasNot('@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-preinstall') | ||
|
|
@@ -382,6 +384,7 @@ test('rebuild with pending option', async () => { | |
| // not to | ||
| // install-scripts-example-for-pnpm@https://codeload.github.com/pnpm-e2e/install-scripts-example/tar.gz/b6cfdb8af6f8d5ebc5e7de6831af9d38084d765b | ||
| expect(modules!.pendingBuilds[1]).toMatch(/^install-scripts-example-for-pnpm@.*b6cfdb8af6f8d5ebc5e7de6831af9d38084d765b.*/) | ||
| const gitDepPath = modules!.pendingBuilds[1] | ||
|
|
||
| project.hasNot('@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-preinstall') | ||
| project.hasNot('@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-postinstall') | ||
|
|
@@ -396,7 +399,7 @@ test('rebuild with pending option', async () => { | |
| pending: true, | ||
| registries: modules!.registries!, | ||
| storeDir, | ||
| allowBuilds: { '@pnpm.e2e/pre-and-postinstall-scripts-example': true, 'install-scripts-example-for-pnpm': true }, | ||
| allowBuilds: { '@pnpm.e2e/pre-and-postinstall-scripts-example': true, [gitDepPath]: true }, | ||
| }, []) | ||
|
|
||
| modules = project.readModulesManifest() | ||
|
|
@@ -538,3 +541,47 @@ test(`rebuild should not fail on incomplete ${WANTED_LOCKFILE}`, async () => { | |
| }, []) | ||
| }) | ||
|
|
||
| test('rebuilds in the global virtual store when the approval was granted after the install', async () => { | ||
| const project = prepare() | ||
| const cacheDir = path.resolve('cache') | ||
| const storeDir = path.resolve('store') | ||
|
|
||
| // No allowBuilds at install time: the GVS projection is created under the | ||
| // not-built hash. The approval arrives only at rebuild time, so the rebuild | ||
| // recomputes a different (built) hash and must locate the existing | ||
| // projection through the project's node_modules link. | ||
| fs.writeFileSync('pnpm-workspace.yaml', [ | ||
| 'enableGlobalVirtualStore: true', | ||
| '', | ||
| ].join('\n')) | ||
|
|
||
| await execa('node', [ | ||
| pnpmBin, | ||
| 'add', | ||
| '--save-dev', | ||
| '@pnpm.e2e/[email protected]', | ||
| `--registry=${REGISTRY}`, | ||
| `--store-dir=${storeDir}`, | ||
| '--ignore-scripts', | ||
| `--cache-dir=${cacheDir}`, | ||
| ]) | ||
|
|
||
| const pkgVersionDir = path.join(storeDir, STORE_VERSION, 'links/@pnpm.e2e/pre-and-postinstall-scripts-example/1.0.0') | ||
| const hash = fs.readdirSync(pkgVersionDir)[0] | ||
| const pkgInGvs = path.join(pkgVersionDir, hash, 'node_modules/@pnpm.e2e/pre-and-postinstall-scripts-example') | ||
| expect(fs.existsSync(path.join(pkgInGvs, 'generated-by-postinstall.js'))).toBeFalsy() | ||
|
|
||
| const modulesManifest = project.readModulesManifest() | ||
| await rebuild.handler({ | ||
| ...DEFAULT_OPTS, | ||
| cacheDir, | ||
| dir: process.cwd(), | ||
| enableGlobalVirtualStore: true, | ||
| pending: false, | ||
| registries: modulesManifest!.registries!, | ||
| storeDir, | ||
| allowBuilds: { '@pnpm.e2e/pre-and-postinstall-scripts-example': true }, | ||
| }, []) | ||
|
|
||
| expect(fs.existsSync(path.join(pkgInGvs, 'generated-by-postinstall.js'))).toBeTruthy() | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,6 +86,9 @@ | |
| }, | ||
| { | ||
| "path": "../after-install" | ||
| }, | ||
| { | ||
| "path": "../policy" | ||
| } | ||
| ] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.