-
Notifications
You must be signed in to change notification settings - Fork 165
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
Fix search without sha prefix #767
Conversation
Signed-off-by: Eddie Zaneski <[email protected]>
@@ -38,8 +38,9 @@ func SearchIndexHandler(params index.SearchIndexParams) middleware.Responder { | |||
var result []string | |||
if params.Query.Hash != "" { | |||
// This must be a valid sha256 hash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SHA1 still seems to be supported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, I think that actually came later because we wanted to support git. So the comment is just out of date.
} | ||
} | ||
params.Query.Hash = fmt.Sprintf("%v%v", prefix, sha) | ||
params.Query.Hash = util.PrefixSHA(sha) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still needed here? Probably if folks update the cli but not the server?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, safe to keep!
Codecov Report
@@ Coverage Diff @@
## main #767 +/- ##
==========================================
- Coverage 48.95% 48.93% -0.02%
==========================================
Files 61 62 +1
Lines 5585 5587 +2
==========================================
Hits 2734 2734
- Misses 2556 2558 +2
Partials 295 295
Continue to review full report at Codecov.
|
@@ -38,8 +38,9 @@ func SearchIndexHandler(params index.SearchIndexParams) middleware.Responder { | |||
var result []string | |||
if params.Query.Hash != "" { | |||
// This must be a valid sha256 hash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, I think that actually came later because we wanted to support git. So the comment is just out of date.
Summary
Rekor API searches without a SHA prefix (sha1:, sha256:) do not currently work as the hash is stored in Redis with the prefix. rekor-cli infers the prefix when using --sha.
This PR reuses that logic when searching with
/index/retrieve
.Ticket Link
Fixes #699
Release Note