Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor verification output. #632

Merged
merged 1 commit into from
Sep 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions cmd/cosign/cli/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,14 @@ func (c *VerifyCommand) Exec(ctx context.Context, args []string) (err error) {
return err
}

PrintVerification(imageRef, verified, co, c.Output)
PrintVerificationHeader(imageRef, co)
PrintVerification(imageRef, verified, c.Output)
}

return nil
}

// PrintVerification logs details about the verification to stdout
func PrintVerification(imgRef string, verified []cosign.SignedPayload, co *cosign.CheckOpts, output string) {
func PrintVerificationHeader(imgRef string, co *cosign.CheckOpts) {
fmt.Fprintf(os.Stderr, "\nVerification for %s --\n", imgRef)
fmt.Fprintln(os.Stderr, "The following checks were performed on each of these signatures:")
if co.ClaimVerifier != nil {
Expand All @@ -204,6 +204,10 @@ func PrintVerification(imgRef string, verified []cosign.SignedPayload, co *cosig
fmt.Fprintln(os.Stderr, " - The signatures were verified against the specified public key")
}
fmt.Fprintln(os.Stderr, " - Any certificates were verified against the Fulcio roots.")
}

// PrintVerification logs details about the verification to stdout
func PrintVerification(imgRef string, verified []cosign.SignedPayload, output string) {

switch output {
case "text":
Expand Down
3 changes: 2 additions & 1 deletion cmd/cosign/cli/verify_attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,9 @@ func (c *VerifyAttestationCommand) Exec(ctx context.Context, args []string) (err
return err
}

PrintVerificationHeader(imageRef, co)
// The attestations are always JSON, so use the raw "text" mode for outputting them instead of conversion
PrintVerification(imageRef, verified, co, "text")
PrintVerification(imageRef, verified, "text")
}

return nil
Expand Down
3 changes: 2 additions & 1 deletion cmd/sget/cli/sget.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ func SgetCmd(ctx context.Context, imageRef, keyRef string) (io.ReadCloser, error
if err != nil {
return nil, err
}
cli.PrintVerification(imageRef, sp, co, "text")
cli.PrintVerificationHeader(imageRef, co)
cli.PrintVerification(imageRef, sp, "text")
}

img, err := remote.Image(ref, co.RegistryClientOpts...)
Expand Down