Skip to content

bump-formula-pr: render added version stanzas as string literals - #23751

Merged
MikeMcQuaid merged 1 commit into
mainfrom
bump-version-stanza-quoting
Sep 3, 2026
Merged

bump-formula-pr: render added version stanzas as string literals#23751
MikeMcQuaid merged 1 commit into
mainfrom
bump-version-stanza-quoting

Conversation

@dduugg

@dduugg dduugg commented Sep 3, 2026

Copy link
Copy Markdown
Member

brew bump takes its new version from a livecheck result, so that value originates upstream. bump-formula-pr pushed the string into the stanza list it hands to add_stable_stanzas_after, which renders each entry with Utils::AST.stanza_text, and that returns a bare string verbatim when it parses as the stanza being added. A version shaped like a version stanza 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 neighbouring mirror stanza 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 through ruby_literal.


  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include brew benchmark results.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug? Reproduction needs a crafted --version value, covered by the added spec instead.
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

Claude Code with Opus 5, with local review and testing.


Copilot AI balanced review requested due to automatic review settings September 3, 2026 00:55
Comment thread Library/Homebrew/dev-cmd/bump-formula-pr.rb Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Comment thread Library/Homebrew/dev-cmd/bump-formula-pr.rb
@dduugg
dduugg force-pushed the bump-version-stanza-quoting branch from caed024 to 63b8c63 Compare September 3, 2026 01:21
Comment thread Library/Homebrew/dev-cmd/bump-formula-pr.rb Outdated
`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
dduugg force-pushed the bump-version-stanza-quoting branch from 834ece9 to 3b9b54a Compare September 3, 2026 01:27

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

@MikeMcQuaid
MikeMcQuaid added this pull request to the merge queue Sep 3, 2026
Merged via the queue into main with commit 69b8bae Sep 3, 2026
58 checks passed
@MikeMcQuaid
MikeMcQuaid deleted the bump-version-stanza-quoting branch September 3, 2026 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants