Repository navigation
feat(artifacts): inventory and extract stored and gzip-compressed tar archives - #14245
Conversation
… archives Recognize POSIX ustar and GNU tar headers, plain or as the first block of a gzip member, as the new tar artifact format, so Linux release tarballs and Unity .unitypackage files inventory and extract like ZIP archives. The tar reader walks every header once, applying pax path, linkpath and size records, GNU long names and the ustar prefix. Regular files, directories and symlinks are occurrences with typeflag, mode, owner, mtime and link target; devices, FIFOs, hard links and sparse members are traversal omissions. Gzip members are read by forward decompression with an idle stream reused for in-order opens, and every decompressed byte is charged to artifact_limits.expanded_bytes. A later corrupt header, a truncated member or gzip stream, and non-zero bytes after the end marker keep the members read so far with unknown coverage and an explicit end_state; a first block with the ustar magic and a bad checksum is refused with that reason. Fixes #14177
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
[Medium impact] The reviewed changes appear safe to merge; all three numbered findings are addressed. SummaryAdds stored and gzip-compressed tar inventory and extraction, including member metadata and partial coverage for damaged archives.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[Archive bytes] --> B[Recognize tar]
B --> C{Compression}
C -->|Stored| D[Read carrier ranges]
C -->|Gzip| E[Read decompressed bytes]
D --> F[Walk headers and record coverage]
E --> F
F --> G[Inventory and hash members]
G --> H[Extract selected files safely]
Reviews (10) · Last reviewed commit: "fix(tar): enforce stored-read budget, de..." · Reviewed by Greptile |
- Charge omitted devices, FIFOs and links to the retained-metadata allowance. - Probe a small gzip tar without verifying its trailer, and feed the final trailer to zlib separately so data before a bad CRC stays readable; queue decompressed output so a later failure cannot drop it. - Decode negative GNU base-256 numbers; only mtime may be negative. - Apply pending pax records only to the next member, never to extension headers, and let an empty pax value delete the keyword. - Push a member once its data is complete, then skip its padding. - Treat a cut-off zero block as truncation, not an end marker. - Stop with malformed partial coverage, not a refusal, when a later header declares an unsafe size.
The decompressed-output queue charged the plaintext-work allowance only when the reader took a chunk, so bytes queued for an idle reader were not bounded by artifact_limits.expanded_bytes. Each chunk is now charged in the data handler before it is queued; an exhausted allowance stops the inflater, and the queued, already-charged bytes are served before the limit failure.
… fields - A pax size, uid, gid or mtime record that does not parse now stops the walk as malformed at that member, keeping earlier members, instead of silently falling back to the header field. - The gzip-wrapped tar probe skips the RFC 1952 FEXTRA, FNAME, FCOMMENT and FHCRC fields before applying its 2 KiB compressed-data bound, so a long name or comment no longer hides the archive.
# Conflicts: # docs/.vitepress/documentation.ts # docs/README.md # docs/reference/supported-targets.md # src/application/binary/TargetFormatVocabularies.test.ts # src/artifacts/artifactFormats.ts # src/domain/artifactFormatRecognition.ts # src/domain/artifactGraph.ts # src/domain/targetFormats.ts # src/resources/ArtifactReader.ts # tests/boundary/filesystem/binaryTarget.test.ts
…eilings as pending #14236
…nour cancellation in gzip waits - An old GNU sparse header (typeflag S) can continue its sparse map in 512-byte extension blocks before the stored data; they are now skipped so the next header stays aligned. The member is still an omission. - The non-UTF-8 name fallback decodes each byte as its own code point. The WHATWG latin1 label is Windows-1252 and rewrote bytes 0x80-0x9f. - A gzip read waiting for decompressed output now wakes on cancellation and raises it, rather than waiting for output or the end of input.
Fixes #14177
What changes
inspect-artifactandextract-artifactnow read POSIX tar archives, stored or gzip-compressed, as a newtarartifact format (archivetarget kind). This covers Linux release tarballs and Unity.unitypackagefiles. Before this change, both were refused asfile_format_rejected/ "unsupported binary format".src/domain/tarFormat.ts, shared recognizer table): a checksum-valid ustar or GNU header at offset 0, or a gzip member whose first decompressed block is one. The gzip probe inflates at most 2 KiB of input with a 4 MiB output cap. A plain gzip stream that is not tar is not claimed. A first block that carries the ustar magic but fails its checksum isrefusedwith the reason ("tar first header checksum does not match").src/artifacts/tar/TarWalk.ts): headers are read once and member data is skipped. Paxpath,linkpath,size,uid,gid,uname,gnameandmtimerecords apply (local and global), as do GNUL/Klong names and the ustar prefix. Regular files, directories and symlinks become occurrences. Character and block devices, FIFOs, hard links, sparse members and vendor typeflags are reported as traversal omissions. The./root and GNU volume labels carry no occurrence. A leading./is dropped and kept insource_path, as for ZIP.src/artifacts/tar/TarArtifactReader.ts): stored members are carrier ranges with a realsource_location. Gzip members are read by forward decompression. An idle decompression is kept, so in-order opens (the inventory scan) cost one pass. An out-of-order open starts a fresh one.format_metadatakind: "tar"records compression, dialects, pax header count, member count, tar-stream bytes,end_state,end_offsetand trailing non-zero bytes. Each member haskind: "tar-entry"with its offsets, typeflag, mode, owner, mtime and link target.compare-artifactscompares typeflag, mode and link target.Unrecognised, malformed and truncated stay distinct
ParseFailurewithoffset: 0).unknown, andend_state/end_offsetrecord the reason.completeonly when the walk reaches the end-of-archive marker and only zeros follow it.#14239 note: the failure model (
TargetFailure) has not landed yet, so the new failures stay minimal and use the existingParseFailure/ArtifactReaderFailureandfile_format_rejectedpaths. #14239 migrates them.Bounds
artifact_limits.expanded_bytes(shared default: max(256 MiB, 500 times the file size)). This includes preparation and each member decompression, and usesBudget.Tests
src/artifacts/tar/TarArtifactReader.test.ts(19 tests), each run for stored and gzip archives where it applies:tests/boundary/filesystem/binaryTarget.test.ts:.tarand.unitypackageresolve to thearchive/tartarget, plain gzip stays unsupported, and a corrupt checksum is refused with its reason.tests/acceptance/tarArchiveCli.test.ts: compiled CLI inventory and extraction for.tarand.tar.gz, a truncated archive giving partial coverage, and a malformed first header.tests/boundary/mcp/tarArchiveMcp.test.ts: MCP summary, aninspect_analysis_viewpage of one member, and extraction.Validation
npx vitest runover the tar, target, vocabulary, format-recognition, inventory and analysis-view tests: 119 files, 2426 passed.tscover the changed modules and tests: clean.oxfmt,oxlint(no errors) andarchitecture-guards.mjs: pass.Real public files (downloaded to a scratch directory, never executed)
Orama-Interactive/Pixeloramav1.2.4Pixelorama-Linux-64bit.tar.gz692473e4…c568e0btar/gzip/GNU, 39 members,complete.Pixelorama.x86_64is classifiedelfandPixelorama.pckis classifiedgodot-pck. 1.07 s, 244 MB peak RSSvrm-c/UniVRMv0.131.4UniVRM-0.131.4_efd2.unitypackage3f0e7349…2730c445atar/gzip/GNU, 3,091 members (the count the issue reports),complete. 0.33 sRemaining
walkTarfunction is long and trips the complexity lint warnings. No lint errors..unitypackagepathname→ GUID projection; pre-POSIX v7 headers; hard-link content.