Repository navigation
Only load dependencies by formula name - #24427
Merged
Merged
Conversation
- `Dependency#to_formula`, `#to_installed_formula` and `brew bundle` passed runtime dependency names from install receipts and bottle manifests to `Formulary`, which also loads paths. Post-install code can write both, so a name pointing at a Ruby file in its keg was evaluated by later `brew bundle` and `brew deps --installed` runs, and by `Dependency#installed?`, which `brew upgrade` calls for names from cached bottle manifests. - Raise `FormulaUnavailableError` for a `Dependency` whose name isn't a bare or tap-qualified formula name, including names `Formulary` would load as a `.rb` or bottle file from the working directory, and drop such names from `brew bundle`'s dependency lists. ANT-2026-8R5KTVE6 Signed-off-by: Patrick Linnane <patrick@linnane.io>
Contributor
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Validate names before formula resolution Library/Homebrew/dependency.rb, Library/Homebrew/test/dependency_spec.rb |
formula_name? checks names against formula-name rules. to_installed_formula and to_formula raise FormulaUnavailableError for names that fail the check. Tests cover accepted and rejected names and formula-file loading. |
Filter bundle runtime dependencies Library/Homebrew/bundle/brew.rb, Library/Homebrew/test/bundle/brew_spec.rb |
formula_to_hash keeps runtime dependency values that are strings and pass formula_name?. The test checks valid formula names alongside paths, URLs, traversal-like strings and a non-string value. |
Merge Risk: 
Minimal · up to c5c55
-
No actionable merge-blocking risk was identified.
Pre-merge checks: 
4
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
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.
Dependency#to_formula,Dependency#to_installed_formulaandbrew bundlepassed runtime dependency names from install receipts and bottle manifests toFormulary, which also loads paths, so a name pointing at a Ruby file in the Cellar, which post-install code can write along with the receipt, was evaluated by laterbrew bundleandbrew deps --installedruns and byDependency#installed?, whichbrew upgradecalls for names from cached bottle manifests.Dependencynow raisesFormulaUnavailableErrorfor names that aren't bare or tap-qualified formula names, including onesFormularywould load as a.rbor bottle file from the working directory, andbrew bundledrops them from its dependency lists.brew benchmarkresults.brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?Claude Code (Opus 5.5) wrote the change and tests, reproduced on macOS before the change that a post-install step's planted receipt and Ruby file got the file evaluated by
brew bundle dump,brew deps --installed(afterbrew postinstall) andDependency#installed?and checked none of them evaluate it with the change, checked that the new examples fail without the change and when any part of the check is removed and ranbrew lgtm --online.