github.com/quay/claircore@v1.5.28/test/vulnerability.go (about) 1 package test 2 3 import ( 4 "fmt" 5 "strconv" 6 7 "github.com/quay/claircore" 8 ) 9 10 // GenUniqueVulnerabilities creates an array of unique Vulnerabilities. 11 // 12 // The array is guaranteed not to have any duplicated fields. 13 func GenUniqueVulnerabilities(n int, updater string) []*claircore.Vulnerability { 14 if n == 0 { 15 return nil 16 } 17 vulns := []*claircore.Vulnerability{} 18 for i := 0; i < n; i++ { 19 vulns = append(vulns, &claircore.Vulnerability{ 20 ID: strconv.Itoa(i), 21 Updater: updater, 22 Name: fmt.Sprintf("test-vuln-%d", i), 23 Description: fmt.Sprintf("test-vuln-desc-%d", i), 24 Links: fmt.Sprintf("test-vuln-links-%d", i), 25 Severity: fmt.Sprintf("test-severity-%d", i), 26 NormalizedSeverity: claircore.Unknown, 27 ArchOperation: claircore.OpEquals, 28 Package: &claircore.Package{ 29 ID: strconv.Itoa(i), 30 Name: fmt.Sprintf("package-%d", i), 31 Version: fmt.Sprintf("version-%d", i), 32 Arch: fmt.Sprintf("arch-%d", i), 33 Kind: claircore.BINARY, 34 }, 35 Dist: &claircore.Distribution{ 36 ID: strconv.Itoa(i), 37 Name: fmt.Sprintf("dist-%d", i), 38 Version: fmt.Sprintf("version-%d", i), 39 VersionCodeName: fmt.Sprintf("version%d", i), 40 VersionID: fmt.Sprintf("%d", i), 41 Arch: fmt.Sprintf("arch-%d", i), 42 CPE: WFN(i), 43 PrettyName: fmt.Sprintf("pretty-name-%d", i), 44 }, 45 Repo: &claircore.Repository{ 46 ID: strconv.Itoa(i), 47 Name: fmt.Sprintf("repo-%d", i), 48 Key: fmt.Sprintf("key-%d", i), 49 URI: fmt.Sprintf("uri-%d", i), 50 }, 51 }) 52 } 53 54 return vulns 55 }