Skip to content

Commit a2c5a73

Browse files
committed
Verify blob attestations exclusively via sigstore-go
Signed-off-by: Aaron Lew <64337293+aaronlew02@users.noreply.github.com>
1 parent ee35cec commit a2c5a73

9 files changed

Lines changed: 177 additions & 487 deletions

File tree

‎cmd/cosign/cli/options/verify.go‎

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -242,59 +242,41 @@ func (o *VerifyDockerfileOptions) AddFlags(cmd *cobra.Command) {
242242

243243
// VerifyBlobAttestationOptions is the top level wrapper for the `verify-blob-attestation` command.
244244
type VerifyBlobAttestationOptions struct {
245-
Key string
246-
SignaturePath string
247-
BundlePath string
245+
Key string
246+
BundlePath string
248247

249248
PredicateOptions
250249
CheckClaims bool
251250

252251
SecurityKey SecurityKeyOptions
253252
CertVerify CertVerifyOptions
254-
Rekor RekorOptions
255253
CommonVerifyOptions CommonVerifyOptions
256-
SignatureDigest SignatureDigestOptions
257-
258-
RFC3161TimestampPath string
259254

260255
Digest string
261256
DigestAlg string
262257
}
263258

264-
var _ Interface = (*VerifyBlobOptions)(nil)
259+
var _ Interface = (*VerifyBlobAttestationOptions)(nil)
265260

266261
// AddFlags implements Interface
267262
func (o *VerifyBlobAttestationOptions) AddFlags(cmd *cobra.Command) {
268263
o.PredicateOptions.AddFlags(cmd)
269264
o.SecurityKey.AddFlags(cmd)
270-
o.Rekor.AddFlags(cmd)
271265
o.CertVerify.AddFlags(cmd)
272266
o.CommonVerifyOptions.AddFlags(cmd)
273-
o.SignatureDigest.AddFlags(cmd)
274-
275-
_ = cmd.Flags().MarkDeprecated("rekor-url", "please use --bundle, which includes the Rekor inclusion proof")
276267

277268
cmd.Flags().StringVar(&o.Key, "key", "",
278269
"path to the public key file, KMS URI or Kubernetes Secret")
279270
_ = cmd.MarkFlagFilename("key", publicKeyExts...)
280271

281-
cmd.Flags().StringVar(&o.SignaturePath, "signature", "",
282-
"path to base64-encoded signature over attestation in DSSE format")
283-
_ = cmd.MarkFlagFilename("signature", signatureExts...)
284-
_ = cmd.Flags().MarkDeprecated("signature", "please use --bundle to provide a signature")
285-
286272
cmd.Flags().StringVar(&o.BundlePath, "bundle", "",
287273
"path to bundle FILE")
288274
_ = cmd.MarkFlagFilename("bundle", bundleExts...)
275+
_ = cmd.MarkFlagRequired("bundle")
289276

290277
cmd.Flags().BoolVar(&o.CheckClaims, "check-claims", true,
291278
"if true, verifies the digest exists in the in-toto subject (using either the provided digest and digest algorithm or the provided blob's sha256 digest). If false, only the DSSE envelope is verified.")
292279

293-
cmd.Flags().StringVar(&o.RFC3161TimestampPath, "rfc3161-timestamp", "",
294-
"path to RFC3161 timestamp FILE")
295-
// _ = cmd.MarkFlagFilename("rfc3161-timestamp") // no typical extensions
296-
_ = cmd.Flags().MarkDeprecated("rfc3161-timestamp", "please use --bundle to provide the output bundle location, which will include the signed timestamp")
297-
298280
cmd.Flags().StringVar(&o.Digest, "digest", "",
299281
"Digest to use for verifying in-toto subject (instead of providing a blob)")
300282
_ = cmd.RegisterFlagCompletionFunc("digest", cobra.NoFileCompletions)

‎cmd/cosign/cli/verify.go‎

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,12 @@ func VerifyBlobAttestation() *cobra.Command {
356356
cmd := &cobra.Command{
357357
Use: "verify-blob-attestation",
358358
Short: "Verify an attestation on the supplied blob",
359-
Long: `Verify an attestation on the supplied blob input using the specified key reference.
360-
You may specify either a key or a kms reference to verify against.
359+
Long: `Verify an attestation on the supplied blob input using a Sigstore bundle, provided via --bundle (required).
360+
Verify against a public key or KMS reference (--key), a security key (--sk), or, for keyless
361+
signatures, a certificate identity and OIDC issuer (--certificate-identity and --certificate-oidc-issuer).
361362
362-
Signed material is provided with the --bundle flag.
363+
A trusted root verifies service-provided material in the bundle (certificates, transparency log
364+
entries, and RFC 3161 timestamps). Cosign fetches it from TUF, unless you provide one via --trusted-root.
363365
The blob may be specified as a path to a file.`,
364366
Example: ` cosign verify-blob-attestation --bundle <path> --certificate-identity <identity> --certificate-oidc-issuer <issuer> <blob>
365367
@@ -390,45 +392,29 @@ The blob may be specified as a path to a file.`,
390392
o.CommonVerifyOptions.IgnoreTlog = true
391393
}
392394

393-
hashAlgorithm, err := o.SignatureDigest.HashAlgorithm()
394-
if err != nil {
395-
return err
396-
}
397-
398395
ko := options.KeyOpts{
399-
KeyRef: o.Key,
400-
Sk: o.SecurityKey.Use,
401-
Slot: o.SecurityKey.Slot,
402-
RekorURL: o.Rekor.URL,
403-
BundlePath: o.BundlePath,
404-
RFC3161TimestampPath: o.RFC3161TimestampPath,
405-
TSACertChainPath: o.CommonVerifyOptions.TSACertChainPath,
406-
NewBundleFormat: o.CommonVerifyOptions.NewBundleFormat,
396+
KeyRef: o.Key,
397+
Sk: o.SecurityKey.Use,
398+
Slot: o.SecurityKey.Slot,
399+
BundlePath: o.BundlePath,
407400
}
408401
v := verify.VerifyBlobAttestationCommand{
409402
KeyOpts: ko,
410403
PredicateType: o.Type,
411404
CheckClaims: o.CheckClaims,
412-
SignaturePath: o.SignaturePath,
413405
CertVerifyOptions: o.CertVerify,
414-
CertRef: o.CertVerify.Cert,
415-
CertChain: o.CertVerify.CertChain,
416-
CARoots: o.CertVerify.CARoots,
417-
CAIntermediates: o.CertVerify.CAIntermediates,
418406
CertGithubWorkflowTrigger: o.CertVerify.CertGithubWorkflowTrigger,
419407
CertGithubWorkflowSHA: o.CertVerify.CertGithubWorkflowSha,
420408
CertGithubWorkflowName: o.CertVerify.CertGithubWorkflowName,
421409
CertGithubWorkflowRepository: o.CertVerify.CertGithubWorkflowRepository,
422410
CertGithubWorkflowRef: o.CertVerify.CertGithubWorkflowRef,
423411
IgnoreSCT: o.CertVerify.IgnoreSCT,
424-
SCTRef: o.CertVerify.SCT,
425412
Offline: o.CommonVerifyOptions.Offline,
426413
IgnoreTlog: o.CommonVerifyOptions.IgnoreTlog,
427414
UseSignedTimestamps: o.CommonVerifyOptions.UseSignedTimestamps,
428415
TrustedRootPath: o.CommonVerifyOptions.TrustedRootPath,
429416
Digest: o.Digest,
430417
DigestAlg: o.DigestAlg,
431-
HashAlgorithm: hashAlgorithm,
432418
AllowCertificateChain: o.CommonVerifyOptions.AllowCertificateChain,
433419
}
434420
// We only use the blob if we are checking claims.

‎cmd/cosign/cli/verify/common.go‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@ func CheckSigstoreBundleUnsupportedOptions(cmd any, verifyOfflineWithKey bool, c
6969
return nil
7070
}
7171

72-
func isb64(data []byte) bool {
73-
_, err := base64.StdEncoding.DecodeString(string(data))
74-
return err == nil
75-
}
76-
7772
// LoadVerifierFromKey returns a signature.Verifier from the provided key flags to use for verifying an artifact.
7873
// In the case of certain types of keys, it returns a close function that must be called by the calling method.
7974
func LoadVerifierFromKey(ctx context.Context, keyRef, slot string, sk bool) (signature.Verifier, func(), error) {

0 commit comments

Comments
 (0)