Skip to content

Commit

Permalink
fix: add verification failed log (notaryproject#469)
Browse files Browse the repository at this point in the history
Signed-off-by: Junjie Gao <[email protected]>
  • Loading branch information
JeyJeyGao authored Dec 7, 2022
1 parent 5b52dc6 commit 7a947d5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cmd/notation/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"reflect"

"github.com/notaryproject/notation-go"
"github.com/notaryproject/notation-go/log"
"github.com/notaryproject/notation-go/verifier"
"github.com/notaryproject/notation-go/verifier/trustpolicy"
"github.com/notaryproject/notation/internal/cmd"
Expand Down Expand Up @@ -61,6 +62,7 @@ Example - Verify a signature on an OCI artifact identified by a tag (Notation w
func runVerify(command *cobra.Command, opts *verifyOpts) error {
// set log level
ctx := opts.LoggingFlagOpts.SetLoggerLevel(command.Context())
logger := log.GetLogger(ctx)

// resolve the given reference and set the digest
ref, err := resolveReference(command.Context(), &opts.SecureFlagOpts, opts.reference, func(ref registry.Reference, manifestDesc ocispec.Descriptor) {
Expand Down Expand Up @@ -97,9 +99,10 @@ func runVerify(command *cobra.Command, opts *verifyOpts) error {

// core verify process.
_, outcomes, err := notation.Verify(ctx, verifier, repo, verifyOpts)

// write out
// on failure
if err != nil {
logger.Error(err)
}
// write out on failure
if err != nil || len(outcomes) == 0 {
return fmt.Errorf("signature verification failed for all the signatures associated with %s", ref.String())
}
Expand Down

0 comments on commit 7a947d5

Please sign in to comment.