63 Commits

Author SHA1 Message Date
Mike McQuaid
a1f112f3fe
Move o* output methods to Utils::Output
This reduces the surface area of our `Kernel` monkeypatch and removes
the need to `include Kernel` in a bunch of modules.

While we're here, also move `Kernel#require?` to `Homebrew` and fully
scope the calls to it.
2025-08-20 19:20:19 +01:00
Mike McQuaid
4ee1015d94
attestation: improve debug message.
Let's reference a bottle filename here rather than a class instance ID.
2025-07-25 15:45:20 +00:00
Mike McQuaid
17762fa77a
attestation: require explicit opt-in.
Work on this has stalled a bit and it slows things down so let's require
an explicit opt-in to use it.

While we're here, remove the silent/implicit opt-out for CI, too.
2025-07-10 09:10:08 +01:00
Mike McQuaid
d899f00c4b
Link to Support Tiers in diagnostic/error messages
Now that we have this nice URL let's reference it to allow our other
messages to be a bit shorter/kinder.
2025-04-01 11:35:27 +01:00
William Woodruff
9e82563a3a
document the version that causes problems here
Signed-off-by: William Woodruff <william@yossarian.net>
2024-12-05 14:16:30 -05:00
William Woodruff
e5d47f85c9
attestation: handle multiple subjects
This should fix the behavior observed in
https://github.com/Homebrew/homebrew-core/issues/177384#issuecomment-2521141910
and below.

Signed-off-by: William Woodruff <william@yossarian.net>
2024-12-05 14:11:00 -05:00
William Woodruff
0613050d59
attestation: specialize error on incompatible gh
Signed-off-by: William Woodruff <william@yossarian.net>
2024-10-10 12:06:09 +01:00
Carlo Cabrera
98647ff0af
attestation: show unit of time for retry message
Otherwise this just shows a message like

    Failed to verify attestation. Retrying in 27...

which is a little vague. Let's make it clear that that refers to
seconds.
2024-10-09 23:24:24 +08:00
Carlo Cabrera
7b74bf07fd
Fix attestation test failures 2024-10-04 16:00:29 +08:00
Carlo Cabrera
6b63660817
attestation: retry on InvalidAttestationError instead 2024-10-04 12:47:13 +08:00
Carlo Cabrera
d0e4aea853
attestion: make InvalidAttestationError non-fatal in CI
I don't think I've seen an `InvalidAttestationError` that wasn't some
sort of network problem (e.g., rate limit, connection timeout, 503).
Let's emit a warning instead of erroring out.

Note that `MissingAttestationError` is still fatal, and that will still
produce errors in CI.
2024-10-04 12:28:22 +08:00
William Woodruff
09c12d817e
Revert "attestation: specialize error when gh is old" 2024-08-12 15:53:17 -04:00
William Woodruff
30acccf4b3
attestation: disable if gh is too old
Signed-off-by: William Woodruff <william@yossarian.net>
2024-08-12 14:54:55 -04:00
William Woodruff
e66df8cfb1
attestation: specialize error when gh is old
See https://github.com/Homebrew/homebrew-core/issues/177384#issuecomment-2263195832.

Signed-off-by: William Woodruff <william@yossarian.net>
2024-08-01 11:36:36 -04:00
Bo Anderson
1b8a8a0902
attestation: only extract credentials when necessary 2024-07-30 04:51:29 +01:00
William Woodruff
5e0e0d56af
attestation: remove gh version detection
I'm declaring bankruptcy on this entire approach:

1. We can attempt to match on versions, but this will fail
   when the version of `gh` installed is built from `HEAD`
   or similar.
2. We can match on dates instead (since `gh --version` also includes
   the date), but this is even more brittle + implies a support
   contract we don't actually have (we don't actually want
   to say we support random dated builds between public releases
   of `gh`).

This moves us back to a simpler approach: if `gh` is present,
we use it. If `gh` is not present, we attempt to install it
with `ensure_executable!`. If the user's `gh` is present but too old,
it'll fail during attestation verification with a reasonable error,
which IMO is fine for now since this is all still in beta.

