install: pin a computed sha512 for npm packages whose manifest has no usable integrity#31327
Conversation
|
Updated 8:05 PM PT - May 28th, 2026
✅ @Jarred-Sumner, your commit f3fe5f616847638ea4cf639745e60978213c2b44 passed in 🧪 To try this PR locally: bunx bun-pr 31327That installs a local version of the PR into your bun-31327 --bun |
|
Found 1 issue this PR may fix:
🤖 Generated with Claude Code |
|
Warning Review limit reached
More reviews will be available in 37 minutes and 51 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughBun now computes and persists integrity checksums for npm registry tarballs that lack usable integrity metadata. The implementation integrates npm packages into the existing tarball extraction and streaming integrity pipeline, enabling sha512 fallback computation and lockfile pinning similar to GitHub and remote tarball sources. ChangesNPM Tarball Integrity Pinning
Possibly related issues
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test/cli/install/bun-install-tarball-integrity.test.ts`:
- Around line 651-660: Replace the manual for (...) loop that generates the
it(...) cases with a Jest parameterized block using describe.each([...]) so the
integrity matrix uses the repository's test convention; take the existing array
of tuples (label, dist, extraEnv) currently iterated in the for loop and pass it
into describe.each, move the it(...) body inside the describe.each callback, use
the label for the test name interpolation (e.g. `(${label})`), and preserve the
tuple names so the test still references dist and extraEnv in the same way as in
the original test function.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: fd40f88a-1c24-408d-ab2c-7f8df1cffc9b
📒 Files selected for processing (4)
src/install/PackageManager/processDependencyList.rssrc/install/TarballStream.rssrc/install/extract_tarball.rstest/cli/install/bun-install-tarball-integrity.test.ts
There was a problem hiding this comment.
I didn't find correctness bugs, but this changes integrity-verification and lockfile write-back behavior for npm packages in bun install (security-adjacent), so it's worth a human look — note also the build-rust CI failures on aarch64-musl and FreeBSD.
Extended reasoning...
Overview
This PR extends the existing SHA-512 fallback (already applied to GitHub / remote / local tarballs) to npm registry packages whose manifest dist.integrity is missing, uses an unsupported algorithm, or is malformed. It touches three Rust files in src/install/ (extract_tarball.rs, TarballStream.rs, PackageManager/processDependencyList.rs) plus ~210 lines of new tests. The Rust changes are small and closely mirror the existing arms for other resolution tags; the new write-back in process_extracted_tarball_package only fires when resolution.tag == Npm, package_id is valid, the extract produced a supported digest, and the lockfile entry's existing integrity is not already supported.
Security risks
This is squarely in security-sensitive territory: it governs whether and how downloaded package bytes are pinned and verified. The change is additive (it adds verification where there was previously none) and is guarded so it never overwrites an existing supported integrity, and it respects --no-verify. I don't see a way it weakens verification, but because it alters the trust/verification surface for the most common dependency source (npm registry), a human should confirm the semantics — particularly the resolve-phase write-back into lockfile.packages[...].meta.integrity and its interaction with lockfile dirty/re-save logic.
Level of scrutiny
High. bun install integrity verification and lockfile persistence are production-critical, supply-chain-relevant paths. Even though the diff is mechanically simple (adding ResolutionTag::Npm to existing match arms), the behavioral implications (every npm package without usable integrity now gets a computed pin) and the new mutation site in processDependencyList.rs warrant maintainer review.
Other factors
- CI (robobun) reports build-rust failures on aarch64-musl and FreeBSD x64 for commit 7459f19; an autofix commit followed but the status comment still shows red.
- Good test coverage added: parametrized over unsupported-algorithm / malformed-base64 / streaming-extractor variants, plus a no-resave-on-second-install check.
- CodeRabbit's only comment is a stylistic nit (
describe.eachvsforloop) — not blocking. - No CODEOWNERS entry for
src/install/.
There was a problem hiding this comment.
No issues found, but this changes integrity-pinning semantics for npm registry packages (a supply-chain security path) and writes back into lockfile package metadata, so it's worth a human look.
Extended reasoning...
Overview
This PR extends the existing SHA-512 fallback (already applied to GitHub/remote/local tarballs) to npm registry packages whose manifest dist.integrity is missing, uses an unsupported algorithm, or fails to parse. It touches three Rust files in src/install/ (the buffered extractor, the streaming extractor, and the resolve-phase lockfile write-back) plus adds ~210 lines of tests. The core change is small (~30 lines) and mechanically mirrors the adjacent Github | RemoteTarball | LocalTarball arms.
Security risks
This is a supply-chain security path: it introduces TOFU pinning for npm packages that previously went permanently unverified. The change is strictly additive (it only writes a computed integrity when !meta.integrity.tag.is_supported(), never overwriting a registry-provided value) and respects --no-verify. I see no way it weakens existing verification, but because it changes when/how integrity is recorded and later enforced for the most common package source, it deserves human sign-off.
Level of scrutiny
Medium-high. The diff is small and pattern-following, but integrity verification and lockfile persistence are correctness-critical. Subtle issues (e.g., the resolve-phase write-back interacting with lockfile dirtying/re-save, or the package_id != INVALID_PACKAGE_ID guard) are the kind of thing a maintainer familiar with the install pipeline should confirm.
Other factors
Test coverage is solid: it exercises both buffered and streaming extractors, verifies swap detection on reinstall, and asserts the lockfile is not re-saved on a second install. The one CodeRabbit comment (style nit on for vs describe.each) was reasonably declined and resolved. No CODEOWNERS apply to these files.
… usable integrity When a registry manifest's dist.integrity is missing, uses an unsupported algorithm, or fails to parse (and there is no shasum), npm packages were recorded in the lockfile with an empty integrity and never verified on any install. Extend the existing GitHub/remote/local tarball fallback to npm: compute a SHA-512 of the downloaded tarball and persist it into the lockfile during the resolve phase, so the first install's lockfile already carries the pin and subsequent installs verify against it. Skipped under --no-verify. Adds tests covering the pin being recorded for unparseable manifest integrity (buffered and streaming extract paths), a swapped tarball being rejected on reinstall, and the lockfile not being re-saved on a second install.
77035b5 to
f3fe5f6
Compare
|
Classified build #57590: the two failing checks are |
There was a problem hiding this comment.
I didn't find any issues, but this changes integrity-verification and lockfile-persistence behavior for the most common package type (npm registry), so it's worth a human sign-off on the TOFU-pinning semantics.
Extended reasoning...
Overview
This PR extends the existing SHA-512 fallback (already applied to GitHub/remote/local tarballs) to npm registry packages whose manifest dist.integrity is missing, uses an unsupported algorithm, or is malformed. Three small Rust hunks:
extract_tarball.rs(~10 lines): adds aResolutionTag::Npmarm mirroring the existing GitHub/remote/local arm, guarded by!self.skip_verify.TarballStream.rs(~6 lines): includes Npm incompute_if_missing(when notskip_verify) and in thepopulate_resultintegrity match.processDependencyList.rs(~13 lines): after extract, writes the computed integrity back intolockfile.packages[id].meta.integrityonly when the existing value is unsupported.
Plus ~210 lines of new end-to-end tests covering buffered + streaming paths, swap detection on reinstall, and no-resave on a second install.
Security risks
This is security-relevant code — package integrity verification — but the change strengthens it (TOFU pinning where previously there was none). The write-back is guarded by !meta.integrity.tag.is_supported(), so a registry-provided integrity is never overwritten. --no-verify opts out, matching the existing contract. I don't see a way this weakens verification; the risk surface is a wrong hash being pinned (causing spurious failures on reinstall) or unintended lockfile churn, both of which the new tests cover.
Level of scrutiny
Medium-high. The diff is small and mechanically extends an established pattern, but it changes user-visible lockfile behavior for the dominant resolution type and lives on the integrity-verification path that every bun install exercises. A human should confirm the design decision (TOFU pinning for npm packages whose manifest integrity is unusable) and that the resolve-phase write-back into lockfile.packages composes correctly with later lockfile serialization / dirty-tracking.
Other factors
- Bug-hunting system found nothing; the only review feedback was a CodeRabbit style nit (for-loop vs describe.each) that the author reasonably declined.
- No CODEOWNERS coverage for
src/install/. - Author reports the new tests pass locally on the rebased branch and fail under
USE_SYSTEM_BUN=1as expected; CI build #58769 was still running at the time of the last timeline update.
When a registry manifest's
dist.integrityis missing, uses an unsupported algorithm, or fails to parse (and there is noshasum), npm packages were recorded in the lockfile with an empty integrity and never verified on any install. This extends the existing GitHub/remote/local tarball fallback to npm registry packages: compute a SHA-512 of the downloaded tarball and persist it into the lockfile during the resolve phase, so the first install's lockfile already carries the pin and every subsequent install verifies against it. The fallback is skipped under--no-verify.Covers both the buffered and streaming extract paths. The resolve-phase write-back means the pin lands in the lockfile on the first install, so a second install of an unchanged project does not re-save the lockfile.
Tests added to
test/cli/install/bun-install-tarball-integrity.test.ts: the pin is recorded when the manifest integrity is unparseable (unsupported algorithm and malformed base64, buffered and streaming), a swapped tarball is rejected on reinstall, and the lockfile is not re-saved on a second install when the registry provides no integrity metadata.