Skip to content

Commit

Permalink
feat: regexp support for sigstore bundle (kyverno#10901)
Browse files Browse the repository at this point in the history
Signed-off-by: Vishal Choudhary <[email protected]>
  • Loading branch information
vishal-chdhry authored Aug 21, 2024
1 parent 39e5808 commit 4287f8c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
12 changes: 1 addition & 11 deletions pkg/cosign/sigstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,17 +185,7 @@ func buildPolicy(desc *v1.Descriptor, opts images.Options) (verify.PolicyBuilder
}
artifactDigestVerificationOption := verify.WithArtifactDigest(desc.Digest.Algorithm, digest)

// TODO: Add full regexp support to sigstore and cosign
// Verify images only has subject field, and no subject regexp, subject cannot be passed to subject regexp
// because then string containing the subjects will also work. We should just add an issuer regexp
// Solve this in a separate PR,
// See: https://github.com/sigstore/cosign/blob/7c20052077a81d667526af879ec40168899dde1f/pkg/cosign/verify.go#L339-L356
subjectRegexp := ""
if strings.Contains(opts.Subject, "*") {
subjectRegexp = opts.Subject
opts.Subject = ""
}
id, err := verify.NewShortCertificateIdentity(opts.Issuer, opts.Subject, "", subjectRegexp)
id, err := verify.NewShortCertificateIdentity(opts.Issuer, opts.Subject, "", opts.SubjectRegExp)
if err != nil {
return verify.PolicyBuilder{}, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ spec:
- entries:
- keyless:
issuer: https://token.actions.githubusercontent.com
subject: https://github.com/vishal-chdhry/artifact-attestation-example/.github/workflows/*
subjectRegExp: https://github.com/vishal-chdhry/artifact-attestation-example/.github/workflows/.+
rekor:
url: https://rekor.sigstore.dev
conditions:
Expand Down

0 comments on commit 4287f8c

Please sign in to comment.