Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens Homebrew Cask uninstall/zap deletion path handling to reduce path traversal and unsafe deletions, and adds regression tests to keep these protections in place.
Changes:
- Tighten
each_resolved_pathvalidation to reject paths containing./..segments. - Filter out undeletable paths after glob expansion (instead of checking only the pre-glob path).
- Add RSpec coverage for traversal rejection and post-glob undeletable filtering for both
uninstallandzap.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| Library/Homebrew/cask/artifact/abstract_uninstall.rb | Strengthens each_resolved_path path validation and filters undeletable glob results before deletion. |
| Library/Homebrew/test/cask/artifact/abstract_uninstall_spec.rb | Adds regression tests for traversal-segment rejection and undeletable glob-match filtering for uninstall/zap. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Bo98
approved these changes
Apr 10, 2026
- validate cask delete paths before `~` normalization so `.` and `..` cannot be hidden inside user-relative directives - keep warnings distinct for relative paths versus absolute paths with relative segments so rejected directives are easier to audit - cover `./`, `~/../`, post-glob undeletable matches, and `Errno::EPERM` guidance in `abstract_uninstall_spec.rb`
0b98e8f to
4275592
Compare
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.
each_resolved_pathfrom accepting.or..segments that can escape intended delete targetsrm -rfrunsabstract_uninstall_spec.rbso traversal and glob bypasses stay coveredbrew lgtm(style, typechecking and tests) with your changes locally?Used OpenAI Codex xhigh and manually reviewed all changes.