add scan by info in the scan report summary

- fix #9795

Signed-off-by: Steven Zou <szou@vmware.com>
This commit is contained in:
Steven Zou 2019-11-08 17:33:45 +08:00
parent b1a756e34b
commit 7bdf24961c
3 changed files with 9 additions and 0 deletions

View File

@ -156,5 +156,7 @@ func GenerateNativeSummary(r *scan.Report, options ...Option) (interface{}, erro
sum.Severity = overallSev
}
sum.Scanner = rp.Scanner
return sum, nil
}

View File

@ -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 ...

View File

@ -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