Skip to content

Commit

Permalink
Merge pull request #17902 from Homebrew/api-credentials-fix
Browse files Browse the repository at this point in the history
Fix GitHub API credential encoding errors
  • Loading branch information
Bo98 authored Jul 30, 2024
2 parents 1b0fdae + 1b8a8a0 commit 874d2da
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Library/Homebrew/attestation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ class GhAuthInvalid < RuntimeError; end
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.
Expand Down
5 changes: 3 additions & 2 deletions Library/Homebrew/utils/github/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,9 @@ def self.keychain_username_password
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
Expand Down

0 comments on commit 874d2da

Please sign in to comment.