Skip to content

Conversation

@malancas
Copy link
Contributor

@malancas malancas commented Dec 3, 2024

This just rearranges some logic for the sigstore verifier used by the gh attestation command set.

cc #9850

Signed-off-by: Meredith Lancaster <[email protected]>
Signed-off-by: Meredith Lancaster <[email protected]>
Signed-off-by: Meredith Lancaster <[email protected]>
Signed-off-by: Meredith Lancaster <[email protected]>
Signed-off-by: Meredith Lancaster <[email protected]>
Signed-off-by: Meredith Lancaster <[email protected]>
Signed-off-by: Meredith Lancaster <[email protected]>
@malancas malancas changed the title Sigstore verifier cleanup Sigstore verifier logic updates Dec 3, 2024

type LiveSigstoreVerifier struct {
config SigstoreConfig
TrustedRoot string
Copy link
Contributor Author

@malancas malancas Dec 3, 2024

Choose a reason for hiding this comment

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

No need for these to be nested in another struct. We probably don't need the SigstoreConfig struct either since it only contains three fields of different types.

}

func (v *LiveSigstoreVerifier) chooseVerifier(b *bundle.Bundle) (*verify.SignedEntityVerifier, string, error) {
func getBundleIssuer(b *bundle.Bundle) (string, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This logic was originally inside of the chooseVerifier method. I moved it out so we could parse the bundle's issuer separately. This allowed me to clean up chooseVerifier a bit.

continue
}
// if the custom trusted root issuer is not set or doesn't match the given issuer, skip it
if len(lowestCert.Issuer.Organization) == 0 || lowestCert.Issuer.Organization[0] != issuer {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I flipped the logic checking if the cert's issuer matches the incoming issuer for an early exit in a given loop iteration.

@malancas malancas marked this pull request as ready for review December 3, 2024 20:07
@malancas malancas requested a review from a team as a code owner December 3, 2024 20:07
@cliAutomation cliAutomation added the external pull request originating outside of the CLI core team label Dec 3, 2024
@williammartin
Copy link
Member

Is this waiting on something to be merged?

@malancas
Copy link
Contributor Author

malancas commented Dec 9, 2024

Is this waiting on something to be merged?

I'm going to open a pull request with some more integration tests across the command set, including some that will test the Sigstore verifier functionality. I'd like to merge that first so I can be more assured there are no regressions accidentally introduced in this PR. While we already have some integration tests for this functionality, I want to add some more that test the gh attestation verify command with various Sigstore verifier options in a script.

Once I open that PR, I'll add a link in this one saying it's blocked.

@malancas
Copy link
Contributor Author

Is this waiting on something to be merged?

I'm going to open a pull request with some more integration tests across the command set, including some that will test the Sigstore verifier functionality. I'd like to merge that first so I can be more assured there are no regressions accidentally introduced in this PR. While we already have some integration tests for this functionality, I want to add some more that test the gh attestation verify command with various Sigstore verifier options in a script.

Once I open that PR, I'll add a link in this one saying it's blocked.

Actually, we have integration tests in pkg/cmd/attestation/verification/sigstore_integration_test.go that cover the public good, GitHub, and custom trust root use cases. So I'm going to merge this. I'll add more bash script integration tests in test/integration/attestation-cmd after #10051 is merged.

@malancas malancas merged commit 76ffe4f into cli:trunk Dec 12, 2024
@malancas malancas deleted the sigstore-verifier-cleanup branch December 12, 2024 22:10
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Dec 21, 2024
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [cli/cli](https://github.com/cli/cli) | minor | `v2.63.2` -> `v2.64.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>cli/cli (cli/cli)</summary>

### [`v2.64.0`](https://github.com/cli/cli/releases/tag/v2.64.0): GitHub CLI 2.64.0

[Compare Source](cli/cli@v2.63.2...v2.64.0)

#### What's Changed

-   docs: improve docs for browse command as of [#&#8203;5352](cli/cli#5352) by [@&#8203;ankddev](https://github.com/ankddev) in cli/cli#10025
-   Open MR against gh-merge-base by [@&#8203;heaths](https://github.com/heaths) in cli/cli#9712
-   Add integration tests for `gh attestation verify` when the `bundle-from-oci` flag is specified by [@&#8203;malancas](https://github.com/malancas) in cli/cli#10020
-   `gh repo rename` help text clarifies new repo name should not include owner by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#10044
-   fix: list branches in square brackets in `gh run` and `gh codespace` by [@&#8203;uday-rana](https://github.com/uday-rana) in cli/cli#10043
-   Bump actions/attest-build-provenance from 1.4.4 to 2.1.0 by [@&#8203;dependabot](https://github.com/dependabot) in cli/cli#10056
-   Bump golang.org/x/crypto from 0.29.0 to 0.31.0 by [@&#8203;dependabot](https://github.com/dependabot) in cli/cli#10070
-   Improve documentation and error messaging for local extension installations without executables by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#9933
-   docs: better document auth scopes by [@&#8203;ankddev](https://github.com/ankddev) in cli/cli#10026
-   Sigstore verifier logic updates by [@&#8203;malancas](https://github.com/malancas) in cli/cli#9999
-   `gh pr merge --delete-branch` exits with error when merge requested via merge queue by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#10074
-   sundry `gh at inspect` improvements by [@&#8203;phillmv](https://github.com/phillmv) in cli/cli#9954
-   Support `pr view` for intra-org forks by [@&#8203;williammartin](https://github.com/williammartin) in cli/cli#10078
-   Print policy information before verifying attestations by [@&#8203;malancas](https://github.com/malancas) in cli/cli#9891
-   Improve error handling in apt setup script by [@&#8203;jobegrabber](https://github.com/jobegrabber) in cli/cli#10055
-   Use Windows compatible file name for downloaded attestations when running `gh attestation download` by [@&#8203;malancas](https://github.com/malancas) in cli/cli#10051
-   Bump github.com/cpuguy83/go-md2man/v2 from 2.0.5 to 2.0.6 by [@&#8203;dependabot](https://github.com/dependabot) in cli/cli#10094
-   Perform all `gh attestation verify` policy options configuration in the `newEnforcementCriteria()` function by [@&#8203;malancas](https://github.com/malancas) in cli/cli#10012

#### New Contributors

-   [@&#8203;ankddev](https://github.com/ankddev) made their first contribution in cli/cli#10025
-   [@&#8203;uday-rana](https://github.com/uday-rana) made their first contribution in cli/cli#10043
-   [@&#8203;jobegrabber](https://github.com/jobegrabber) made their first contribution in cli/cli#10055

**Full Changelog**: cli/cli@v2.63.2...v2.64.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS43Ny4wIiwidXBkYXRlZEluVmVyIjoiMzkuNzcuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external pull request originating outside of the CLI core team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants