Skip to content

Commit

Permalink
Move new bundle options to CommonVerifyOptions
Browse files Browse the repository at this point in the history
Signed-off-by: Cody Soyland <codysoyland@github.com>
  • Loading branch information
codysoyland committed Feb 7, 2025
1 parent ae2b3ba commit 6d7fbf2
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
4 changes: 0 additions & 4 deletions cmd/cosign/cli/options/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ type CertVerifyOptions struct {
CertChain string
SCT string
IgnoreSCT bool
NewBundleFormat bool
TrustedRootPath string
}

var _ Interface = (*RekorOptions)(nil)
Expand Down Expand Up @@ -105,8 +103,6 @@ func (o *CertVerifyOptions) AddFlags(cmd *cobra.Command) {
cmd.Flags().BoolVar(&o.IgnoreSCT, "insecure-ignore-sct", false,
"when set, verification will not check that a certificate contains an embedded SCT, a proof of "+
"inclusion in a certificate transparency log")
cmd.Flags().StringVar(&o.TrustedRootPath, "trusted-root", "", "Path to a Sigstore TrustedRoot JSON file.")
cmd.Flags().BoolVar(&o.NewBundleFormat, "new-bundle-format", false, "expect the signature/attestation to be packaged in a Sigstore bundle")
}

func (o *CertVerifyOptions) Identities() ([]cosign.Identity, error) {
Expand Down
8 changes: 8 additions & 0 deletions cmd/cosign/cli/options/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ type CommonVerifyOptions struct {
ExperimentalOCI11 bool
PrivateInfrastructure bool
UseSignedTimestamps bool
NewBundleFormat bool
TrustedRootPath string
}

func (o *CommonVerifyOptions) AddFlags(cmd *cobra.Command) {
Expand All @@ -56,6 +58,12 @@ func (o *CommonVerifyOptions) AddFlags(cmd *cobra.Command) {

cmd.Flags().IntVar(&o.MaxWorkers, "max-workers", cosign.DefaultMaxWorkers,
"the amount of maximum workers for parallel executions")

cmd.Flags().StringVar(&o.TrustedRootPath, "trusted-root", "",
"Path to a Sigstore TrustedRoot JSON file.")

cmd.Flags().BoolVar(&o.NewBundleFormat, "new-bundle-format", false,
"expect the signature/attestation to be packaged in a Sigstore bundle")
}

// VerifyOptions is the top level wrapper for the `verify` command.
Expand Down
8 changes: 4 additions & 4 deletions cmd/cosign/cli/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,9 @@ The blob may be specified as a path to a file or - for stdin.`,
Slot: o.SecurityKey.Slot,
RekorURL: o.Rekor.URL,
BundlePath: o.BundlePath,
NewBundleFormat: o.CertVerify.NewBundleFormat,
RFC3161TimestampPath: o.RFC3161TimestampPath,
TSACertChainPath: o.CommonVerifyOptions.TSACertChainPath,
NewBundleFormat: o.CommonVerifyOptions.NewBundleFormat,
}
verifyBlobCmd := &verify.VerifyBlobCmd{
KeyOpts: ko,
Expand All @@ -347,7 +347,6 @@ The blob may be specified as a path to a file or - for stdin.`,
CARoots: o.CertVerify.CARoots,
CAIntermediates: o.CertVerify.CAIntermediates,
SigRef: o.Signature,
TrustedRootPath: o.CertVerify.TrustedRootPath,
CertGithubWorkflowTrigger: o.CertVerify.CertGithubWorkflowTrigger,
CertGithubWorkflowSHA: o.CertVerify.CertGithubWorkflowSha,
CertGithubWorkflowName: o.CertVerify.CertGithubWorkflowName,
Expand All @@ -358,6 +357,7 @@ The blob may be specified as a path to a file or - for stdin.`,
Offline: o.CommonVerifyOptions.Offline,
IgnoreTlog: o.CommonVerifyOptions.IgnoreTlog,
UseSignedTimestamps: o.CommonVerifyOptions.UseSignedTimestamps,
TrustedRootPath: o.CommonVerifyOptions.TrustedRootPath,
}

ctx, cancel := context.WithTimeout(cmd.Context(), ro.Timeout)
Expand Down Expand Up @@ -406,17 +406,16 @@ The blob may be specified as a path to a file.`,
Slot: o.SecurityKey.Slot,
RekorURL: o.Rekor.URL,
BundlePath: o.BundlePath,
NewBundleFormat: o.CertVerify.NewBundleFormat,
RFC3161TimestampPath: o.RFC3161TimestampPath,
TSACertChainPath: o.CommonVerifyOptions.TSACertChainPath,
NewBundleFormat: o.CommonVerifyOptions.NewBundleFormat,
}
v := verify.VerifyBlobAttestationCommand{
KeyOpts: ko,
PredicateType: o.PredicateOptions.Type,
CheckClaims: o.CheckClaims,
SignaturePath: o.SignaturePath,
CertVerifyOptions: o.CertVerify,
TrustedRootPath: o.CertVerify.TrustedRootPath,
CertRef: o.CertVerify.Cert,
CertChain: o.CertVerify.CertChain,
CARoots: o.CertVerify.CARoots,
Expand All @@ -431,6 +430,7 @@ The blob may be specified as a path to a file.`,
Offline: o.CommonVerifyOptions.Offline,
IgnoreTlog: o.CommonVerifyOptions.IgnoreTlog,
UseSignedTimestamps: o.CommonVerifyOptions.UseSignedTimestamps,
TrustedRootPath: o.CommonVerifyOptions.TrustedRootPath,
}
// We only use the blob if we are checking claims.
if len(args) == 0 && o.CheckClaims {
Expand Down
1 change: 1 addition & 0 deletions cmd/cosign/cli/verify/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import (
type VerifyCommand struct {
options.RegistryOptions
options.CertVerifyOptions
options.CommonVerifyOptions
CheckClaims bool
KeyRef string
CertRef string
Expand Down
1 change: 1 addition & 0 deletions cmd/cosign/cli/verify/verify_attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import (
type VerifyAttestationCommand struct {
options.RegistryOptions
options.CertVerifyOptions
options.CommonVerifyOptions
CheckClaims bool
KeyRef string
CertRef string
Expand Down

0 comments on commit 6d7fbf2

Please sign in to comment.