Repository navigation
Bound ZIP log extraction by total size and entry count - #74906
Conversation
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
|
✅ Ponytail Reviewer completed successfully! Ponytail ReviewerOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ PR Code Quality Reviewer completed the code quality review.
|
Comment MemoryPeek at saved memory (pr-code-quality-reviewer)Note This comment is managed by comment memory.Expand the saved memory block to view or edit the persistent context for this thread.
|
There was a problem hiding this comment.
Review complete: no blocking correctness or security issues found.
Highlights
- Preserve the distinction between per-entry and archive-wide size errors.
- Add coverage for runtime enforcement when ZIP metadata understates extracted bytes.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~2 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review to run again
| return extractErr | ||
| // written == maxSize+1 means the reader was not exhausted, i.e. the | ||
| // actual content is larger than the allowed size. | ||
| if uint64(written) > maxSize { |
There was a problem hiding this comment.
The per-entry limit violation is now reported as a total-archive violation, which misleads callers and breaks the prior error distinction.
💡 Preserve the limit-specific error
extractZipFile passes maxZipEntrySize as maxSize, so an entry whose actual content exceeds 1 GiB reaches this branch and emits file extraction exceeded total uncompressed size limit. Select the message based on whether the per-entry or archive-wide limit is being enforced (or retain the existing per-entry wording) so diagnostics and error matching remain accurate.
| }) | ||
| } | ||
|
|
||
| func TestUnzipFileWithLimits(t *testing.T) { |
There was a problem hiding this comment.
This test only covers the pre-scan based on declared ZIP sizes and does not exercise the runtime byte-counting safeguard this change introduces.
💡 Add an understated-metadata case
Add a case whose declared UncompressedSize64 is below the configured total while the reader produces more bytes, then assert extraction stops with the total-limit error and verify the resulting files. That protects remainingSize accounting and the io.LimitReader enforcement from regressions instead of testing only metadata validation.
🏗️ Design Decision Gate — ADR RequiredThis PR adds a lot of new core business logic (111 new lines in 📄 Draft ADR committed: Decision recorded in the draft: ZIP log extraction now has two archive-wide limits: at most 10,000 entries and at most 1 GiB uncompressed in total. They are checked twice: once from the archive metadata before anything is written, and again by counting bytes as entries are extracted (
📋 What to do next
Once an ADR is linked in the PR body, this gate will re-run and check that the implementation matches the decision. ❓ Why ADRs Matter
ADRs create a searchable, permanent record of why the codebase looks the way it does. Future contributors (and your future self) will thank you. 📋 Michael Nygard ADR Format ReferenceAn ADR must contain these four sections to be considered complete:
All ADRs are stored in
|
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /tdd and /codebase-design. The core logic is sound: the archive-wide preflight runs before any extraction, the runtime budget is enforced with min(maxSize, maxZipEntrySize), and an exact-size file is accepted. Posting observations only.
📋 Key Themes & Highlights
Key Themes
- Untested runtime budget:
TestUnzipFileWithLimitscovers only the preflight checks. The runtime byte-count guard, which is the protection the PR description relies on, has no test (see inline comment). - Ambiguous error wording: the runtime error says "total" even when the per-entry 1 GB cap is the limit that fired.
Positive Highlights
- ✅ Preflight validation rejects over-limit archives before any entry is written, and the test asserts the destination stays empty.
- ✅
Close()errors are propagated through named returns, matching the existing destFile pattern. - ✅ The per-entry
extractZipFilecaller inlogs_episode_retrieval_artifacts.gokeeps its own 64 MiB total check, so it is not weakened. - ✅ Targeted zip tests pass when run with the -run filter for Zip and Unzip.
@copilot please address the review comments above.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~4 AIC · ⌖ ~1 AIC · ⊞ 5.4K
Comment /matt to run again
| // written == maxSize+1 means the reader was not exhausted, i.e. the | ||
| // actual content is larger than the allowed size. | ||
| if uint64(written) > maxSize { | ||
| extractErr = fmt.Errorf("file extraction exceeded total uncompressed size limit: %s", f.Name) |
There was a problem hiding this comment.
[/codebase-design] This message says "total uncompressed size limit", but it also fires when the per-entry 1 GB cap binds. The extractZipFile path passes maxZipEntrySize as the budget, so one oversized file would be reported as an archive-total problem. Use wording that matches the limit that actually fired, or neutral wording such as "exceeded size limit".
@copilot please address this.
| return extractErr | ||
| // written == maxSize+1 means the reader was not exhausted, i.e. the | ||
| // actual content is larger than the allowed size. | ||
| if uint64(written) > maxSize { |
There was a problem hiding this comment.
[/tdd] The runtime byte budget is the guarantee the PR description relies on (archive metadata can lie), but no test reaches it. Coverage shows lines 163-166 never run, and the per-entry size pre-check at lines 52-54 is also untested.
💡 Suggested test
Call extractZipFileWithLimit directly with a budget smaller than the real content, so the declared size does not trigger the error (sketch, adapt the zip setup):
func TestExtractZipFileWithLimitEnforcesRuntimeBudget(t *testing.T) {
t.Parallel()
// one-entry zip containing "hello" (5 bytes), opened with zip.OpenReader
_, err := extractZipFileWithLimit(r.File[0], t.TempDir(), false, 4)
require.ErrorContains(t, err, "exceeded total uncompressed size limit")
_, err = extractZipFileWithLimit(r.File[0], t.TempDir(), false, 5)
require.NoError(t, err)
}I ran an equivalent probe locally and both assertions held.
@copilot please address this.
There was a problem hiding this comment.
🟡 Changes recommended
The archive limits still allow disk or inode exhaustion through unbounded implicit parent-directory creation.
3 open issues
What changed in this PR
Adds archive-wide resource limits to the CLI’s GitHub Actions log ZIP extraction, addressing #74889.
Changes:
- Reject archives exceeding 10,000 entries or 1 GiB of declared uncompressed data before extraction.
- Track a shared byte budget during extraction and propagate file-close errors.
- Add multi-entry tests verifying archive-limit rejection occurs before files are created.
| File | Description |
|---|---|
pkg/cli/logs_extract_zip_test.go |
Tests entry-count and total-size preflight rejection. |
pkg/cli/logs_download_zip.go |
Adds archive limits, runtime byte accounting, and close-error handling. |
Review effort: Max (auto)
| if len(r.File) > maxEntryCount { | ||
| return fmt.Errorf("zip archive contains too many entries (max %d)", maxEntryCount) |
| } | ||
| } |
|
@copilot run pr-finisher skill |
|
Note The pull request was not created — a fallback review issue was created instead due to protected file changes: #74930 PR finisher summarySubmitted for publication (not confirmed pushed): merged Validation: Review replies/resolutions are deferred until the fix is published. CI needs a maintainer re-trigger after publication. PR finisher dispatch requested for the following outstanding work: Sous-chef head: fc96c8d
|
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Ran pr-finisher and pushed Not yet merge-ready: review threads still require replies/resolution, the draft ADR needs maintainer approval and a PR-body link, and mergeability is currently unknown after the push. Thread resolution and PR-body editing are unavailable through the authenticated tools here. CI on the new HEAD remains unverified and needs a maintainer re-trigger; the inspected approval-gated runs had no failed jobs. No merge performed. |
|
🎉 This pull request is included in a new release. Release: |



ZIP logs were limited per entry but not across the archive, allowing many entries to consume excessive disk space or CPU.