diff --git a/gcp/website/frontend3/src/go/templates/vulnerability.html b/gcp/website/frontend3/src/go/templates/vulnerability.html index c9702d3a60e..8acfee4ebb6 100644 --- a/gcp/website/frontend3/src/go/templates/vulnerability.html +++ b/gcp/website/frontend3/src/go/templates/vulnerability.html @@ -103,12 +103,14 @@

{{ if .IsCVSS }} {{ .Rating }} {{ .Type }} - {{ .Score }} + {{ if .Source }}(Source: {{ .Source }}){{ end }} {{ if .CalculatorURL }} CVSS Calculator {{ end }} {{ else }} {{ .Type }} - {{ .Score }} + {{ if .Source }}(Source: {{ .Source }}){{ end }} {{ end }} {{ end }} @@ -222,12 +224,14 @@

Severity

{{ if .IsCVSS }} {{ .Rating }} {{ .Type }} - {{ .Score }} + {{ if .Source }}(Source: {{ .Source }}){{ end }} {{ if .CalculatorURL }} CVSS Calculator {{ end }} {{ else }} {{ .Type }} - {{ .Score }} + {{ if .Source }}(Source: {{ .Source }}){{ end }} {{ end }} {{ end }} @@ -379,12 +383,14 @@

{{ if .IsCVSS }} {{ .Rating }} {{ .Type }} - {{ .Score }} + {{ if .Source }}(Source: {{ .Source }}){{ end }} {{ if .CalculatorURL }} CVSS Calculator {{ end }} {{ else }} {{ .Type }} - {{ .Score }} + {{ if .Source }}(Source: {{ .Source }}){{ end }} {{ end }} {{ end }} diff --git a/gcp/website/frontend3/src/templates/vulnerability.html b/gcp/website/frontend3/src/templates/vulnerability.html index 915032ce1db..6ffb9794f71 100644 --- a/gcp/website/frontend3/src/templates/vulnerability.html +++ b/gcp/website/frontend3/src/templates/vulnerability.html @@ -107,10 +107,12 @@

{% if item | is_cvss %} {{ item | display_severity_rating }} {{ item.type }} - {{ item.score }} + {% if item.source %}(Source: {{ item.source }}){% endif %} CVSS Calculator {% else %} {{ item.type }} - {{ item.score }} + {% if item.source %}(Source: {{ item.source }}){% endif %} {% endif %} {% endfor -%} @@ -227,10 +229,12 @@

Severity

{% if item | is_cvss %} {{ item | display_severity_rating }} {{ item.type }} - {{ item.score }} + {% if item.source %}(Source: {{ item.source }}){% endif %} CVSS Calculator {% else %} {{ item.type }} - {{ item.score }} + {% if item.source %}(Source: {{ item.source }}){% endif %} {% endif %} {% endfor -%} @@ -400,10 +404,12 @@

{% if item | is_cvss %} {{ item | display_severity_rating }} {{ item.type }} - {{ item.score }} + {% if item.source %}(Source: {{ item.source }}){% endif %} CVSS Calculator {% else %} {{ item.type }} - {{ item.score }} + {% if item.source %}(Source: {{ item.source }}){% endif %} {% endif %} {% endfor -%} diff --git a/gcp/website/testdata/osv/CVE-2021-44228.json b/gcp/website/testdata/osv/CVE-2021-44228.json index 5519e3ec505..90fa5d2d765 100644 --- a/gcp/website/testdata/osv/CVE-2021-44228.json +++ b/gcp/website/testdata/osv/CVE-2021-44228.json @@ -3,6 +3,13 @@ "modified": "2025-02-04T00:00:00Z", "published": "2023-08-14T00:00:00Z", "summary": "Log4Shell demo entry", + "severity": [ + { + "type": "CVSS_V3", + "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", + "source": "NVD" + } + ], "affected": [] } diff --git a/go/internal/website/vulnerability_models.go b/go/internal/website/vulnerability_models.go index 74e3c9f56ad..0af0c0b70dc 100644 --- a/go/internal/website/vulnerability_models.go +++ b/go/internal/website/vulnerability_models.go @@ -11,6 +11,7 @@ import ( type SeverityDisplay struct { Type string Score string + Source string IsCVSS bool Level string // e.g. "low", "medium", "high", "critical" Rating string // e.g. "7.5 (High)" or "7.5" diff --git a/go/internal/website/vulnerability_view.go b/go/internal/website/vulnerability_view.go index d3d3ada1852..142ec0e527a 100644 --- a/go/internal/website/vulnerability_view.go +++ b/go/internal/website/vulnerability_view.go @@ -156,7 +156,12 @@ func (v VulnerabilityPageData) Severities() []SeverityDisplay { id := v.Vulnerability.GetId() displays := make([]SeverityDisplay, 0, len(severities)) for _, sev := range severities { + source := "" + if sev.GetSource() != osvschema.Severity_SOURCE_UNSPECIFIED { + source = sev.GetSource().String() + } if display, ok := ParseSeverityDisplay(sev.GetType(), sev.GetScore(), id); ok { + display.Source = source displays = append(displays, display) } else { // This probably only happens if the CVSS score itself is wrong. @@ -166,6 +171,7 @@ func (v VulnerabilityPageData) Severities() []SeverityDisplay { Level: "invalid", Type: sev.GetType().String(), Score: sev.GetScore(), + Source: source, Rating: "Invalid Severity Rating", }) } diff --git a/go/internal/website/vulnerability_view_test.go b/go/internal/website/vulnerability_view_test.go index 4e9593bbb44..bdcb7407c53 100644 --- a/go/internal/website/vulnerability_view_test.go +++ b/go/internal/website/vulnerability_view_test.go @@ -11,16 +11,20 @@ func TestSeverities(t *testing.T) { name string sevType osvschema.Severity_Type score string + source osvschema.Severity_Source wantCalcURL string wantLevel string + wantSource string wantCount int }{ { name: "CVSS v2.0 valid vector", sevType: osvschema.Severity_CVSS_V2, score: "AV:N/AC:L/Au:N/C:P/I:P/A:P", + source: osvschema.Severity_NVD, wantCalcURL: firstCVSSCalculatorBaseURL + "/2.0#AV:N/AC:L/Au:N/C:P/I:P/A:P", wantLevel: "", + wantSource: "NVD", wantCount: 1, }, { @@ -64,8 +68,9 @@ func TestSeverities(t *testing.T) { Id: "GHSA-1234-abcd", Severity: []*osvschema.Severity{ { - Type: tt.sevType, - Score: tt.score, + Type: tt.sevType, + Score: tt.score, + Source: tt.source, }, }, }, @@ -83,6 +88,9 @@ func TestSeverities(t *testing.T) { if d.Level != tt.wantLevel { t.Errorf("Level = %q, want %q", d.Level, tt.wantLevel) } + if d.Source != tt.wantSource { + t.Errorf("Source = %q, want %q", d.Source, tt.wantSource) + } } }) }