github.com/quay/claircore@v1.5.28/pkg/ovalutil/links.go (about) 1 package ovalutil 2 3 import ( 4 "strings" 5 6 "github.com/quay/goval-parser/oval" 7 ) 8 9 // Links joins all the links in the cve definition into a single string. 10 func Links(def oval.Definition) string { 11 links := []string{} 12 13 for _, ref := range def.References { 14 links = append(links, ref.RefURL) 15 } 16 17 for _, ref := range def.Advisory.Refs { 18 links = append(links, ref.URL) 19 } 20 for _, bug := range def.Advisory.Bugs { 21 links = append(links, bug.URL) 22 } 23 24 for _, cve := range def.Advisory.Cves { 25 links = append(links, cve.Href) 26 } 27 28 links = deduplicate(links) 29 s := strings.Join(links, " ") 30 return s 31 } 32 33 func deduplicate(links []string) []string { 34 inResult := make(map[string]bool) 35 de := []string{} 36 for _, l := range links { 37 if _, ok := inResult[l]; !ok { 38 if l != "" { 39 inResult[l] = true 40 de = append(de, l) 41 } 42 } 43 } 44 return de 45 }