Skip to content

feat(artifacts): recognize Zip64 archives after leading bytes - #14105

Merged
morluto merged 3 commits into
morluto:mainfrom
Afloat16:feat/zip64-leading-archive-20261123
Nov 27, 2026
Merged

morluto merged 3 commits into
morluto:mainfrom
Afloat16:feat/zip64-leading-archive-20261123

Conversation

@Afloat16

@Afloat16 Afloat16 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Recognize nonempty single-volume Zip64 archives after an unclaimed leading prefix. These archives already work through the ZIP reader, but the shared root probe only interprets classic end records. A launch-script prefix therefore makes inspection and extraction reject the entire Zip64 input.

This extends the passive root-admission behavior introduced by #5803. It consumes the shared Zip64 framing facts from #12157; the desktop end-record changes in #9173/#10618 address a different consumer.

Problem and expected behavior

With the locked ZIP writer, a two-member Zip64 archive is 456 bytes. Prepending a 17-byte inert shell stub makes the original root classifier return file, target parsing reject it, and the compiled inspect-artifact command return target_unavailable / unsupported_target. The same plain Zip64 archive and the prefixed classic control are readable.

The change admits the original prefixed bytes as ZIP, preserves their complete root digest, and exposes the same verified member contents. The prefix continues to appear in the inventory's unaccounted-byte limitation, with coverage.status: "unknown".

Change and scope

  • Resolve classic or Zip64 directory placement through the existing end-record, locator and single-volume owners.
  • Check a Zip64 frame at its declared address, then retain the fixed-record fallback for an unchanged archive after a prefix. Only fixed framing fields are read; the extension and directory are not allocated as part of recognition.
  • Keep sizes and offsets as bigint until they fit the observed file regions. Resolve a deferred first-member offset from its conditional Zip64 extra field before applying the prefix shift.
  • Preserve first-directory/local-header bounds, false-EOCD comment handling and the existing native executable routes. Share the Zip64 extra-field identifier with member-region accounting.

Contribution scope: ordinary passive archive inspection within the existing boundaries; a separate advance provider/execution scope decision is not applicable. No separate issue was opened because the patch extends the existing archive-admission owner and includes a producer-based regression for the concrete refusal.

Contract and boundary impact

  • Semantic owner: hasTrailingZipArchive, shared by target admission and root inventory classification. Existing ZIP framing owners supply the parsed facts.

  • CLI/MCP: existing inspection and extraction schemas; no new operation or input.

  • Evidence/provenance: complete original root identity and member identities; leading bytes remain explicitly outside member coverage.

  • Authority and cleanup: selected files are read; extraction writes only its selected output. Tests close the active MCP target and remove materialized test output. The prefix is never executed.

  • Package/installation: no dependency, package version, installer or generated catalog change.

  • Read existing files or captured data.

  • Change process memory, registers, files, or configuration.

Evidence and regression coverage

The original compiled CLI regression is 1 failed / 1 passed: prefixed Zip64 is refused while the classic control inspects and extracts successfully.

The final public workflow tests both formats through the compiled CLI and a real stdio MCP session (open_binary, inspection, extraction and close). Each returns the two exact member contents, retains the original root SHA-256 and unknown prefix coverage, and leaves the source bytes unchanged.

Sixteen new boundary cases cover adjusted and unadjusted offsets, a 64-bit first-member offset, an adjusted extensible end record, the maximum ZIP comment with a false EOCD, split-volume claims, inconsistent counts, invalid frame extents, and missing/out-of-range wide offsets. Existing native routing, classic corruption and member-accounting controls also pass.

Five producer-based wire variants were independently read and CRC-checked by Python zipfile. Info-ZIP tested both member contents in all five: adjusted variants exited 0; the two relative-offset variants exited 1 with the expected 17-byte prefix warning and successful member checks. The extended fixture uses a short framed unknown extension accepted by the existing ZIP reader.

Remaining coverage: no physical archive over 4 GiB or native Windows/macOS run. A variable-size Zip64 end record whose pointer was left unadjusted by a prepended prefix remains outside the fixed-record fallback.

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

