fix(gost/debian): show all severities that appeared (#1914)

This commit is contained in:
MaineK00n
2024-05-16 18:01:01 +09:00
committed by GitHub
parent 61c39637f2
commit e4728e3881
4 changed files with 231 additions and 40 deletions

View File

@@ -560,15 +560,29 @@ func (v VulnInfo) Cvss3Scores() (values []CveContentCvss) {
if conts, found := v.CveContents[ctype]; found {
for _, cont := range conts {
if cont.Cvss3Severity != "" {
values = append(values, CveContentCvss{
Type: ctype,
Value: Cvss{
Type: CVSS3,
Score: severityToCvssScoreRoughly(cont.Cvss3Severity),
CalculatedBySeverity: true,
Severity: strings.ToUpper(cont.Cvss3Severity),
},
})
switch ctype {
case DebianSecurityTracker: // Multiple Severities(sorted) may be listed, and the largest one is used.
ss := strings.Split(cont.Cvss3Severity, "|")
values = append(values, CveContentCvss{
Type: ctype,
Value: Cvss{
Type: CVSS3,
Score: severityToCvssScoreRoughly(ss[len(ss)-1]),
CalculatedBySeverity: true,
Severity: strings.ToUpper(cont.Cvss3Severity),
},
})
default:
values = append(values, CveContentCvss{
Type: ctype,
Value: Cvss{
Type: CVSS3,
Score: severityToCvssScoreRoughly(cont.Cvss3Severity),
CalculatedBySeverity: true,
Severity: strings.ToUpper(cont.Cvss3Severity),
},
})
}
}
}
}

View File

@@ -698,6 +698,26 @@ func TestCvss3Scores(t *testing.T) {
},
},
},
// [2] Multiple Severities in Debian Security Tracker
{
in: VulnInfo{
CveContents: CveContents{
DebianSecurityTracker: []CveContent{{
Type: DebianSecurityTracker,
Cvss3Severity: "not yet assigned|low",
}},
},
},
out: []CveContentCvss{{
Type: DebianSecurityTracker,
Value: Cvss{
Type: CVSS3,
Score: 3.9,
CalculatedBySeverity: true,
Severity: "NOT YET ASSIGNED|LOW",
},
}},
},
// Empty
{
in: VulnInfo{},