Signed-off-by: William Woodruff <william@yossarian.net>
2024-07-29 13:13:55 -04:00
William Woodruff
6e2975d026
attestation: handle mirrored bottles correctly
Signed-off-by: William Woodruff <william@yossarian.net>
2024-07-26 14:26:45 -04:00
Bo Anderson
131b930d89
attestation: only fallback to backfill on 404 2024-07-23 16:59:52 +01:00
Nanda H Krishna
45f853ef61
Merge pull request #17793 from Homebrew/fix-frozen-array-modification-errors
Avoid frozen array errors in `brew upgrade`
2024-07-19 09:58:57 -04:00
apainintheneck
52cf4e30fc Share attestation formula sorting and gh exe checking logic
This adds a new method to either move the `gh` formula to the front
of the formula list to be installed or checks that the `gh` formula
is already installed some other way.
2024-07-18 21:32:50 -07:00
William Woodruff
493450a3ac
attestation: fix comment
Signed-off-by: William Woodruff <william@yossarian.net>
2024-07-18 12:06:37 -04:00
Bo Anderson
16d547b030
attestation: handle bad configurations better 2024-07-18 16:11:25 +01:00
Nanda H Krishna
6db608f43f
Ensure that the gh formula is sufficiently new 2024-07-17 14:48:53 -04:00
Nanda H Krishna
8839ccfe72
Fix tests for attestations 2024-07-17 14:48:53 -04:00
Nanda H Krishna
d2d814414e
cmd/{install,reinstall,upgrade}: ensure that gh is installed 2024-07-17 14:48:52 -04:00
Nanda H Krishna
51ec743d6f
Remove ensure_gh_installed!
Co-authored-by: William Woodruff <william@yossarian.net>
2024-07-17 14:48:52 -04:00
Nanda H Krishna
802eb54e87
Fix tests for attestations 2024-07-17 14:48:50 -04:00
Nanda H Krishna
4d387d285e
Fix type and style errors 2024-07-17 14:46:59 -04:00
Nanda H Krishna
3bb91601fb
Ensure early installation of gh for attestations 2024-07-17 14:46:58 -04:00
Bo Anderson
f40330c42d
attestation: avoid touching working directory 2024-07-17 19:18:09 +01:00
William Woodruff
ad1500ad60
Apply suggestions from code review 2024-07-14 16:30:12 -04:00
Nanda H Krishna
1ae21d2731
attestation: improve error message when gh is too old 2024-07-14 16:12:56 -04:00
Mike McQuaid
b8ff4b3d23
Widen attestation verification rollout
Take 2 of https://github.com/Homebrew/brew/pull/17692 but with:

- provide and document `HOMEBREW_NO_VERIFY_ATTESTATIONS`
- don't try to run unless there's GitHub credentials
- don't try to run unless `gh` is installed
- don't try to run in CI

While we're here:
- split out a `Homebrew::EnvConfig.devcmdrun?` helper method
- add some missing `Homebrew::EnvConfig.github_api_token` presence
  checks
2024-07-14 11:50:57 -04:00
Patrick Linnane
99b278b66b
brew style --fix
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2024-07-13 14:58:07 -07:00
Mike McQuaid
5771c2f968
attestation: only enable for developers outside CI
Let's hold off on CI and devcmdrun for now.
2024-07-13 17:55:44 -04:00
Mike McQuaid
4366ade990
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.
2024-07-13 17:39:40 -04:00
William Woodruff
6cfe118ae3
attestation: don't dupe stderr
Silences `system_command!`'s own stderr handling,
since we do it independently.

Signed-off-by: William Woodruff <william@yossarian.net>
2024-07-13 15:30:21 -04:00
William Woodruff
570cf65523
attestations: widen the beta
This widens the beta to include people with developer mode enabled,
as well as those with HOMEBREW_DEVELOPER set in their environment.

Signed-off-by: William Woodruff <william@yossarian.net>
2024-07-13 10:51:49 -04:00
Mike McQuaid
c13700af00
Use repository consistently instead of repo
The documentation linting job doesn't like `repo` so let's fix this
globally rather than naming it differently in documentation and code.
2024-06-10 09:31:53 +01:00
William Woodruff
e0179350fe
attestation: rename loop var to please sorbet
Signed-off-by: William Woodruff <william@yossarian.net>
2024-06-06 11:41:21 -04:00
William Woodruff
8d0e6eafc3
attestation: handle :all bottles
Signed-off-by: William Woodruff <william@yossarian.net>
2024-06-06 11:23:03 -04:00
William Woodruff
3319e9956d
attestation: drop workflow check on core attestation
Signed-off-by: William Woodruff <william@yossarian.net>
2024-05-18 10:04:53 -04:00
William Woodruff
f78a8882d9
attestation: redact secret in environment
Signed-off-by: William Woodruff <william@yossarian.net>
2024-05-14 14:32:23 -04:00
Mike McQuaid
3d31594e39
Merge pull request #17220 from woodruffw-forks/ww/refine-gh-auth
attestations: improve authentication techniques
2024-05-06 08:38:07 +01:00
William Woodruff
18a8b12f7a
attestations: improve authentication techniques
Signed-off-by: William Woodruff <william@yossarian.net>
2024-05-03 12:37:01 -04:00
Markus Reiter
caf87c0336
Warn about undocumented non-private APIs. 2024-05-01 11:35:20 +02:00
Joseph Sweeney
3ccc6b2521 fixup comment 2024-04-30 10:52:36 -04:00
Joseph Sweeney
9fff688bbe Make comment more explicit 2024-04-30 10:51:11 -04:00
Joseph Sweeney
883c1e9907 Update attestation tests 2024-04-30 10:16:57 -04:00
Joseph Sweeney
0f5d19220c Add comment explaining lack of signing workflow 2024-04-30 10:10:43 -04:00