Skip to content

Commit 62516a4

Browse files
committed
media/vulncheckView: use codicons to distinguish severity
We differentiate two classes of vulnerabilities and add Warning/Info icons. - Warning for affecting vulnerabilities (vulnerable symbols are being used). - Info for unaffecting vulnerabilities (vulnerable symbols are not being used). Change-Id: I76b5df80d24eccb38c5744ece8a49dae8de698b7 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/429238 Reviewed-by: Jamal Carvalho <[email protected]> TryBot-Result: kokoro <[email protected]> Run-TryBot: Hyang-Ah Hana Kim <[email protected]>
1 parent cf7c1cc commit 62516a4

File tree

5 files changed

+37
-3
lines changed

5 files changed

+37
-3
lines changed

media/vulncheckView.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,20 @@
1515
padding-bottom: 1em;
1616
}
1717

18+
.vuln-icon-info, .vuln-icon-warning {
19+
padding-right: 1em;
20+
font-size: 14px;
21+
display: inline;
22+
}
23+
24+
.vuln-icon-info {
25+
color: var(--vscode-list-warningForeground);
26+
}
27+
28+
.vuln-icon-warning {
29+
color: var(--vscode-list-errorForeground);
30+
}
31+
1832
.vuln-desc {
1933
padding-top: 0.5em;
2034
padding-bottom: 0.5em;

media/vulncheckView.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ Found ${affecting?.length || 0} known vulnerabilities.`;
114114

115115
// TITLE - Vuln ID
116116
const title = document.createElement('h2');
117-
title.innerHTML = `<a href="${vuln.URL}">${vuln.ID}</a>`;
117+
title.innerHTML = `<div class="vuln-icon-warning"><i class="codicon codicon-warning"></i></div><a href="${vuln.URL}">${vuln.ID}</a>`;
118118
title.className = 'vuln-title';
119119
element.appendChild(title);
120120

@@ -191,7 +191,7 @@ for details.
191191

192192
// TITLE - Vuln ID
193193
const title = document.createElement('h2');
194-
title.innerHTML = `<a href="${vuln.URL}">${vuln.ID}</a>`;
194+
title.innerHTML = `<div class="vuln-icon-info"><i class="codicon codicon-info"></i></div><a href="${vuln.URL}">${vuln.ID}</a>`;
195195
title.className = 'vuln-title';
196196
element.appendChild(title);
197197

package-lock.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
},
5050
"extensionDependencies": [],
5151
"dependencies": {
52+
"@vscode/codicons": "0.0.32",
5253
"diff": "4.0.2",
5354
"glob": "7.1.7",
5455
"json-rpc2": "2.0.0",

src/goVulncheck.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ export class VulncheckResultViewProvider implements vscode.CustomTextEditorProvi
8181
const styleResetUri = webview.asWebviewUri(vscode.Uri.joinPath(mediaUri, 'reset.css'));
8282
const styleVSCodeUri = webview.asWebviewUri(vscode.Uri.joinPath(mediaUri, 'vscode.css'));
8383
const styleMainUri = webview.asWebviewUri(vscode.Uri.joinPath(mediaUri, 'vulncheckView.css'));
84+
const codiconsUri = webview.asWebviewUri(
85+
vscode.Uri.joinPath(this.extensionUri, 'node_modules', '@vscode/codicons', 'dist', 'codicon.css')
86+
);
8487

8588
// Use a nonce to whitelist which scripts can be run
8689
const nonce = getNonce();
@@ -94,11 +97,15 @@ export class VulncheckResultViewProvider implements vscode.CustomTextEditorProvi
9497
Use a content security policy to only allow loading images from https or from our extension directory,
9598
and only allow scripts that have a specific nonce.
9699
-->
97-
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src ${webview.cspSource}; style-src ${webview.cspSource}; script-src 'nonce-${nonce}';">
100+
<!--
101+
Use a content security policy to only allow loading specific resources in the webview
102+
-->
103+
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; font-src ${webview.cspSource}; style-src ${webview.cspSource}; script-src 'nonce-${nonce}';">
98104
<meta name="viewport" content="width=device-width, initial-scale=1.0">
99105
<link href="${styleResetUri}" rel="stylesheet" />
100106
<link href="${styleVSCodeUri}" rel="stylesheet" />
101107
<link href="${styleMainUri}" rel="stylesheet" />
108+
<link href="${codiconsUri}" rel="stylesheet" />
102109
<title>Vulnerability Report - govulncheck</title>
103110
</head>
104111
<body>

0 commit comments

Comments
 (0)