Repository navigation
Conversation
|
/gemini review |
There was a problem hiding this comment.
📋 Review Summary
This PR replaces the manual .. path component check in ZipFiles.unzipFile with canonical Path.startsWith validation against the target directory, resolving the CodeQL java/zipslip finding. The implementation and accompanying unit tests in ZipFilesTest are clean, accurate, and thoroughly cover traversal and sibling-prefix edge cases.
🔍 General Feedback
- Using
targetFile.getCanonicalFile().toPath().startsWith(canonicalTargetDir)properly enforces path-component prefix matching rather than raw string prefix matching, preventing sibling directory bypasses (../target_sibling/...) as well as symlink escapes. - Regression tests cover both rejected traversal paths and valid filenames containing
...
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #41497 +/- ##
=========================================
Coverage 59.38% 59.38%
Complexity 5137 5137
=========================================
Files 1470 1470
Lines 187512 187512
Branches 3819 3819
=========================================
Hits 111351 111351
Misses 72756 72756
Partials 3405 3405 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Assigning reviewers: R: @Abacn for label java. 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). |
|
Reminder, please take a look at this pr: @Abacn |
Note: this PR was auto-generated by tooling. Before moving it out of draft, the author has done a full review of the PR, specifically evaluating it on the following criteria:
CodeQL/zizmor) onmasterwithout altering intended public API or workflow semanticsIf you have concerns with the PR or with the underlying methodology used to generate this, please comment below - they will be addressed by the author not the tooling :)
Summary
java/zipslip(CWE-022, High/Error, alert #89) inorg.apache.beam.sdk.util.ZipFiles.unzipFile...string-splitting incheckNamewith canonicalPath.startsWithverification (targetFile.getCanonicalFile().toPath().startsWith(canonicalTargetDir)) prior to creating directories or writing extracted files, preventing directory traversal, sibling-prefix bypasses (../target_sibling/...), and symlink escapes outsidetargetDirectory.ZipFilesTestcovering Zip Slip traversal entries (../escaped.txt,nested/../../escaped.txt,../target_sibling/escaped.txt) while preserving valid filenames containing double dots (foo..bar.txt).Verification
./gradlew :sdks:java:core:spotlessCheck :sdks:java:core:test --tests org.apache.beam.sdk.util.ZipFilesTest