Merge pull request #17902 from Homebrew/api-credentials-fix

Fix GitHub API credential encoding errors
This commit is contained in:
Bo Anderson 2024-07-30 07:25:46 +01:00 committed by GitHub
commit 874d2da453
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 4 deletions

View File

@ -59,11 +59,11 @@ module Homebrew
def self.enabled?
return false if Homebrew::EnvConfig.no_verify_attestations?
return true if Homebrew::EnvConfig.verify_attestations?
return false if GitHub::API.credentials.blank?
return false if ENV.fetch("CI", false)
return false if OS.unsupported_configuration?
Homebrew::EnvConfig.developer? || Homebrew::EnvConfig.devcmdrun?
# Always check credentials last to avoid unnecessary credential extraction.
(Homebrew::EnvConfig.developer? || Homebrew::EnvConfig.devcmdrun?) && GitHub::API.credentials.present?
end
# Returns a path to a suitable `gh` executable for attestation verification.

View File

@ -177,8 +177,9 @@ module GitHub
print_stderr: false
return unless result.success?
github_username = git_credential_out[/username=(.+)/, 1]
github_password = git_credential_out[/password=(.+)/, 1]
git_credential_out.force_encoding("ASCII-8BIT")
github_username = git_credential_out[/^username=(.+)/, 1]
github_password = git_credential_out[/^password=(.+)/, 1]
return unless github_username
# Don't use passwords from the keychain unless they look like