Node 24.22.3 and npm 11.19.1 on Linux.

  • npm run test:focused -- tests/acceptance/artifactZipLeadingBytes.test.ts tests/boundary/filesystem/zip64LeadingBytes.test.ts tests/boundary/filesystem/zipDetection.test.ts src/domain/zipPackageFormat.test.ts src/artifacts/ZipMemberRegion.test.ts src/domain/zipEndOfCentralDirectory.test.ts — 90 passed.
  • npm run docs:check — passed, including 8 README consistency tests.
  • npm run check, with GOMEMLIMIT=512MiB — typecheck, lint, format, Knip, metadata, architecture guards (3,072 source files) and production reachability completed. The final whole-tree typed-lint process received SIGKILL, so the complete gate is not recorded as passing.
  • The repository's typed-lint-changed command over all 7 changed TypeScript files, with the same memory setting — 0 errors, 1 advisory warning.
  • git diff --check — passed.

Compatibility, safety, and release

Existing caller-selected inputs, integrity policy, member budgets and extraction containment continue to apply. This is static ZIP recognition; no native analysis provider, target execution, installer change or breaking schema migration is involved.

Author readiness

Human owner: @Afloat16

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

@greptile-apps

greptile-apps Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · No blocking defects were found; Git history shows this exact change is already on main.RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] No blocking defects were found; Git history shows this exact change is already on main.

Summary

Extends passive ZIP recognition to nonempty, single-volume Zip64 archives after unclaimed leading bytes.

  • Prefixed Zip64 archives now pass the shared ZIP probe.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Unclaimed leading bytes] --> B[Find complete classic end record]
  B --> C{Zip64 locator present?}
  C -->|Yes| D[Try declared record, then fixed fallback]
  C -->|No| E[Use complete classic fields]
  D --> F[Check single-volume claims and directory bounds]
  E --> F
  F --> G[Resolve first member offset]
  G --> H[Check local header before directory]
  H --> I[Recognize original bytes as ZIP]
Loading

Reviews (3) · Last reviewed commit: "test(artifacts): pin the unadjusted Zip6..." · Reviewed by Greptile

@Afloat16
Afloat16 marked this pull request as ready for review November 24, 2026 05:42
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-24T05:42:41.365242Z
We couldn’t complete this review. Comment @codex review to try again.
f1f8b7c Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@morluto morluto added area: evidence Evidence, artifacts, and reconstruction enhancement New feature or request labels Nov 26, 2026
@morluto

morluto commented Nov 27, 2026

Copy link
Copy Markdown
Owner

Maintainer review.

I read the probe against the PKWARE APPNOTE (4.3.14 Zip64 end record, 4.3.15 locator, 4.5.3 extended-information field) and libarchive's seekable reader (archive_read_support_format_zip.c: read_zip64_eocd, and offset correction in slurp_central_directory). Their behavior matches:

  • The 0x0001 field order is uncompressed size, then compressed size, then local-header offset. Each is present only when its 32-bit field holds 0xffffffff.
  • The locator is read at the declared absolute offset. libarchive leaves locating a shifted record as a TODO and corrects offsets later from the directory scan. This PR's fixed-record fallback covers that case up front.

I found no defects in the source. The admission checks run before every read, all reads are bounded (fixed records plus one extra field of at most 65,535 bytes), and conversions from 64-bit to Number happen only after the bounds checks.

Pushed on top of your branch:

  • f64c422d1d: merges current main (the branch was 631 commits behind; no conflicts).
  • 7075ec8704: adds a regression pinning the documented limit. An unadjusted Zip64 record followed by an extensible data sector stays unrecognized, because neither the shifted pointer nor the fixed-size fallback can place it. The probe then leaves the file classified as ordinary bytes instead of guessing.

Validation:

  • zip64LeadingBytes boundary and artifactZipLeadingBytes acceptance tests: 19 passed.
  • zipPackageFormat unit test: passed.
  • check:fast: passed.

@morluto
morluto enabled auto-merge (squash) November 27, 2026 17:44
@morluto
morluto merged commit b14844d into morluto:main Nov 27, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: evidence Evidence, artifacts, and reconstruction enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants