-
Notifications
You must be signed in to change notification settings - Fork 52
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
CLI: sigstore verify github
#381
Conversation
Signed-off-by: William Woodruff <william@trailofbits.com>
Signed-off-by: William Woodruff <william@trailofbits.com>
Here's the usage: sigstore verify github [-h] [--certificate FILE] [--signature FILE]
[--rekor-bundle FILE] --cert-identity IDENTITY
[--require-rekor-offline]
[--workflow-trigger EVENT] [--workflow-sha SHA]
[--workflow-name NAME]
[--workflow-repository REPO]
[--workflow-ref REF] [--staging]
[--rekor-url URL] [--rekor-root-pubkey FILE]
[--certificate-chain FILE]
FILE [FILE ...]
optional arguments:
-h, --help show this help message and exit
Verification inputs:
--certificate FILE, --cert FILE
The PEM-encoded certificate to verify against; not
used with multiple inputs (default: None)
--signature FILE The signature to verify against; not used with
multiple inputs (default: None)
--rekor-bundle FILE The offline Rekor bundle to verify with; not used with
multiple inputs (default: None)
FILE The file to verify
Verification options:
--cert-identity IDENTITY
The identity to check for in the certificate's Subject
Alternative Name (default: None)
--require-rekor-offline
Require offline Rekor verification with a bundle;
implied by --rekor-bundle (default: False)
--workflow-trigger EVENT
The GitHub Actions event name that triggered the
workflow (default: None)
--workflow-sha SHA The `git` commit SHA that the workflow run was invoked
with (default: None)
--workflow-name NAME The name of the workflow that was triggered (default:
None)
--workflow-repository REPO
The repository slug that the workflow was triggered
under (default: None)
--workflow-ref REF The `git` ref that the workflow was invoked with
(default: None)
Sigstore instance options:
--staging Use sigstore's staging instances, instead of the
default production instances (default: False)
--rekor-url URL The Rekor instance to use (conflicts with --staging)
(default: https://rekor.sigstore.dev)
--rekor-root-pubkey FILE
A PEM-encoded root public key for Rekor itself
(conflicts with --staging) (default: None)
--certificate-chain FILE
Path to a list of CA certificates in PEM format which
will be needed when building the certificate chain for
the Fulcio signing certificate (default: None) |
Signed-off-by: William Woodruff <william@trailofbits.com>
This should now be basically functional, and I can confirm that it works on a signed release of $ sigstore verify github ~/Downloads/sigstore-0.9.0-py3-none-any.whl \
--cert-identity 'https://github.com/sigstore/sigstore-python/.github/workflows/release.yml@refs/tags/v0.9.0' \
--workflow-sha 62865f364852c1842e4ccacc821e3190f9b92eb8 \
--workflow-trigger release \
--workflow-name Release \
--workflow-repository sigstore/sigstore-python \
--workflow-ref refs/tags/v0.9.0
OK: /Users/william/Downloads/sigstore-0.9.0-py3-none-any.whl (In this case, I had |
cc @jku for thoughts on the CLI structure as well! In particular, I'd like opinions from everyone on:
|
Signed-off-by: William Woodruff <william@trailofbits.com>
Signed-off-by: William Woodruff <william@trailofbits.com>
for (file, materials) in files_with_materials: | ||
result = verifier.verify(materials=materials, policy=policy_) | ||
|
||
if result: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NB: From here to the end is pretty much just a dupe of the body of _verify_identity
, so it isn't very DRY of us. It turns out that the two are nearly identical except for how the various verification flags are handled, so I need to think some more about whether it really makes sense for them to have separate functions like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it feels like a lot of this could be wrapped up into a function. It seems like it's mostly the beginning before the (file, materials)
loop that differs so this should separate pretty cleanly.
I'm ok with just leaving it as a TODO though.
Long deprecated. Signed-off-by: William Woodruff <william@trailofbits.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some nits, LGTM otherwise.
Now that we manage keys with TUF, the most likely error here is misconfiguration: someone asking us to verify a sig/cert that was issued against a different instance of Fulcio than we're verifying with. Signed-off-by: William Woodruff <william@trailofbits.com>
That seems reasonable. I believe that the identity issued from GH is effectively
I'm mildly in favour of having the shorter names. It doesn't seem like we're getting much from the
That'd be neat. I think it's a bit fuzzy at this stage because usually not every file in a GitHub release gets signed. So we'd have to have some way of figuring out what we should check. Either way, I don't think anything in your current design excludes that possibility in the future whether it goes under a flag or an entirely new subcommand. |
The tricky thing here is that it isn't quite the same: the identity string contains the workflow filename itself, while the closest equivalent claim ( AFAICT there's no equivalent standalone claim for the workflow filename, so no set of alternative options would be fully equivalent to it. This may or may not be super important -- on one hand any action can name itself whatever it would like (e.g. |
Signed-off-by: William Woodruff <william@trailofbits.com>
Agreed; I went with a middle solution: the flags themselves now use the short names, but the |
Signed-off-by: William Woodruff <william@trailofbits.com>
Signed-off-by: William Woodruff <william@trailofbits.com>
Signed-off-by: William Woodruff <william@trailofbits.com>
Signed-off-by: William Woodruff <william@trailofbits.com>
Signed-off-by: William Woodruff <william@trailofbits.com>
Signed-off-by: William Woodruff <william@trailofbits.com>
Closes #322.