Skip to content

Commit

Permalink
fix: still support old vscode webview
Browse files Browse the repository at this point in the history
  • Loading branch information
teodora-sandu committed Jun 27, 2024
1 parent b1cf2ee commit 517d986
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
14 changes: 8 additions & 6 deletions infrastructure/oss/template/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Security-Policy"
content="default-src 'self' 'none'; style-src 'self' 'nonce-${nonce}'; script-src 'nonce-${nonce}';">
content="default-src 'self' ${cspSource}; style-src 'self' 'nonce-${nonce}' ${cspSource}; script-src 'nonce-${nonce}' ${cspSource};">

<style nonce="${nonce}">
.suggestion {
Expand Down Expand Up @@ -97,6 +97,8 @@

</style>

${headerEnd}

${ideStyle}
</head>

Expand All @@ -110,7 +112,7 @@
<div class="identifiers">
{{.IssueType}}
{{if gt (len .CVEs) 0}}
<span class="delimiter">|</span>
<span class="delimiter"> </span>
{{range $index, $cve := .CVEs}}
<a class="cve styled-link" target="_blank" rel="noopener noreferrer"
href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=$cve">{{$cve}}</a>
Expand All @@ -119,7 +121,7 @@
{{end}}

{{if gt (len .CWEs) 0}}
<span class="delimiter">|</span>
<span class="delimiter"> </span>
{{range $index, $cwe := .CWEs}}
<a class="cwe styled-link" target="_blank" rel="noopener noreferrer"
href="https://cwe.mitre.org/data/definitions/{{trimCWEPrefix $cwe}}.html">{{$cwe}}</a>
Expand All @@ -128,11 +130,11 @@
{{end}}

{{if gt (len .CVSSv4) 0}}
<span class="delimiter">|</span>
<span>{{.CVSSv4}}</span>
<span class="delimiter"> </span>
<span>CVSS {{.CVSSv4}}</span>
{{end}}

<span class="delimiter">|</span>
<span class="delimiter"> </span>
<a class="styled-link" target="_blank" rel="noopener noreferrer"
href="https://snyk.io/vuln/{{.IssueId}}">{{.IssueId}}</a>
</div>
Expand Down
10 changes: 5 additions & 5 deletions internal/html/html.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TrimCWEPrefix(cwe string) string {
}

func GetLessonIconSvg() template.HTML {
return template.HTML(`<svg width="17" height="14" viewBox="0 0 17 14" fill="none" xmlns="http://www.w3.org/2000/svg">
return template.HTML(`<svg class="icon" width="17" height="14" viewBox="0 0 17 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M8.25 0L0 4.5L3 6.135V10.635L8.25 13.5L13.5 10.635V6.135L15 5.3175V10.5H16.5V4.5L8.25 0ZM13.365 4.5L8.25 7.29L3.135 4.5L8.25 1.71L13.365 4.5ZM12 9.75L8.25 11.79L4.5 9.75V6.9525L8.25 9L12 6.9525V9.75Z" fill="#888"/>
</svg>
`)
Expand All @@ -46,22 +46,22 @@ func GetLessonIconSvg() template.HTML {
func GetSeverityIconSvg(issue snyk.Issue) template.HTML {
switch issue.Severity {
case snyk.Critical:
return template.HTML(`<svg id="critical" fill="none" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 16 16">
return template.HTML(`<svg id="severity-icon" class="icon critical" fill="none" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 16 16">
<rect width="16" height="16" rx="2" fill="#AB1A1A"/>
<path d="M9.975 9.64h2.011a3.603 3.603 0 0 1-.545 1.743 3.24 3.24 0 0 1-1.338 1.19c-.57.284-1.256.427-2.06.427-.627 0-1.19-.107-1.688-.32a3.594 3.594 0 0 1-1.278-.936 4.158 4.158 0 0 1-.801-1.47C4.092 9.7 4 9.057 4 8.345v-.675c0-.712.094-1.356.283-1.93a4.255 4.255 0 0 1 .82-1.476 3.657 3.657 0 0 1 1.286-.936A4.114 4.114 0 0 1 8.057 3c.817 0 1.505.147 2.066.44.565.295 1.002.7 1.312 1.217.314.516.502 1.104.565 1.763H9.982c-.023-.392-.101-.723-.236-.995a1.331 1.331 0 0 0-.612-.621c-.27-.143-.628-.214-1.077-.214-.336 0-.63.062-.881.187a1.632 1.632 0 0 0-.633.568c-.17.254-.298.574-.383.962a6.61 6.61 0 0 0-.121 1.349v.688c0 .503.038.946.114 1.33.076.378.193.699.35.961.161.259.368.454.619.588.256.13.563.194.922.194.421 0 .769-.067 1.043-.2a1.39 1.39 0 0 0 .625-.595c.148-.263.236-.59.263-.982Z" fill="#fff"/>
</svg>`)
case snyk.High:
return template.HTML(`<svg id="high" fill="none" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 16 16">
return template.HTML(`<svg id="severity-icon" class="icon high" fill="none" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 16 16">
<rect width="16" height="16" rx="2" fill="#CE5019"/>
<path d="M10.5 7v2h-5V7h5ZM6 3v10H4V3h2Zm6 0v10h-2V3h2Z" fill="#fff"/>
</svg>`)
case snyk.Medium:
return template.HTML(`<svg id="medium" fill="none" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 16 16">
return template.HTML(`<svg id="severity-icon" class="icon medium" fill="none" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 16 16">
<rect width="16" height="16" rx="2" fill="#D68000"/>
<path d="M3 3h2l2.997 7.607L11 3h2L9 13H7L3 3Zm0 0h2v10l-2-.001V3.001Zm8 0h2V13h-2V3Z" fill="#fff"/>
</svg>`)
case snyk.Low:
return template.HTML(`<svg id="low" fill="none" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 16 16">
return template.HTML(`<svg id="severity-icon" class="icon low" fill="none" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 16 16">
<rect width="16" height="16" rx="2" fill="#88879E"/>
<path d="M11 11v2H6.705v-2H11ZM7 3v10H5V3h2Z" fill="#fff"/>
</svg>`)
Expand Down

0 comments on commit 517d986

Please sign in to comment.