Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions gcp/website/frontend3/src/go/templates/vulnerability.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,14 @@ <h1 class="title">
{{ if .IsCVSS }}
<span class="severity-level severity-{{ .Level }}">{{ .Rating }}</span>
{{ .Type }} - {{ .Score }}
{{ if .Source }}(Source: {{ .Source }}){{ end }}
{{ if .CalculatorURL }}
<a href="{{ .CalculatorURL }}" target="_blank" rel="nofollow noopener noreferrer">
CVSS Calculator</a>
{{ end }}
{{ else }}
<span class="severity-level severity-invalid">{{ .Type }} - {{ .Score }}</span>
{{ if .Source }}(Source: {{ .Source }}){{ end }}
{{ end }}
</li>
{{ end }}
Expand Down Expand Up @@ -222,12 +224,14 @@ <h3 class="mdc-layout-grid__cell--span-3">Severity</h3>
{{ if .IsCVSS }}
<span class="severity-level severity-{{ .Level }}">{{ .Rating }}</span>
{{ .Type }} - {{ .Score }}
{{ if .Source }}(Source: {{ .Source }}){{ end }}
{{ if .CalculatorURL }}
<a href="{{ .CalculatorURL }}" target="_blank" rel="nofollow noopener noreferrer">
CVSS Calculator</a>
{{ end }}
{{ else }}
<span class="severity-level severity-invalid">{{ .Type }} - {{ .Score }}</span>
{{ if .Source }}(Source: {{ .Source }}){{ end }}
{{ end }}
</li>
{{ end }}
Expand Down Expand Up @@ -379,12 +383,14 @@ <h3 class="mdc-layout-grid__cell--span-3">
{{ if .IsCVSS }}
<span class="severity-level severity-{{ .Level }}">{{ .Rating }}</span>
{{ .Type }} - {{ .Score }}
{{ if .Source }}(Source: {{ .Source }}){{ end }}
{{ if .CalculatorURL }}
<a href="{{ .CalculatorURL }}" target="_blank" rel="nofollow noopener noreferrer">
CVSS Calculator</a>
{{ end }}
{{ else }}
<span class="severity-level severity-invalid">{{ .Type }} - {{ .Score }}</span>
{{ if .Source }}(Source: {{ .Source }}){{ end }}
{{ end }}
</li>
{{ end }}
Expand Down
6 changes: 6 additions & 0 deletions gcp/website/frontend3/src/templates/vulnerability.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,12 @@ <h1 class="title">
{% if item | is_cvss %}
<span class="severity-level severity-{{ item | severity_level }}">{{ item | display_severity_rating }}</span>
{{ item.type }} - {{ item.score }}
{% if item.source %}(Source: {{ item.source }}){% endif %}
<a href="{{ item | cvss_calculator_url }}" target="_blank" rel="nofollow noopener noreferrer">
CVSS Calculator</a>
{% else %}
<span class="severity-level severity-invalid">{{ item.type }} - {{ item.score }}</span>
{% if item.source %}(Source: {{ item.source }}){% endif %}
{% endif %}
</li>
{% endfor -%}
Expand Down Expand Up @@ -227,10 +229,12 @@ <h3 class="mdc-layout-grid__cell--span-3">Severity</h3>
{% if item | is_cvss %}
<span class="severity-level severity-{{ item | severity_level }}">{{ item | display_severity_rating }}</span>
{{ item.type }} - {{ item.score }}
{% if item.source %}(Source: {{ item.source }}){% endif %}
<a href="{{ item | cvss_calculator_url }}" target="_blank" rel="nofollow noopener noreferrer">
CVSS Calculator</a>
{% else %}
<span class="severity-level severity-invalid">{{ item.type }} - {{ item.score }}</span>
{% if item.source %}(Source: {{ item.source }}){% endif %}
{% endif %}
</li>
{% endfor -%}
Expand Down Expand Up @@ -400,10 +404,12 @@ <h3 class="mdc-layout-grid__cell--span-3">
{% if item | is_cvss %}
<span class="severity-level severity-{{ item | severity_level }}">{{ item | display_severity_rating }}</span>
{{ item.type }} - {{ item.score }}
{% if item.source %}(Source: {{ item.source }}){% endif %}
<a href="{{ item | cvss_calculator_url }}" target="_blank" rel="nofollow noopener noreferrer">
CVSS Calculator</a>
{% else %}
<span class="severity-level severity-invalid">{{ item.type }} - {{ item.score }}</span>
{% if item.source %}(Source: {{ item.source }}){% endif %}
{% endif %}
</li>
{% endfor -%}
Expand Down
7 changes: 7 additions & 0 deletions gcp/website/testdata/osv/CVE-2021-44228.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": []
}

1 change: 1 addition & 0 deletions go/internal/website/vulnerability_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 6 additions & 0 deletions go/internal/website/vulnerability_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -166,6 +171,7 @@ func (v VulnerabilityPageData) Severities() []SeverityDisplay {
Level: "invalid",
Type: sev.GetType().String(),
Score: sev.GetScore(),
Source: source,
Rating: "Invalid Severity Rating",
})
}
Expand Down
12 changes: 10 additions & 2 deletions go/internal/website/vulnerability_view_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
{
Expand Down Expand Up @@ -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,
},
},
},
Expand All @@ -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)
}
}
})
}
Expand Down