Skip to content

Commit

Permalink
cmd/inspect: add data on withdrawn and (un)reviewed reports
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
tatianab committed Jul 15, 2024
1 parent bbfc2dc commit 61369c8
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions cmd/inspect/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ func display(overall *summary, byYear map[int]*summary) {
headings()
data("Go reports", 0, func(s *summary) int { return s.reports })
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 })
for _, er := range report.ExcludedReasons {
data(string(er), 2, func(s *summary) int { return s.excludedByReason[er] })
Expand Down Expand Up @@ -138,15 +142,17 @@ func displayGHSAs(ghsas []string) {
}

type summary struct {
reports, regular, excluded, noGHSA, firstParty int
ghsas int
ghsasNotInVDB []string
excludedByReason map[report.ExcludedReason]int
reports, regular, withdrawn, excluded, noGHSA, firstParty int
ghsas int
ghsasNotInVDB []string
excludedByReason map[report.ExcludedReason]int
regularByReview map[report.ReviewStatus]int
}

func newSummary() *summary {
return &summary{
excludedByReason: make(map[report.ExcludedReason]int),
regularByReview: make(map[report.ReviewStatus]int),
}
}

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

yearSummary.excluded++
yearSummary.excludedByReason[r.Excluded]++
} else if r.Withdrawn != nil {
overall.withdrawn++
yearSummary.withdrawn++
} else {
overall.regular++
yearSummary.regular++

overall.regularByReview[r.ReviewStatus]++
yearSummary.regularByReview[r.ReviewStatus]++
}

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

0 comments on commit 61369c8

Please sign in to comment.