Skip to content

Commit 0bb7a28

Browse files
Merge pull request #326 from wking/signature-config-map-valid-keys
Bug 1782982: pkg/verify/verifyconfigmap: Use {algo}-{hash} prefixes
2 parents 2afd105 + cffa42c commit 0bb7a28

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pkg/verify/verifyconfigmap/store.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,17 @@ func (s *Store) DigestSignatures(ctx context.Context, digest string) ([][]byte,
8585
s.rememberMostRecentConfigMaps(configMaps.Items)
8686
}
8787

88+
parts := strings.SplitN(digest, ":", 3)
89+
if len(parts) != 2 || len(parts[0]) == 0 || len(parts[1]) == 0 {
90+
return nil, fmt.Errorf("the provided digest must be of the form ALGO:HASH")
91+
}
92+
algo, hash := parts[0], parts[1]
93+
prefix := fmt.Sprintf("%s-%s", algo, hash)
94+
8895
var signatures [][]byte
8996
for _, cm := range items {
9097
for k, v := range cm.BinaryData {
91-
if strings.HasPrefix(k, digest) {
98+
if strings.HasPrefix(k, prefix) {
9299
signatures = append(signatures, v)
93100
}
94101
}

0 commit comments

Comments
 (0)