From 7bdf24961ccd98dc20e7f81934763d46e7a4dfb4 Mon Sep 17 00:00:00 2001 From: Steven Zou Date: Fri, 8 Nov 2019 17:33:45 +0800 Subject: [PATCH] add scan by info in the scan report summary - fix #9795 Signed-off-by: Steven Zou --- src/pkg/scan/report/summary.go | 2 ++ src/pkg/scan/report/summary_test.go | 4 ++++ src/pkg/scan/vuln/summary.go | 3 +++ 3 files changed, 9 insertions(+) diff --git a/src/pkg/scan/report/summary.go b/src/pkg/scan/report/summary.go index cbd611b17..98628760d 100644 --- a/src/pkg/scan/report/summary.go +++ b/src/pkg/scan/report/summary.go @@ -156,5 +156,7 @@ func GenerateNativeSummary(r *scan.Report, options ...Option) (interface{}, erro sum.Severity = overallSev } + sum.Scanner = rp.Scanner + return sum, nil } diff --git a/src/pkg/scan/report/summary_test.go b/src/pkg/scan/report/summary_test.go index 5d1669f9a..70f4cc77c 100644 --- a/src/pkg/scan/report/summary_test.go +++ b/src/pkg/scan/report/summary_test.go @@ -100,6 +100,10 @@ func (suite *SummaryTestSuite) TestSummaryGenerateSummaryNoOptions() { suite.Equal(vuln.High, nativeSummary.Severity) suite.Nil(nativeSummary.CVEBypassed) suite.Equal(2, nativeSummary.Summary.Total) + + suite.Equal("Clair", nativeSummary.Scanner.Name) + suite.Equal("Harbor", nativeSummary.Scanner.Vendor) + suite.Equal("0.1.0", nativeSummary.Scanner.Version) } // TestSummaryGenerateSummaryWithOptions ... diff --git a/src/pkg/scan/vuln/summary.go b/src/pkg/scan/vuln/summary.go index 83cbc4e83..b9da462cb 100644 --- a/src/pkg/scan/vuln/summary.go +++ b/src/pkg/scan/vuln/summary.go @@ -16,6 +16,8 @@ package vuln import ( "time" + + v1 "github.com/goharbor/harbor/src/pkg/scan/rest/v1" ) // NativeReportSummary is the default supported scan report summary model. @@ -29,6 +31,7 @@ type NativeReportSummary struct { CVEBypassed []string `json:"-"` StartTime time.Time `json:"start_time"` EndTime time.Time `json:"end_time"` + Scanner *v1.Scanner `json:"scanner,omitempty"` } // VulnerabilitySummary contains the total number of the found vulnerabilities number