From a75c727173e7b8faaf703e0ffdaf8f530237b593 Mon Sep 17 00:00:00 2001 From: Tatiana Bradley Date: Tue, 4 Jun 2024 16:34:49 -0400 Subject: [PATCH] internal/report: add lint check for source Add a lint check to ensure that original reports created by the Go team are always marked REVIEWED. Change-Id: I5d72998be1597e42ec5ae5e05d4a5d9a4324cb40 Reviewed-on: https://go-review.googlesource.com/c/vulndb/+/590276 LUCI-TryBot-Result: Go LUCI Reviewed-by: Damien Neil --- internal/report/lint.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/internal/report/lint.go b/internal/report/lint.go index 9b0e45c2..3af0eaed 100644 --- a/internal/report/lint.go +++ b/internal/report/lint.go @@ -259,6 +259,15 @@ func (r *Report) lintReviewStatus(l *linter) { } } +func (r *Report) lintSource(l *linter) { + if r.SourceMeta == nil { + return + } + if !r.IsReviewed() && r.SourceMeta.ID == sourceGoTeam { + l.Errorf("source: if id=%s, report must be %s", sourceGoTeam, Reviewed) + } +} + func (r *Report) countAdvisories() int { advisoryCount := 0 for _, ref := range r.References { @@ -496,6 +505,7 @@ func (r *Report) lint(pc *proxy.Client) []string { r.lintReferences(l) r.lintReviewStatus(l) + r.lintSource(l) if r.hasTODOs() { l.Error("contains one or more TODOs")