From 89d52f19a9be49d683233a8f8ac28bb2c9df6722 Mon Sep 17 00:00:00 2001 From: Alexander Bayandin Date: Fri, 25 Aug 2023 13:58:51 +0100 Subject: [PATCH] shared_audits: allow GitHub's IP not permitted error Co-authored-by: Mike McQuaid --- Library/Homebrew/utils/shared_audits.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Library/Homebrew/utils/shared_audits.rb b/Library/Homebrew/utils/shared_audits.rb index de1ec69c95..b47e3060b0 100644 --- a/Library/Homebrew/utils/shared_audits.rb +++ b/Library/Homebrew/utils/shared_audits.rb @@ -12,6 +12,10 @@ module SharedAudits URL_TYPE_HOMEPAGE = "homepage URL" + GITHUB_IP_ALLOWLIST_ERROR = Regexp.new("Although you appear to have the correct authorization credentials, " \ + "the `(.+)` organization has an IP allow list enabled, " \ + "and your IP address is not permitted to access this resource").freeze + module_function def github_repo_data(user, repo) @@ -21,6 +25,8 @@ module SharedAudits @github_repo_data["#{user}/#{repo}"] rescue GitHub::API::HTTPNotFoundError nil + rescue GitHub::API::AuthenticationFailedError => e + raise unless e.message.match?(GITHUB_IP_ALLOWLIST_ERROR) end def github_release_data(user, repo, tag) @@ -32,6 +38,8 @@ module SharedAudits @github_release_data[id] rescue GitHub::API::HTTPNotFoundError nil + rescue GitHub::API::AuthenticationFailedError => e + raise unless e.message.match?(GITHUB_IP_ALLOWLIST_ERROR) end def github_release(user, repo, tag, formula: nil, cask: nil)