Skip to content

Commit

Permalink
make tlog upload default true and always print cert in bundle
Browse files Browse the repository at this point in the history
Signed-off-by: Asra Ali <asraa@google.com>
  • Loading branch information
asraa committed Dec 8, 2022
1 parent 432c8f0 commit 6ec1d76
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
13 changes: 5 additions & 8 deletions cmd/cosign/cli/attest/attest_blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ func (c *AttestBlobCommand) Exec(ctx context.Context, artifactPath string) error
artifact, err = os.ReadFile(filepath.Clean(artifactPath))
}
if err != nil {
fmt.Println(filepath.Clean(artifactPath))
return err
}
}
Expand Down Expand Up @@ -159,12 +158,11 @@ func (c *AttestBlobCommand) Exec(ctx context.Context, artifactPath string) error
fmt.Printf("RF3161 timestamp bundle wrote in the file %s\n", c.RFC3161TimestampPath)
}

var rekorBytes []byte
rekorBytes, err := sv.Bytes(ctx)
if err != nil {
return err
}
if sign.ShouldUploadToTlog(ctx, c.KeyOpts, nil, c.TlogUpload) {
rekorBytes, err = sv.Bytes(ctx)
if err != nil {
return err
}
rekorClient, err := rekor.NewClient(c.RekorURL)
if err != nil {
return err
Expand All @@ -176,7 +174,6 @@ func (c *AttestBlobCommand) Exec(ctx context.Context, artifactPath string) error
fmt.Fprintln(os.Stderr, "tlog entry created with index:", *entry.LogIndex)
signedPayload.Bundle = cbundle.EntryToBundle(entry)
}

if c.BundlePath != "" {
signedPayload.Base64Signature = base64.StdEncoding.EncodeToString(sig)
signedPayload.Cert = base64.StdEncoding.EncodeToString(rekorBytes)
Expand All @@ -188,7 +185,7 @@ func (c *AttestBlobCommand) Exec(ctx context.Context, artifactPath string) error
if err := os.WriteFile(c.BundlePath, contents, 0600); err != nil {
return fmt.Errorf("create bundle file: %w", err)
}
fmt.Printf("Bundle wrote in the file %s\n", c.BundlePath)
fmt.Fprintln(os.Stderr, "Bundle wrote in the file ", c.BundlePath)
}

if c.OutputSignature != "" {
Expand Down
2 changes: 1 addition & 1 deletion cmd/cosign/cli/options/attest_blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (o *AttestBlobOptions) AddFlags(cmd *cobra.Command) {
cmd.Flags().BoolVarP(&o.SkipConfirmation, "yes", "y", false,
"skip confirmation prompts for non-destructive operations")

cmd.Flags().BoolVar(&o.TlogUpload, "tlog-upload", false,
cmd.Flags().BoolVar(&o.TlogUpload, "tlog-upload", true,
"whether or not to upload to the tlog")

cmd.Flags().StringVar(&o.TSAServerURL, "timestamp-server-url", "",
Expand Down

0 comments on commit 6ec1d76

Please sign in to comment.