-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: add search support for sha512 (#1142)
* Feature: add search support for sha512 This commit introduces the possibility to *search* via sha512 digests. Example of how this could be useful is for the npm ecosystem. npm often relies on sha512 digests, and provenance attestations in intoto format may use sha512 digests as the subject. Subjects are extract during uploads and added as index keys, which are then stored in Redis. This feature lets the cli accept sha512 digests, and the server to accept them to use when searching in the Redis cache. Signed-off-by: Fredrik Skogman <kommendorkapten@github.com> * Added SHA512 to the cli help Signed-off-by: Fredrik Skogman <kommendorkapten@github.com> * Re-ran code generation. Signed-off-by: Fredrik Skogman <kommendorkapten@github.com> * Added e2e tests that uploads an intoto attestation, with a SHA512 subject. The tests then verifies that the entry can be found via the SHA512 digest. Signed-off-by: Fredrik Skogman <kommendorkapten@github.com> Signed-off-by: Fredrik Skogman <kommendorkapten@github.com>
- Loading branch information
1 parent
de91fb6
commit f8ae9ba
Showing
16 changed files
with
674 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,4 @@ trillianSignerImagerefs | |
cosign.* | ||
signature | ||
rekor.pub | ||
*~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright 2022 The Sigstore Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package util | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestPrefixSHA(t *testing.T) { | ||
var testCases = []struct { | ||
input string | ||
want string | ||
}{ | ||
{ | ||
input: "123", | ||
want: "123", | ||
}, | ||
{ | ||
input: "sha512:abc", | ||
want: "sha512:abc", | ||
}, | ||
{ | ||
input: "09b80428c53912d4174162fd5b7c7d485bdcc3ab", | ||
want: "sha1:09b80428c53912d4174162fd5b7c7d485bdcc3ab", | ||
}, | ||
{ | ||
input: "b9869be95b24001702120dd5dd673a9bd8447446fb57220388d8d0a48c738808", | ||
want: "sha256:b9869be95b24001702120dd5dd673a9bd8447446fb57220388d8d0a48c738808", | ||
}, | ||
{ | ||
input: "cfd356237e261871e8f92ae6710a75a65a925ae121d94d28533f008bd3e00b5472d261b5d0e1ab4082e3078dd1ad2af57876ed3c1c797c4097dbed870f458408", | ||
want: "sha512:cfd356237e261871e8f92ae6710a75a65a925ae121d94d28533f008bd3e00b5472d261b5d0e1ab4082e3078dd1ad2af57876ed3c1c797c4097dbed870f458408", | ||
}, | ||
} | ||
|
||
for _, tr := range testCases { | ||
got := PrefixSHA(tr.input) | ||
if got != tr.want { | ||
t.Errorf("Got '%s' expected '%s'", got, tr.want) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.