mirror of
https://github.com/anchore/syft.git
synced 2025-11-20 09:53:16 +01:00
26 lines
486 B
Go
26 lines
486 B
Go
package pkg
|
|
|
|
import (
|
|
"sort"
|
|
)
|
|
|
|
func mergeCPEs(a, b []CPE) (result []CPE) {
|
|
aCPEs := make(map[string]CPE)
|
|
|
|
// keep all CPEs from a and create a quick string-based lookup
|
|
for _, aCPE := range a {
|
|
aCPEs[aCPE.BindToFmtString()] = aCPE
|
|
result = append(result, aCPE)
|
|
}
|
|
|
|
// keep all unique CPEs from b
|
|
for _, bCPE := range b {
|
|
if _, exists := aCPEs[bCPE.BindToFmtString()]; !exists {
|
|
result = append(result, bCPE)
|
|
}
|
|
}
|
|
|
|
sort.Sort(CPEBySpecificity(result))
|
|
return result
|
|
}
|