Repository navigation
Publish PR builds from validated, extracted files - #65550
Merged
Jake Bailey (jakebailey) merged 5 commits intoNov 17, 2026
Merged
Jake Bailey (jakebailey) merged 5 commits into
Jake Bailey (jakebailey) merged 5 commits into
Conversation
The PR build validator inspected each tarball through GNU tar, but npm publish read the original tarball with its own tar parser, and the two do not always agree on an archive's contents. Reading paths from the human-readable tar listing was also fragile, for example with owner names that contain spaces. Extract each tarball once, validate the extracted files, and publish that directory so that npm publishes exactly the files that were validated.
Rejecting a fixed list of fields still allowed others that npm acts on
during installation, such as "directories": { "bin": ... }. Allow only
the fields the packages use.
set -e does not see the exit status of a process substitution, so the step kept running after a validation failure and stopped only later because no packages were listed.
npm publish parses some paths, such as those containing "@" and ":", as git URLs. Name the extraction directories by index instead.
Loose equality accepted values such as a null bin, and the version pattern accepted leading zeros, which npm removes when publishing.
Jake Bailey (jakebailey)
requested a review
from Ryan Cavanaugh (RyanCavanaugh)
November 17, 2026 18:31
Ryan Cavanaugh (RyanCavanaugh)
approved these changes
Nov 17, 2026
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The publish workflow can accept a platform package whose npm pack rules exclude the compiler, resulting in a broken published package.
1 open issue
What changed in this PR
Hardens PR-build publishing by validating extracted package directories and publishing from those directories instead of downloaded tarballs.
Changes:
- Extract archives into an empty staging directory and validate file types, package metadata, and version formats.
- Restrict manifest fields to an explicit allowlist.
- Stop publishing on validation failures and disable npm lifecycle scripts.
| File | Description |
|---|---|
tools/scripts/validate-pr-build.mjs |
Extracts and validates package trees, then outputs directories in publish order. |
.github/workflows/pr-build.yml |
Stages extracted packages, propagates validation failures, and publishes directories with scripts disabled. |
Review effort: Balanced
Comment on lines
+251
to
253
| for packageDir in "${toPublish[@]}"; do | ||
| npm publish "$packageDir" --access public --tag pr --ignore-scripts | ||
| done |
Member
Author
There was a problem hiding this comment.
No, all this can break is to make the published thing broken, not contain anything weird.
And again, this is belt and suspenders, if we are running this, we already trust it
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

This is a bit belt-and-suspenders as we only
pack thison trusted PRs, but these are not unreasonable as a matter of correctness.