From d73b0079e926f4c81b646cf79124a0068dddfd5a Mon Sep 17 00:00:00 2001 From: Justin Rackliffe Date: Wed, 23 Apr 2025 10:34:45 -0400 Subject: [PATCH 1/4] Resolve the corner case of anonymous OCI registry access (#16669). --- Library/Homebrew/download_strategy.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 82cb409a5b..a593835c2e 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -705,7 +705,10 @@ class CurlGitHubPackagesDownloadStrategy < CurlDownloadStrategy meta[:headers] ||= [] # GitHub Packages authorization header. # HOMEBREW_GITHUB_PACKAGES_AUTH set in brew.sh - meta[:headers] << "Authorization: #{HOMEBREW_GITHUB_PACKAGES_AUTH}" + # If using a private GHCR mirror with no Authentication set than do not add the header. In all other cases add it. + if not (Homebrew::EnvConfig.artifact_domain.presence && !Homebrew::EnvConfig.docker_registry_basic_auth_token.presence && !Homebrew::EnvConfig.docker_registry_token.presence) + meta[:headers] << "Authorization: #{HOMEBREW_GITHUB_PACKAGES_AUTH}" + end super end From 3761d7078547e0fd51542c66cb45b4f17cafbd93 Mon Sep 17 00:00:00 2001 From: Justin Rackliffe Date: Fri, 2 May 2025 11:33:48 -0400 Subject: [PATCH 2/4] Revised conditional logic to match CONTRIBUTING.md recommendations on adhering to brew style findings. --- Library/Homebrew/download_strategy.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index a593835c2e..19e03072a8 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -706,9 +706,11 @@ class CurlGitHubPackagesDownloadStrategy < CurlDownloadStrategy # GitHub Packages authorization header. # HOMEBREW_GITHUB_PACKAGES_AUTH set in brew.sh # If using a private GHCR mirror with no Authentication set than do not add the header. In all other cases add it. - if not (Homebrew::EnvConfig.artifact_domain.presence && !Homebrew::EnvConfig.docker_registry_basic_auth_token.presence && !Homebrew::EnvConfig.docker_registry_token.presence) - meta[:headers] << "Authorization: #{HOMEBREW_GITHUB_PACKAGES_AUTH}" - end + if !Homebrew::EnvConfig.artifact_domain.presence || + Homebrew::EnvConfig.docker_registry_basic_auth_token.presence || + Homebrew::EnvConfig.docker_registry_token.presence + meta[:headers] << "Authorization: #{HOMEBREW_GITHUB_PACKAGES_AUTH}" + end super end From efa2786732cdf4a0662029fba5ec6eaba521ffc5 Mon Sep 17 00:00:00 2001 From: Justin Rackliffe Date: Fri, 2 May 2025 15:00:22 -0400 Subject: [PATCH 3/4] Resolving CI style errors with whitespace that are not flagged using stle locally --- Library/Homebrew/download_strategy.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 19e03072a8..75d3a57c7c 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -707,10 +707,10 @@ class CurlGitHubPackagesDownloadStrategy < CurlDownloadStrategy # HOMEBREW_GITHUB_PACKAGES_AUTH set in brew.sh # If using a private GHCR mirror with no Authentication set than do not add the header. In all other cases add it. if !Homebrew::EnvConfig.artifact_domain.presence || - Homebrew::EnvConfig.docker_registry_basic_auth_token.presence || - Homebrew::EnvConfig.docker_registry_token.presence - meta[:headers] << "Authorization: #{HOMEBREW_GITHUB_PACKAGES_AUTH}" - end + Homebrew::EnvConfig.docker_registry_basic_auth_token.presence || + Homebrew::EnvConfig.docker_registry_token.presence + meta[:headers] << "Authorization: #{HOMEBREW_GITHUB_PACKAGES_AUTH}" + end super end From f051510e6763590aa2cc7c6564ccd43f30590a0c Mon Sep 17 00:00:00 2001 From: Justin Rackliffe Date: Tue, 20 May 2025 09:25:30 -0400 Subject: [PATCH 4/4] Update Library/Homebrew/download_strategy.rb Co-authored-by: Eric Knibbe --- Library/Homebrew/download_strategy.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 75d3a57c7c..01d5a91302 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -705,7 +705,7 @@ class CurlGitHubPackagesDownloadStrategy < CurlDownloadStrategy meta[:headers] ||= [] # GitHub Packages authorization header. # HOMEBREW_GITHUB_PACKAGES_AUTH set in brew.sh - # If using a private GHCR mirror with no Authentication set than do not add the header. In all other cases add it. + # If using a private GHCR mirror with no Authentication set then do not add the header. In all other cases add it. if !Homebrew::EnvConfig.artifact_domain.presence || Homebrew::EnvConfig.docker_registry_basic_auth_token.presence || Homebrew::EnvConfig.docker_registry_token.presence