Skip to content

Commit

Permalink
all_test: add check for duplicate summaries
Browse files Browse the repository at this point in the history
Add a test to ensure that no two reports have the exact same summary.
This makes it easier for consumers to quickly visually/conceptually
distinguish reports beyond just the Go ID.

Change-Id: I00105570b5cd7ae5004788207ae61d4ca0deff8d
Reviewed-on: https://go-review.googlesource.com/c/vulndb/+/543801
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Damien Neil <[email protected]>
  • Loading branch information
tatianab committed Dec 14, 2023
1 parent cde7859 commit adabd30
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions all_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ func TestLintReports(t *testing.T) {

// Map from aliases (CVEs/GHSAS) to report paths, used to check for duplicate aliases.
aliases := make(map[string]string)
// Map from summaries to report paths, used to check for duplicate summaries.
summaries := make(map[string]string)
sort.Strings(reports)
for _, filename := range reports {
t.Run(filename, func(t *testing.T) {
Expand All @@ -110,6 +112,13 @@ func TestLintReports(t *testing.T) {
aliases[alias] = filename
}
}
if summary := r.Summary.String(); summary != "" {
if report, ok := summaries[summary]; ok {
t.Errorf("report %s shares duplicate summary %q with report %s", filename, summary, report)
} else {
summaries[summary] = filename
}
}
// Check that a correct OSV file was generated for each YAML report.
if r.Excluded == "" {
generated := r.ToOSV(time.Time{})
Expand Down

0 comments on commit adabd30

Please sign in to comment.