зеркало из https://github.com/golang/vulndb.git
x/vulndb: add a check to ensure that GHSAs and CVEs are not repeated across reports
Change-Id: Ibbde79bb08d4c540202ac6dca9e9fff0221e0c0d Reviewed-on: https://go-review.googlesource.com/c/vulndb/+/451286 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Tatiana Bradley <tatiana@golang.org> Run-TryBot: Maceo Thompson <maceothompson@google.com>
This commit is contained in:
Родитель
852de697b5
Коммит
e2eba22a51
|
@ -76,6 +76,8 @@ func TestLintReports(t *testing.T) {
|
|||
reports = append(reports, filename)
|
||||
}
|
||||
}
|
||||
// Map from aliases (CVEs/GHSAS) to report paths, used to check for duplicate aliases.
|
||||
aliases := make(map[string]string)
|
||||
sort.Strings(reports)
|
||||
for _, filename := range reports {
|
||||
t.Run(filename, func(t *testing.T) {
|
||||
|
@ -87,6 +89,13 @@ func TestLintReports(t *testing.T) {
|
|||
if len(lints) > 0 {
|
||||
t.Errorf(strings.Join(lints, "\n"))
|
||||
}
|
||||
for _, alias := range r.GetAliases() {
|
||||
if report, ok := aliases[alias]; ok {
|
||||
t.Errorf("report %s shares duplicate alias %s with report %s", filename, alias, report)
|
||||
} else {
|
||||
aliases[alias] = filename
|
||||
}
|
||||
}
|
||||
// Check that a correct OSV file was generated for each YAML report.
|
||||
if r.Excluded == "" {
|
||||
generated := database.GenerateOSVEntry(filename, time.Time{}, r)
|
||||
|
|
Загрузка…
Ссылка в новой задаче