feat(ingest): unpack tar and tar.gz source archives (#335) #340

Merged
sharang merged 1 commits from feat/tar-ingest into main 2026-09-23 13:08:07 +00:00
Owner

Closes #335. Part of the pilot P0 (#338).

Why

Only zip was unpacked. A .tar.gz upload, the usual export from Linux build hosts and git forges, was kept as one opaque file, and the scan still finished as "completed" with nothing analysed.

What

  • ingest/archive.rs (new; zip extraction moved here from blob.rs):
    • Format from content: ArchiveFormat::sniff reads the blob's first bytes: zip, ustar/GNU tar, or a gzip whose content is a tar. A lone gzipped file is not treated as an archive. A gzip that cannot be decoded still counts as tar.gz, so it fails visibly.
    • Same limits for every format: entry count and bytes actually written, as for zip.
    • Hostile entries: absolute paths and .. entries are skipped. Symlinks, hard links, devices and FIFOs are never created.
  • Visible failure:
    • an uploaded source archive that cannot be unpacked is an ingest error;
    • the classification step records it as the ingest skipped stage;
    • the run then fails with "the uploaded archive could not be unpacked…" instead of completing over nothing.
    • PLC projects and mobile packages keep their single-file fallback, so plc-corrupt-archive is unchanged.
  • Wizard label: "Source archive (zip, tar, tar.gz)".
  • Nightly harness: an artifact can say "pack": "tar_gz". The new target archive-order-intake-tgz uploads fixtures/nightly/archive as a .tar.gz.

Verification

  • Unit tests:
    • format sniffing (zip, tar, tar.gz, gzipped non-tar, plain file, empty);
    • tar/tar.gz extract like zip;
    • traversal, absolute and symlink entries are not written;
    • a tar.gz bomb is refused and cleaned up;
    • the entry limit holds in every format;
    • a truncated tar.gz fails;
    • an archive exactly at the limits extracts whole.
  • Full local nightly (bless, then compare on a second fresh DB):
    • passes;
    • the .tar.gz baseline is identical to the zip baseline;
    • no other baseline changed.
  • fmt; clippy with the CI flags.

Touches orchestrator.rs and targets.json like #339. Whichever merges second may need a trivial rebase.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p

Closes #335. Part of the pilot P0 (#338). ## Why Only zip was unpacked. A `.tar.gz` upload, the usual export from Linux build hosts and git forges, was kept as one opaque file, and the scan still finished as "completed" with nothing analysed. ## What - `ingest/archive.rs` (new; zip extraction moved here from `blob.rs`): - **Format from content:** `ArchiveFormat::sniff` reads the blob's first bytes: zip, ustar/GNU tar, or a gzip whose content is a tar. A lone gzipped file is not treated as an archive. A gzip that cannot be decoded still counts as `tar.gz`, so it fails visibly. - **Same limits for every format:** entry count and bytes actually written, as for zip. - **Hostile entries:** absolute paths and `..` entries are skipped. Symlinks, hard links, devices and FIFOs are never created. - **Visible failure:** - an uploaded *source archive* that cannot be unpacked is an ingest error; - the classification step records it as the `ingest` skipped stage; - the run then **fails** with "the uploaded archive could not be unpacked…" instead of completing over nothing. - PLC projects and mobile packages keep their single-file fallback, so `plc-corrupt-archive` is unchanged. - Wizard label: "Source archive (zip, tar, tar.gz)". - Nightly harness: an artifact can say `"pack": "tar_gz"`. The new target `archive-order-intake-tgz` uploads `fixtures/nightly/archive` as a `.tar.gz`. ## Verification - Unit tests: - format sniffing (zip, tar, tar.gz, gzipped non-tar, plain file, empty); - tar/tar.gz extract like zip; - traversal, absolute and symlink entries are not written; - a tar.gz bomb is refused and cleaned up; - the entry limit holds in every format; - a truncated tar.gz fails; - an archive exactly at the limits extracts whole. - Full local nightly (bless, then compare on a second fresh DB): - passes; - the `.tar.gz` baseline is **identical** to the zip baseline; - no other baseline changed. - fmt; clippy with the CI flags. Touches `orchestrator.rs` and `targets.json` like #339. Whichever merges second may need a trivial rebase. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang added 1 commit 2026-09-23 11:05:58 +00:00
feat(ingest): unpack tar and tar.gz source archives (#335)
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 7m26s
499e82bf53
Only zip was unpacked. A .tar.gz upload was kept as one opaque file and
the scan still finished as "completed" with nothing analysed.

- The archive format is read from the blob's first bytes (zip, tar, gzip
  holding a tar); the stored blob has no file name to go by.
- tar and tar.gz are held to the same ExtractLimits as zip (entry count,
  bytes actually written). Entries that would leave the destination are
  skipped, and links, devices and FIFOs are never created.
- An uploaded source archive that cannot be unpacked fails the scan run
  with the reason, and ingest failures are recorded as a skipped stage,
  instead of completing over a tree that was never there. PLC projects and
  mobile packages keep their single-file fallback.
- Zip extraction moved from ingest/blob.rs into ingest/archive.rs.
- Nightly target archive-order-intake-tgz uploads the archive fixture as
  a .tar.gz; its baseline is identical to the zip's.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang merged commit 0e0dfadf56 into main 2026-09-23 13:08:07 +00:00
Sign in to join this conversation.