Skip to content

Commit

Permalink
feat: consistent tlog warnings during verification (#2840)
Browse files Browse the repository at this point in the history
Closes #2839

Signed-off-by: Luiz Carvalho <lucarval@redhat.com>
  • Loading branch information
lcarva committed Mar 25, 2023
1 parent 2205558 commit 8a304d5
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions cmd/cosign/cli/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (
"github.com/sigstore/cosign/v2/internal/ui"
)

const ignoreTLogMessage = "Skipping tlog verification is an insecure practice that lacks of transparency and auditability verification for the %s."

func Verify() *cobra.Command {
o := &options.VerifyOptions{}

Expand Down Expand Up @@ -128,7 +130,7 @@ against the transparency log.`,
ctx := cmd.Context()

if o.CommonVerifyOptions.IgnoreTlog {
ui.Warnf(ctx, "Skipping tlog verification is an insecure practice that lacks of transparency and auditability verification for the signature.")
ui.Warnf(ctx, fmt.Sprintf(ignoreTLogMessage, "signature"))
}

return v.Exec(ctx, args)
Expand Down Expand Up @@ -215,7 +217,13 @@ against the transparency log.`,
IgnoreTlog: o.CommonVerifyOptions.IgnoreTlog,
}

return v.Exec(cmd.Context(), args)
ctx := cmd.Context()

if o.CommonVerifyOptions.IgnoreTlog {
ui.Warnf(ctx, fmt.Sprintf(ignoreTLogMessage, "attestation"))
}

return v.Exec(ctx, args)
},
}

Expand Down Expand Up @@ -299,10 +307,14 @@ The blob may be specified as a path to a file or - for stdin.`,
Offline: o.CommonVerifyOptions.Offline,
IgnoreTlog: o.CommonVerifyOptions.IgnoreTlog,
}
if err := verifyBlobCmd.Exec(cmd.Context(), args[0]); err != nil {
return fmt.Errorf("verifying blob %s: %w", args, err)

ctx := cmd.Context()

if o.CommonVerifyOptions.IgnoreTlog {
ui.Warnf(ctx, fmt.Sprintf(ignoreTLogMessage, "blob"))
}
return nil

return verifyBlobCmd.Exec(ctx, args[0])
},
}

Expand Down Expand Up @@ -366,7 +378,14 @@ The blob may be specified as a path to a file.`,
if len(args) > 0 {
path = args[0]
}
return v.Exec(cmd.Context(), path)

ctx := cmd.Context()

if o.CommonVerifyOptions.IgnoreTlog {
ui.Warnf(ctx, fmt.Sprintf(ignoreTLogMessage, "blob attestation"))
}

return v.Exec(ctx, path)
},
}

Expand Down

0 comments on commit 8a304d5

Please sign in to comment.