Limit archive entry counts - #34
Open
andrew wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a hard cap on the number of entries an archive can contain (default 100,000) to mitigate resource-exhaustion cases across supported archive formats.
Changes:
- Introduces a shared entry-count limit (
maxArchiveEntries) and a common validation helper (checkArchiveEntryCount) with a new sentinel error (ErrEntryLimit). - Enforces the limit in TAR and GEM while streaming headers, and in ZIP and CONDA based on their indexed entries (with CONDA also enforcing a cumulative limit across members).
- Adds test coverage to ensure TAR/ZIP/GEM/CONDA reject archives that exceed the configured entry-count limit.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| zip.go | Rejects ZIP archives whose central directory contains too many entries. |
| tar.go | Adds entry-count limit constants/error and enforces the limit while reading TAR headers. |
| gem.go | Tracks and enforces entry count while scanning the outer GEM tar for data.tar.gz. |
| conda.go | Enforces entry-count limits on the outer CONDA zip and cumulatively across member tarballs. |
| conda_test.go | Adds a test verifying CONDA rejects too many combined entries across members. |
| archives_test.go | Adds tests verifying TAR/ZIP/GEM reject archives with too many entries. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+129
to
+134
| func checkArchiveEntryCount(count int) error { | ||
| if count > maxArchiveEntries { | ||
| return fmt.Errorf("%w: %d entries exceeds %d", ErrEntryLimit, count, maxArchiveEntries) | ||
| } | ||
| return nil | ||
| } |
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.
Reject archives containing more than 100,000 entries. TAR and gem readers enforce the limit as headers are read, while ZIP and conda readers check their indexed entries. Conda also checks the combined entries across members.