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 <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Tatiana Bradley 2024-07-02 16:15:49 -04:00
Родитель bbfc2dc6ae
Коммит 61369c8fa8
1 изменённых файлов: 16 добавлений и 4 удалений

Просмотреть файл

@ -107,6 +107,10 @@ func display(overall *summary, byYear map[int]*summary) {
headings() headings()
data("Go reports", 0, func(s *summary) int { return s.reports }) data("Go reports", 0, func(s *summary) int { return s.reports })
data("Regular reports", 1, func(s *summary) int { return s.regular }) data("Regular reports", 1, func(s *summary) int { return s.regular })
for _, rs := range []report.ReviewStatus{report.Reviewed, report.Unreviewed} {
data(rs.String(), 2, func(s *summary) int { return s.regularByReview[rs] })
}
data("Withdrawn reports", 1, func(s *summary) int { return s.withdrawn })
data("Excluded reports", 1, func(s *summary) int { return s.excluded }) data("Excluded reports", 1, func(s *summary) int { return s.excluded })
for _, er := range report.ExcludedReasons { for _, er := range report.ExcludedReasons {
data(string(er), 2, func(s *summary) int { return s.excludedByReason[er] }) data(string(er), 2, func(s *summary) int { return s.excludedByReason[er] })
@ -138,15 +142,17 @@ func displayGHSAs(ghsas []string) {
} }
type summary struct { type summary struct {
reports, regular, excluded, noGHSA, firstParty int reports, regular, withdrawn, excluded, noGHSA, firstParty int
ghsas int ghsas int
ghsasNotInVDB []string ghsasNotInVDB []string
excludedByReason map[report.ExcludedReason]int excludedByReason map[report.ExcludedReason]int
regularByReview map[report.ReviewStatus]int
} }
func newSummary() *summary { func newSummary() *summary {
return &summary{ return &summary{
excludedByReason: make(map[report.ExcludedReason]int), excludedByReason: make(map[report.ExcludedReason]int),
regularByReview: make(map[report.ReviewStatus]int),
} }
} }
@ -179,9 +185,15 @@ func summarize(ghsas []*genericosv.Entry, reports []*report.Report) (*summary, m
yearSummary.excluded++ yearSummary.excluded++
yearSummary.excludedByReason[r.Excluded]++ yearSummary.excludedByReason[r.Excluded]++
} else if r.Withdrawn != nil {
overall.withdrawn++
yearSummary.withdrawn++
} else { } else {
overall.regular++ overall.regular++
yearSummary.regular++ yearSummary.regular++
overall.regularByReview[r.ReviewStatus]++
yearSummary.regularByReview[r.ReviewStatus]++
} }
if len(r.GHSAs) == 0 && r.CVEMetadata == nil { if len(r.GHSAs) == 0 && r.CVEMetadata == nil {