Skip to content

fix(js): preserve npm allowScripts allowlist in pruned package.json#36016

Open
leosvelperez wants to merge 1 commit into
masterfrom
gh-35931
Open

fix(js): preserve npm allowScripts allowlist in pruned package.json#36016
leosvelperez wants to merge 1 commit into
masterfrom
gh-35931

Conversation

@leosvelperez

@leosvelperez leosvelperez commented Jun 17, 2026

Copy link
Copy Markdown
Member

Current Behavior

@nx/js:prune-lockfile builds the generated package.json from only the project package.json. The npm allowScripts install-script allowlist lives at the workspace root (npm's approve-scripts is workspace-unaware and writes it there), so it never reached the pruned output. Running npm ci against the pruned artifact then executed install scripts the developer had reviewed and gated, and once npm enforces the allowlist a previously approved script would instead be blocked.

Expected Behavior

The pruned package.json carries the root allowScripts policy, merged with any project-level entries (project entries win on conflict). This mirrors how createPackageJson already copies the root pnpm.allowBuilds build-script allowlist into generated package.json files.

Related Issue(s)

Fixes #35931


View session information ↗

@netlify

netlify Bot commented Jun 17, 2026

Copy link
Copy Markdown

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit e7a32b3
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/6a325efbecf1df0008f38526
😎 Deploy Preview https://deploy-preview-36016--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Jun 17, 2026

Copy link
Copy Markdown

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit e7a32b3
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/6a325efbf3b8d00008e2b709
😎 Deploy Preview https://deploy-preview-36016--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nx-cloud

nx-cloud Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit e7a32b3

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 41m 55s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 3s View ↗
nx-cloud record -- pnpm nx-cloud conformance:check ✅ Succeeded 1m View ↗
nx build workspace-plugin ✅ Succeeded <1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 17s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 5s View ↗

☁️ Nx Cloud last updated this comment at 2026-06-17 09:33:10 UTC

@leosvelperez leosvelperez self-assigned this Jun 17, 2026
The @nx/js:prune-lockfile executor built its output package.json from
only the project package.json, so the npm `allowScripts` install-script
allowlist (which `npm approve-scripts` writes to the workspace root) was
dropped from the pruned output. `npm ci` in the deployed artifact then
ran install scripts the allowlist was meant to gate, and under npm's
upcoming strict mode an approved script would instead be blocked.

Carry the root `allowScripts` into the pruned package.json, with any
project-level entries preserved and winning on conflict. This mirrors the
existing `pnpm.allowBuilds` handling in createPackageJson.
@leosvelperez leosvelperez marked this pull request as ready for review June 17, 2026 10:09
@leosvelperez leosvelperez requested a review from a team as a code owner June 17, 2026 10:09
@leosvelperez leosvelperez requested a review from lourw June 17, 2026 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[security issue] @nx/js:prune-lockfile should include allowScripts in generated package.json

1 participant