attestation: allow disabling verification.

Add the (for now undocumented) `HOMEBREW_NO_VERIFY_ATTESTATIONS` to
disable attestation verification if it's having issues or when doing
development.

While we're here, do a little style cleanup too.
This commit is contained in:
Mike McQuaid 2024-07-13 17:38:52 -04:00
parent 6b99ac5868
commit 4366ade990
No known key found for this signature in database

View File

@ -45,9 +45,13 @@ module Homebrew
# @api private
sig { returns(T::Boolean) }
def self.enabled?
Homebrew::EnvConfig.verify_attestations? \
|| Homebrew::EnvConfig.developer? \
|| Homebrew::Settings.read("devcmdrun") == "true"
# TODO: allow this undocumented variable until this is rolled out more
# widely and then we can remove or document it.
return false if ENV.fetch("HOMEBREW_NO_VERIFY_ATTESTATIONS", false)
Homebrew::EnvConfig.verify_attestations? ||
Homebrew::EnvConfig.developer? ||
Homebrew::Settings.read("devcmdrun") == "true"
end
# Returns a path to a suitable `gh` executable for attestation verification.