mirror of
https://github.com/anchore/syft.git
synced 2026-11-01 23:16:30 +01:00
Deduplicate digests from user configuration (#2522)
* deduplicate digests from user configuration Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * backout pointer reciever change on imageSource Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> --------- Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package file
|
||||
|
||||
import (
|
||||
"crypto"
|
||||
"sort"
|
||||
|
||||
"github.com/scylladb/go-set/uset"
|
||||
)
|
||||
|
||||
func NormalizeHashes(hashes []crypto.Hash) []crypto.Hash {
|
||||
set := uset.New()
|
||||
for _, h := range hashes {
|
||||
set.Add(uint(h))
|
||||
}
|
||||
list := set.List()
|
||||
sort.Slice(list, func(i, j int) bool {
|
||||
return list[i] < list[j]
|
||||
})
|
||||
result := make([]crypto.Hash, len(list))
|
||||
for i, v := range list {
|
||||
result[i] = crypto.Hash(v)
|
||||
}
|
||||
return result
|
||||
}
|
||||
Reference in New Issue
Block a user