Skip to content

NuGet: refuse the archives NuGet refuses as split or spanned - #919

Open
schmitch wants to merge 1 commit into
mainfrom
claude/818-nuget-split-archives
Open

schmitch wants to merge 1 commit into
mainfrom
claude/818-nuget-split-archives

Conversation

@schmitch

Copy link
Copy Markdown
Member

Fixes #818

Problem

Forge's own zip reader (crates/formats/nuget/src/nuspec.rs) accepted archives that .NET's ZipArchive refuses with "Split or spanned archives are not supported". Such a package was stored and listed (hosted push, proxy download, import), though no NuGet client installs it.

Change

  • check_eocd_candidate refuses an end record whose disk number (offset 4) differs from the disk where its central directory starts (offset 6), then one whose two entry counts (offsets 8 and 10) differ. Both checks run on the 32-bit record before the ZIP64 records are looked for, in .NET's order (ReadEndOfCentralDirectory).
  • check_zip64_record refuses a ZIP64 record whose total differs from its on-disk count.
  • The optional check is included: a manifest whose central header names another start disk than the archive's is refused, as ZipArchiveEntry.IsOpenable refuses it. The comparison follows .NET (checked against the v9.0.0 sources):
    • the archive's disk number is the end record's, or the ZIP64 record's (offset 16) when there is one;
    • the entry's start disk is the header's (offset 34), or, when that holds 0xFFFF, the one .NET reads from the header's ZIP64 field: after the values the header marks, or at its fixed place from 28 bytes on, and not at all when the field is too short (the 0xFFFF then stands). An archive that is consistently "disk 1" is still read, as .NET reads it.
    • Only the manifest is checked, as the issue asks; other entries are not opened by Forge.

The refusals are InvalidZip errors ending in "split or spanned archives are not supported".

Tests

Next to the_end_record_is_the_one_nuget_reads, one per case:

  • an_end_record_naming_another_disk_for_its_directory_is_refused
  • an_end_record_whose_entry_counts_differ_is_refused
  • a_zip64_record_whose_entry_counts_differ_is_refused
  • a_manifest_that_starts_on_another_disk_is_refused

All four fail against the reader before this change and pass with it.

Checks run

  • cargo test -p forge-format-nuget: passes (63 unit tests and the crate's integration tests)
  • cargo xtask check (cargo fmt --check and clippy with -D warnings, workspace): passes
  • cargo xtask changelog --check: passes

Not run locally: the full workspace tests and the end-to-end suites (they need Docker); CI runs them. No real dotnet restore was run against the crafted archives: .NET's behaviour is taken from its sources.

Changelog and milestone

docs/changes/2.2.0/818.fixed.md. The issue was in Backlog; it is moved to the 2.2.0 milestone, since the fix ships in the next release.

No admin API changes, so no web UI screen.


Generated by Claude Code

Forge's zip reader accepted what .NET's ZipArchive refuses with "Split or
spanned archives are not supported", so such a package was stored and
listed though no NuGet client installs it:

- an end record whose disk number differs from the disk where its central
  directory starts, or whose two entry counts differ (both checked on the
  32-bit record before the ZIP64 ones are looked for, in .NET's order);
- a ZIP64 end record whose total differs from its on-disk count;
- a manifest whose central header names another start disk than the
  archive's (the ZIP64 record's when there is one), read from the header's
  ZIP64 field when the header marks it, as .NET reads it.

Fixes #818

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_012e6DJYq6nQn7DUc2EYRWcf

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants