Limit headered curl redirects#22945
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens CurlDownloadStrategy’s handling of redirects when caller-supplied headers are present, aiming to prevent those headers (including deferred HOMEBREW_ secrets) from being replayed to redirect targets while preserving the existing --location curl code path.
Changes:
- Add
--max-redirs 0to curl invocations when download headers are present. - Extend
CurlDownloadStrategyspecs to cover deferredHOMEBREW_header expansion and verify redirects are refused (--max-redirs 0) while still using--location.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| Library/Homebrew/download_strategy/curl_download_strategy.rb | Adds --max-redirs 0 when headers are provided to prevent redirect-following with headers attached. |
| Library/Homebrew/test/download_strategies/curl_spec.rb | Adds/extends regression coverage ensuring --max-redirs 0 is included for deferred header scenarios (both pre- and post-expansion). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Avoid replaying deferred formula or cask secrets to redirect targets. - Keep ordinary GHCR header redirects working for bottle downloads. - Cover deferred `HOMEBREW_` headers and GitHub Packages headers.
b711fff to
ffeae21
Compare
p-linnane
approved these changes
Jul 4, 2026
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.
--locationpath while failing closed on redirects.HOMEBREW_header handling with regression tests.brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?OpenAI Codex 5.5 xhigh with local review and testing.