bump-formula-pr: render added version stanzas as string literals - #23751
Merged
Conversation
dduugg
commented
Sep 3, 2026
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The resource insertion path lacks regression coverage for this security-sensitive behavior.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Escapes newly added version stanzas so upstream version data cannot become executable Ruby source.
Changes:
- Render formula and resource versions as Ruby string literals.
- Add a regression test for formula version insertion.
File summaries
| File | Description |
|---|---|
Library/Homebrew/dev-cmd/bump-formula-pr.rb |
Safely renders added version stanzas. |
Library/Homebrew/test/dev-cmd/bump-formula-pr_spec.rb |
Tests formula-level version escaping. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
dduugg
force-pushed
the
bump-version-stanza-quoting
branch
from
September 3, 2026 01:21
caed024 to
63b8c63
Compare
dduugg
commented
Sep 3, 2026
`add_stable_stanzas_after` renders each entry with `Utils::AST.stanza_text`, which returns a bare string verbatim when it parses as the stanza being added, so a forced version shaped like a `version` stanza was written into the formula as Ruby source and evaluated on the next load. `brew bump` derives that value from a livecheck result. - render the value at both insertion sites, matching the neighbouring `mirror` stanza - cover both sites with regression examples, as the resource specs stub `update_resource_block!` and never reached the second one The replacement paths already went through `ruby_literal`.
dduugg
force-pushed
the
bump-version-stanza-quoting
branch
from
September 3, 2026 01:27
834ece9 to
3b9b54a
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.
brew bumptakes its new version from a livecheck result, so that value originates upstream.bump-formula-prpushed the string into the stanza list it hands toadd_stable_stanzas_after, which renders each entry withUtils::AST.stanza_text, and that returns a bare string verbatim when it parses as the stanza being added. A version shaped like aversionstanza was therefore written into the formula as Ruby source and evaluated on the next load instead of being treated as data. Rendering the value first, as the neighbouringmirrorstanza already does, means an upstream string can only ever land in a formula as a quoted literal. The same applies to the resource insertion path, and the replacement paths were already safe because they go throughruby_literal.brew benchmarkresults.brewcommands to reproduce the bug? Reproduction needs a crafted--versionvalue, covered by the added spec instead.brew lgtm(style, typechecking and tests) locally?Claude Code with Opus 5, with local review and testing.