4
4
"sort"
5
5
"strings"
6
6
7
+ "github.com/google/osv-scanner/internal/output"
7
8
"github.com/google/osv-scanner/internal/sourceanalysis"
8
9
"github.com/google/osv-scanner/pkg/grouper"
9
10
"github.com/google/osv-scanner/pkg/models"
@@ -22,7 +23,7 @@ func buildVulnerabilityResults(
22
23
licensesResp [][]models.License ,
23
24
actions ScannerActions ,
24
25
) models.VulnerabilityResults {
25
- output := models.VulnerabilityResults {
26
+ results := models.VulnerabilityResults {
26
27
Results : []models.PackageSource {},
27
28
}
28
29
groupedBySource := map [models.SourceInfo ][]models.PackageVulns {}
@@ -57,6 +58,9 @@ func buildVulnerabilityResults(
57
58
includePackage = true
58
59
pkg .Vulnerabilities = vulnsResp .Results [i ].Vulns
59
60
pkg .Groups = grouper .Group (grouper .ConvertVulnerabilityToIDAliases (pkg .Vulnerabilities ))
61
+ for i , group := range pkg .Groups {
62
+ pkg .Groups [i ].MaxSeverity = output .MaxSeverity (group , pkg )
63
+ }
60
64
}
61
65
if len (actions .ScanLicensesAllowlist ) > 0 {
62
66
pkg .Licenses = licensesResp [i ]
@@ -83,28 +87,28 @@ func buildVulnerabilityResults(
83
87
84
88
for source , packages := range groupedBySource {
85
89
sourceanalysis .Run (r , source , packages , actions .CallAnalysisStates )
86
- output .Results = append (output .Results , models.PackageSource {
90
+ results .Results = append (results .Results , models.PackageSource {
87
91
Source : source ,
88
92
Packages : packages ,
89
93
})
90
94
}
91
95
92
- sort .Slice (output .Results , func (i , j int ) bool {
93
- if output .Results [i ].Source .Path == output .Results [j ].Source .Path {
94
- return output .Results [i ].Source .Type < output .Results [j ].Source .Type
96
+ sort .Slice (results .Results , func (i , j int ) bool {
97
+ if results .Results [i ].Source .Path == results .Results [j ].Source .Path {
98
+ return results .Results [i ].Source .Type < results .Results [j ].Source .Type
95
99
}
96
100
97
- return output .Results [i ].Source .Path < output .Results [j ].Source .Path
101
+ return results .Results [i ].Source .Path < results .Results [j ].Source .Path
98
102
})
99
103
100
104
if len (actions .ScanLicensesAllowlist ) > 0 || actions .ScanLicensesSummary {
101
- output .ExperimentalAnalysisConfig .Licenses .Summary = actions .ScanLicensesSummary
105
+ results .ExperimentalAnalysisConfig .Licenses .Summary = actions .ScanLicensesSummary
102
106
allowlist := make ([]models.License , len (actions .ScanLicensesAllowlist ))
103
107
for i , l := range actions .ScanLicensesAllowlist {
104
108
allowlist [i ] = models .License (l )
105
109
}
106
- output .ExperimentalAnalysisConfig .Licenses .Allowlist = allowlist
110
+ results .ExperimentalAnalysisConfig .Licenses .Allowlist = allowlist
107
111
}
108
112
109
- return output
113
+ return results
110
114
}
0 commit comments