|
12 | 12 |
|
13 | 13 | const logContainer = /** @type {HTMLElement} */ (document.querySelector('.log'));
|
14 | 14 | const vulnsContainer = /** @type {HTMLElement} */ (document.querySelector('.vulns'));
|
| 15 | + const unaffectingContainer = /** @type {HTMLElement} */ (document.querySelector('.unaffecting')); |
15 | 16 |
|
16 | 17 | vulnsContainer.addEventListener('click', (event) => {
|
17 | 18 | let node = event && event.target;
|
|
37 | 38 | }
|
38 | 39 |
|
39 | 40 | function snapshotContent() {
|
40 |
| - return vulnsContainer.innerHTML; |
| 41 | + const res = { |
| 42 | + 'log': logContainer.innerHTML, |
| 43 | + 'vulns': vulnsContainer.innerHTML, |
| 44 | + 'unaffecting': unaffectingContainer.innerHTML |
| 45 | + }; |
| 46 | + return JSON.stringify(res); |
41 | 47 | }
|
42 | 48 |
|
43 | 49 | /**
|
|
61 | 67 | return durationMillisec ? `${startDate} (took ${durationMillisec} msec)` : `${startDate}`;
|
62 | 68 | }
|
63 | 69 |
|
| 70 | + const vulns = json.Vuln || []; |
| 71 | + const affecting = vulns.filter((v) => v.CallStackSummaries?.length); |
| 72 | + const unaffecting = vulns.filter((v) => !v.CallStackSummaries?.length); |
| 73 | + |
64 | 74 | runLog.innerHTML = `
|
65 | 75 | <tr><td>Dir:</td><td>${json.Dir || ''}</td></tr>
|
66 | 76 | <tr><td>Pattern:</td><td>${json.Pattern || ''}</td></tr>
|
67 |
| -<tr><td>Analyzed at:</td><td>${timeinfo(json.Start, json.Duration)}</td></tr>`; |
| 77 | +<tr><td>Analyzed at:</td><td>${timeinfo(json.Start, json.Duration)}</td></tr> |
| 78 | +<tr><td>Found ${affecting?.length || 0} known vulnerabilities</td></tr>`; |
68 | 79 | logContainer.appendChild(runLog);
|
69 | 80 |
|
70 |
| - const vulns = json.Vuln || []; |
71 | 81 | vulnsContainer.innerHTML = '';
|
72 |
| - |
73 |
| - vulns.forEach((vuln) => { |
| 82 | + affecting.forEach((vuln) => { |
74 | 83 | const element = document.createElement('div');
|
75 | 84 | element.className = 'vuln';
|
76 | 85 | vulnsContainer.appendChild(element);
|
|
92 | 101 | details.className = 'vuln-details'
|
93 | 102 | details.innerHTML = `
|
94 | 103 | <tr><td>Package</td><td>${vuln.PkgPath}</td></tr>
|
95 |
| - <tr><td>Current Version</td><td>${moduleVersion(vuln.ModPath, vuln.CurrentVersion)}</td></tr> |
| 104 | + <tr><td>Found in Version</td><td>${moduleVersion(vuln.ModPath, vuln.CurrentVersion)}</td></tr> |
96 | 105 | <tr><td>Fixed Version</td><td>${moduleVersion(vuln.ModPath, vuln.FixedVersion)}</td></tr>
|
97 | 106 | <tr><td>Affecting</td><td>${vuln.AffectedPkgs?.join('<br>')}</td></tr>
|
98 | 107 | `;
|
|
131 | 140 | examples.appendChild(callstacksContainer);
|
132 | 141 | element.appendChild(examples);
|
133 | 142 | });
|
| 143 | + |
| 144 | + unaffectingContainer.innerText = ''; |
| 145 | + if (unaffecting.length > 0) { |
| 146 | + unaffectingContainer.innerHTML = '<hr></hr><p>These vulnerabilities exist in required modules, but no vulnerable symbols are used.<br>No action is required. For more information, visit <a href="https://pkg.go.dev/vuln">https://pkg.go.dev/vuln</a></p>'; |
| 147 | + |
| 148 | + const details = document.createElement('table'); |
| 149 | + unaffecting.forEach((vuln) => { |
| 150 | + const row = document.createElement('tr'); |
| 151 | + row.className = 'vuln-details' |
| 152 | + row.innerHTML = `<tr><td>${vuln.ModPath}</td><td><a href="${vuln.URL}">${vuln.ID}</a></td></tr>`; |
| 153 | + details.appendChild(row); |
| 154 | + }); |
| 155 | + unaffectingContainer.appendChild(details); |
| 156 | + } |
134 | 157 | }
|
135 | 158 |
|
136 | 159 | // Message Passing between Extension and Webview
|
|
0 commit comments