Skip to content

Commit 61369c8

Browse files
committed
cmd/inspect: add data on withdrawn and (un)reviewed reports
In the inspect command, display stats on the number of withdrawn and unreviewed reports in the corpus. Change-Id: I724a4f2bc00dbe279c2b20ecd9da5fcd961c029c Reviewed-on: https://go-review.googlesource.com/c/vulndb/+/596181 Reviewed-by: Damien Neil <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent bbfc2dc commit 61369c8

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

cmd/inspect/main.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ func display(overall *summary, byYear map[int]*summary) {
107107
headings()
108108
data("Go reports", 0, func(s *summary) int { return s.reports })
109109
data("Regular reports", 1, func(s *summary) int { return s.regular })
110+
for _, rs := range []report.ReviewStatus{report.Reviewed, report.Unreviewed} {
111+
data(rs.String(), 2, func(s *summary) int { return s.regularByReview[rs] })
112+
}
113+
data("Withdrawn reports", 1, func(s *summary) int { return s.withdrawn })
110114
data("Excluded reports", 1, func(s *summary) int { return s.excluded })
111115
for _, er := range report.ExcludedReasons {
112116
data(string(er), 2, func(s *summary) int { return s.excludedByReason[er] })
@@ -138,15 +142,17 @@ func displayGHSAs(ghsas []string) {
138142
}
139143

140144
type summary struct {
141-
reports, regular, excluded, noGHSA, firstParty int
142-
ghsas int
143-
ghsasNotInVDB []string
144-
excludedByReason map[report.ExcludedReason]int
145+
reports, regular, withdrawn, excluded, noGHSA, firstParty int
146+
ghsas int
147+
ghsasNotInVDB []string
148+
excludedByReason map[report.ExcludedReason]int
149+
regularByReview map[report.ReviewStatus]int
145150
}
146151

147152
func newSummary() *summary {
148153
return &summary{
149154
excludedByReason: make(map[report.ExcludedReason]int),
155+
regularByReview: make(map[report.ReviewStatus]int),
150156
}
151157
}
152158

@@ -179,9 +185,15 @@ func summarize(ghsas []*genericosv.Entry, reports []*report.Report) (*summary, m
179185

180186
yearSummary.excluded++
181187
yearSummary.excludedByReason[r.Excluded]++
188+
} else if r.Withdrawn != nil {
189+
overall.withdrawn++
190+
yearSummary.withdrawn++
182191
} else {
183192
overall.regular++
184193
yearSummary.regular++
194+
195+
overall.regularByReview[r.ReviewStatus]++
196+
yearSummary.regularByReview[r.ReviewStatus]++
185197
}
186198

187199
if len(r.GHSAs) == 0 && r.CVEMetadata == nil {

0 commit comments

Comments
 (0)