Repository navigation
Resolve zip slip + fix leaking file handles - #41183
jrmccluskey wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
📋 Review Summary
This PR updates validatePath in expansionx to use filepath.IsLocal and a cleaned prefix check recognized by static analysis scanners for Zip Slip protection, and refactors extractJar to properly close the archive reader and per-entry file handles instead of deferring closures until function exit. The changes are well-structured and accompanied by thorough unit tests covering path traversal cases and file descriptor exhaustion.
🔍 General Feedback
- Scoping file handle lifecycles into
extractZipEntryand explicitly checkingdf.Close()write errors is a solid improvement over deferring inside the extraction loop. - Combining
filepath.IsLocalwithstrings.HasPrefix(destPath, cleanDest+string(filepath.Separator))cleanly satisfies CodeQL'sgo/zipslipsanitizer requirements while preserving defense-in-depth.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #41183 +/- ##
============================================
+ Coverage 57.61% 57.63% +0.01%
Complexity 2617 2617
============================================
Files 1209 1209
Lines 171890 171930 +40
Branches 2163 2163
============================================
+ Hits 99036 99088 +52
+ Misses 70187 70171 -16
- Partials 2667 2671 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Assigning reviewers: R: @lostluck for label go. This pull request likely touches a core component ("core" label). Please review with scrutiny. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
|
Assigning new set of reviewers because Pr has gone too long without review. If you would like to opt out of this review, comment R: @kennknowles added as fallback since no labels match configuration This pull request likely touches a core component ("core" label). Please review with scrutiny. Available commands:
|
Looks like that PR resolved it, this is no longer necessary. That being said, there's no reason this PR doing the same thing should have sat for two weeks without getting reviewed. |
My apologies—this slipped off my radar. When I compared the two PRs yesterday, I noticed there's a change to extractJar here that isn't in #41589. Do we still need that fix? @jrmccluskey |
The initial zip slip fix in expansionx (#39638,) was not solved in a way the code scanner liked, so this reformats the fix + fixes the use of defer in extractJar to avoid leaking file handles until large JARs are returned.