Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attestation: specialize error when gh is old #17926

Merged
merged 3 commits into from
Aug 12, 2024
Merged

attestation: specialize error when gh is old #17926

merged 3 commits into from
Aug 12, 2024

Conversation

woodruffw
Copy link
Member

@woodruffw woodruffw commented Aug 1, 2024

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

This isn't really ideal (I'll look further into the bootstrap cycle issues that led us to try version sniffing in the first place), but it'll help more users in the current beta resolve issues they're seeing.

See Homebrew/homebrew-core#177384 (comment).

Copy link
Member

@nandahkrishna nandahkrishna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mostly seems fine but the reason I created the version-based check earlier was because some older versions of gh, weirdly, seem to not output an unknown command error even though they don't support attestations.

See for example:

$ oras pull ghcr.io/homebrew/core/gh:2.48.0
$ HOMEBREW_NO_VERIFY_ATTESTATIONS=1 brew install ./gh--2.48.0.arm64_sonoma.bottle.tar.gz
$ gh --version
gh version 2.48.0 (2024-04-17)
$ gh attestation     
Download and verify artifact attestations.

USAGE
  gh attestation [subcommand] [flags]

ALIASES
  at

AVAILABLE COMMANDS
  download:    Download an artifact's Sigstore bundle(s) for offline use
  verify:      Verify an artifact's integrity using attestations

INHERITED FLAGS
  --help   Show help for command

LEARN MORE
  Use `gh <command> <subcommand> --help` for more information about a command.
  Read the manual at https://cli.github.com/manual

However, the minimum gh version that supports attestations is 2.49.0, so I have no idea why this is happening.

@Bo98
Copy link
Member

Bo98 commented Aug 1, 2024

Honestly, it might just be easier to only check brewed gh version in Attestation.enabled? e.g.

gh_version = Formula["gh"].any_installed_version
return false if gh_version.nil? || gh_version < "2.49"

Especially given we hope to phase out gh entirely.

For Homebrew/core CI, where we don't use brewed gh, we already explicitly opt-in via the env which would override this check anyway. The number of non-CI end users using non-brewed gh is likely sufficiently small that it's probably not worth trying to extend the beta to cover them.

@woodruffw
Copy link
Member Author

Honestly, it might just be easier to only check brewed gh version in Attestation.enabled? e.g.

Yeah, seems right. I remember we had some bootstrap cycle issue with accessing Formula[...] in that context, but I think as long as it's below no_verify_attestations? that shouldn't be an issue.

@carlocab
Copy link
Member

carlocab commented Aug 1, 2024

This might make it easier to parse the gh version for --HEAD installs: Homebrew/homebrew-core#179266

@MikeMcQuaid
Copy link
Member

Honestly, it might just be easier to only check brewed gh version in Attestation.enabled? e.g.

Agreed.

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed with @Bo98's comment.

@woodruffw
Copy link
Member Author

I've updated this so that we now only enable attestations if gh is already installed and sufficiently new (unless the user explicitly enables them with HOMEBREW_VERIFY_ATTESTATIONS=1). This has the side effect of curbing the current beta significantly, since most people currently in it are probably getting it from having developer mode enabled. But per @Bo98's points that seems fine to me.

@woodruffw woodruffw self-assigned this Aug 12, 2024
Signed-off-by: William Woodruff <[email protected]>
@woodruffw woodruffw merged commit aafa81b into master Aug 12, 2024
24 checks passed
@woodruffw woodruffw deleted the ww/gh-too-old branch August 12, 2024 19:28
@PtrTeixeira
Copy link
Contributor

Hey! This looks like it might be the cause of #18028

@woodruffw
Copy link
Member Author

woodruffw commented Aug 12, 2024

Hey! This looks like it might be the cause of #18028

Looks like it, thanks. Reverting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants