From c008f02fcf6cc611adf8d2081d6fe9ae838f5814 Mon Sep 17 00:00:00 2001 From: Bob Callaway Date: Wed, 21 Jul 2021 07:31:39 -0400 Subject: [PATCH] insert sha256: prefix if not provided Signed-off-by: Bob Callaway --- cmd/rekor-cli/app/search.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/rekor-cli/app/search.go b/cmd/rekor-cli/app/search.go index 3bd49d92c..335d45034 100644 --- a/cmd/rekor-cli/app/search.go +++ b/cmd/rekor-cli/app/search.go @@ -114,9 +114,12 @@ var searchCmd = &cobra.Command{ artifactStr := viper.GetString("artifact") sha := viper.GetString("sha") if sha != "" { - params.Query.Hash = sha + var prefix string + if !strings.HasPrefix(sha, "sha256:") { + prefix = "sha256:" + } + params.Query.Hash = fmt.Sprintf("%v%v", prefix, sha) } else if artifactStr != "" { - hasher := sha256.New() var tee io.Reader if isURL(artifactStr) {