Repository navigation
Only accept stable and head as formula specs - #24407
Conversation
Findings
|
| Layer / File(s) | Summary |
|---|---|
Validate formula spec selection Library/Homebrew/formula.rb, Library/Homebrew/test/formula_spec.rb, Library/Homebrew/test/formula_spec_selection_spec.rb |
Formula spec selection checks requested symbols against spec_syms before dispatch. The setter uses public_send for allowed symbols. Tests cover invalid assignment and a request matching a formula method that raises. |
Validate receipt spec values Library/Homebrew/tab/tab.rb, Library/Homebrew/test/tab_spec.rb |
Tab#spec returns :stable when the receipt spec is not listed in Formula.spec_syms. A test covers an invalid receipt value. |
Merge Risk: 
Low · up to f245a
-
Malformed receipts can interrupt formula loading, but the impact is limited to affected invalid receipts.
Pre-merge checks: 
4
-
Full details: Title check
-
Explanation
The title "Only accept stable and head as formula specs" matches the main change. Tab#spec now returns :stable unless the receipt names stable or head, and spec selection is limited to Formula.spec_syms names. The title is specific and concise, and it describes the primary intent of the changeset.
Full details: Description check
-
Explanation
The description states the bug, the fix, and the new examples. It explains that Tab#spec returned an unchecked source.spec and that Formula#initialize, Formula#active_spec= and Formulary.resolve used it as a method name. It also says Tab#spec now returns :stable for values other than stable or head, and that spec selection only calls Formula.spec_syms names. The test changes listed in the summary match these claims. The unchecked bug-fix reproduction checkbox is a template item and does not make the description off-topic.
-
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.
There was a problem hiding this comment.
Actionable comments posted: 1

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Organization UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
dc30af8a-7b57-4c28-b575-a7a90f79ade8
Files selected for processing: 5-
Library/Homebrew/formula.rbLibrary/Homebrew/tab/tab.rbLibrary/Homebrew/test/formula_spec.rbLibrary/Homebrew/test/formula_spec_selection_spec.rbLibrary/Homebrew/test/tab_spec.rb
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
-
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Thanks, good catch! No blockers but maybe follow-ups.
- `Tab#spec` returned an install receipt's `source.spec` unchecked and `Formula#initialize`, `Formula#active_spec=` and `Formulary.resolve` called it as a method, so a keg's receipt could make loading an installed formula call any of its methods that take no arguments. - Return `:stable` from `Tab#spec` for anything but `stable` or `head` and pick `stable` or `head` directly when selecting a spec, so a receipt naming anything else now loads as stable. ANT-2026-2YNM6WKU Signed-off-by: Patrick Linnane <patrick@linnane.io>
f245af4 to
dc44429
Compare
Tab#specreturned an install receipt'ssource.specunchecked andFormula#initialize,Formula#active_spec=andFormulary.resolvecalled it as a method, so a keg's receipt could make commands that load installed formulae, such asbrew outdated, call any of the formula's methods that take no arguments.Tab#specnow returns:stablefor anything butstableorheadand spec selection picksstableorheaddirectly; new examples cover receipt,Formula.newandactive_spec=values that aren't specs.brew benchmarkresults.brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?Claude Code (Opus 5.5) wrote the change and tests, ran
brew outdatedwith and without a formula name against a receipt namingpost_installbefore and after the change, checked that the new examples fail without the change and when any of the spec checks is removed and ranbrew lgtm --online.