Skip to content

Commit 5060b33

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

7 files changed

Lines changed: 124 additions & 423 deletions

File tree

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

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -241,20 +241,15 @@ func (o *VerifyDockerfileOptions) AddFlags(cmd *cobra.Command) {
241241

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

248247
PredicateOptions
249248
CheckClaims bool
250249

251250
SecurityKey SecurityKeyOptions
252251
CertVerify CertVerifyOptions
253-
Rekor RekorOptions
254252
CommonVerifyOptions CommonVerifyOptions
255-
SignatureDigest SignatureDigestOptions
256-
257-
RFC3161TimestampPath string
258253

259254
Digest string
260255
DigestAlg string
@@ -266,34 +261,20 @@ var _ Interface = (*VerifyBlobOptions)(nil)
266261
func (o *VerifyBlobAttestationOptions) AddFlags(cmd *cobra.Command) {
267262
o.PredicateOptions.AddFlags(cmd)
268263
o.SecurityKey.AddFlags(cmd)
269-
o.Rekor.AddFlags(cmd)
270264
o.CertVerify.AddFlags(cmd)
271265
o.CommonVerifyOptions.AddFlags(cmd)
272-
o.SignatureDigest.AddFlags(cmd)
273-
274-
_ = cmd.Flags().MarkDeprecated("rekor-url", "please use --bundle, which includes the Rekor inclusion proof")
275266

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

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

289275
cmd.Flags().BoolVar(&o.CheckClaims, "check-claims", true,
290276
"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.")
291277

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

‎cmd/cosign/cli/verify.go‎

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -390,45 +390,29 @@ The blob may be specified as a path to a file.`,
390390
o.CommonVerifyOptions.IgnoreTlog = true
391391
}
392392

393-
hashAlgorithm, err := o.SignatureDigest.HashAlgorithm()
394-
if err != nil {
395-
return err
396-
}
397-
398393
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,
394+
KeyRef: o.Key,
395+
Sk: o.SecurityKey.Use,
396+
Slot: o.SecurityKey.Slot,
397+
BundlePath: o.BundlePath,
407398
}
408399
v := verify.VerifyBlobAttestationCommand{
409400
KeyOpts: ko,
410401
PredicateType: o.Type,
411402
CheckClaims: o.CheckClaims,
412-
SignaturePath: o.SignaturePath,
413403
CertVerifyOptions: o.CertVerify,
414-
CertRef: o.CertVerify.Cert,
415-
CertChain: o.CertVerify.CertChain,
416-
CARoots: o.CertVerify.CARoots,
417-
CAIntermediates: o.CertVerify.CAIntermediates,
418404
CertGithubWorkflowTrigger: o.CertVerify.CertGithubWorkflowTrigger,
419405
CertGithubWorkflowSHA: o.CertVerify.CertGithubWorkflowSha,
420406
CertGithubWorkflowName: o.CertVerify.CertGithubWorkflowName,
421407
CertGithubWorkflowRepository: o.CertVerify.CertGithubWorkflowRepository,
422408
CertGithubWorkflowRef: o.CertVerify.CertGithubWorkflowRef,
423409
IgnoreSCT: o.CertVerify.IgnoreSCT,
424-
SCTRef: o.CertVerify.SCT,
425410
Offline: o.CommonVerifyOptions.Offline,
426411
IgnoreTlog: o.CommonVerifyOptions.IgnoreTlog,
427412
UseSignedTimestamps: o.CommonVerifyOptions.UseSignedTimestamps,
428413
TrustedRootPath: o.CommonVerifyOptions.TrustedRootPath,
429414
Digest: o.Digest,
430415
DigestAlg: o.DigestAlg,
431-
HashAlgorithm: hashAlgorithm,
432416
AllowCertificateChain: o.CommonVerifyOptions.AllowCertificateChain,
433417
}
434418
// 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)