Repository navigation
feat(prebuilt): streaming integrity-checked archive extraction - #2176
Merged
Merged
Conversation
Unit 8 of #1882. `prebuilt::extract` turns a verified `Artifact` into a tree in a single pass: the descriptor's exact size and SHA-256 are recomputed over the compressed stream while the tar entries are decompressed, so a body swapped after the fetch ladder verified it cannot land. Layout rules: `.tar.zst` only, relative paths of ordinary components only, regular files and directories only — absolute names, `..`, symlinks, hard links and device entries are refused, so an archive cannot write outside its root. Decompressed size and entry count are bounded so a few-KiB archive cannot fill the disk. Commit rules: extraction goes into a sibling staging directory and is moved into place only after the completion marker is written, so a killed process leaves either a complete tree or nothing claimable. A destination carrying a matching marker is reused without re-reading the archive; a destination holding anything else is refused rather than merged into (eviction is the GC/LRU cell). `extract_async` runs the blocking pass on its own thread for daemon callers. Tests: 12 new real tar.zst fixtures. RED proven by mutation twice: disabling the digest comparison fails `a_replaced_body_fails_the_descriptor_check` (11 pass / 1 fail), and allowing `ParentDir` fails `parent_traversal_is_refused` (11 pass / 1 fail); both restored green at 30/30 prebuilt, 347/347 crate lib. #1882 stays open (remaining cells: staging/partial GC, disk-cache LRU, BuildRequest field, bucket key, daemon-wide single-flight).
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Nov 24, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Nov 24, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Nov 24, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Nov 25, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Nov 25, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Nov 25, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Nov 25, 2026
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.
What
Unit 8 of #1882:
prebuilt::extractturns a verifiedArtifactinto a tree in one pass, verifying the descriptor while it decompresses..tar.zstonly; anything else isUnsupported, never guessed by extensionsize_bytesand SHA-256 are recomputed over the compressed stream during extraction; a body swapped after the fetcher verified it is refused.., symlinks, hard links, devices and fifos are refusedMAX_EXTRACTED_BYTES, 16 GiB) and entry count (200 000) are capped, so a small archive cannot fill the diskextract_asyncruns the blocking pass on its own thread for daemon callers.Why this shape
The fetcher already returns an immutable
Artifact; extraction is the only other place a bucket object can influence the disk, so it is the only other place that must re-prove identity. Doing that in the same pass keeps the 60 MB read count at one and means acargobuild never starts from a tree whose bytes were never checked.Tests (real output)
12 new
extract_tests.rsfixtures build real.tar.zstarchives in a tempdir: layout, marker reuse with the archive deleted, flipped body, replaced-but-valid body, truncated body,.., absolute name, symlink, occupied destination, empty destination, size ceiling, wrong extension.RED proven by mutation, twice, restored green after each:
a_replaced_body_fails_the_descriptor_checkFAILED (11 pass / 1 fail);Component::ParentDir→parent_traversal_is_refusedFAILED (11 pass / 1 fail).Gates I could not run
soldr cargo clippy -p fbuild-packages-fetch --all-targets -- -D warningscould not acquire the build lease (root-maintenance.lock, 30 s bound) — a sibling agent's gate held it across three attempts, so CI'slinux / Checkis the equivalent. The earlier cold-build attempts also hit the documented runner-daemon flake (broker first-response deadline exceeded), not a compile error.#1882 stays open (remaining cells: staging/partial GC, disk-cache LRU, the
BuildRequestfield, the bucket key, daemon-wide single-flight).