cve-lite-cli 1.9.0 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +132 -84
- package/dist/index.js +97 -13
- package/dist/output/formatters.js +29 -9
- package/dist/output/html-reporter.js +110 -17
- package/dist/output/printers.js +75 -24
- package/dist/parsers/npm-lock-graph.js +231 -0
- package/dist/parsers/utils.js +5 -1
- package/dist/remediation/fix-commands.js +104 -5
- package/dist/remediation/npm-transitive-graph.js +123 -0
- package/dist/remediation/npm-transitive-resolution.js +221 -0
- package/dist/remediation/parent-upgrade.js +25 -9
- package/dist/scanner.js +115 -10
- package/dist/utils/finding.js +6 -0
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ import { spawn } from "node:child_process";
|
|
|
4
4
|
import { serializeFinding } from "./formatters.js";
|
|
5
5
|
import { LOGO_BASE64 } from "./logo-base64.js";
|
|
6
6
|
import { OWASP_LOGO_BASE64 } from "./owasp-logo-base64.js";
|
|
7
|
+
import { isMajorVersionBump } from "../utils/version.js";
|
|
7
8
|
export function buildReportData(params) {
|
|
8
9
|
return {
|
|
9
10
|
projectPath: params.projectPath,
|
|
@@ -27,6 +28,7 @@ export function renderHtmlReport(data) {
|
|
|
27
28
|
if (sev in counts)
|
|
28
29
|
counts[sev]++;
|
|
29
30
|
}
|
|
31
|
+
const noticesHtml = renderNotices(data.notes, data.warnings);
|
|
30
32
|
const fixPlanHtml = renderFixPlan(data.suggestedFixCommands);
|
|
31
33
|
const findingRowsHtml = data.findings.map(renderFindingRow).join("\n");
|
|
32
34
|
const dataJson = JSON.stringify(data)
|
|
@@ -58,6 +60,8 @@ body{background:#0d1117;color:#e6edf3;font-family:-apple-system,BlinkMacSystemFo
|
|
|
58
60
|
.header-links{display:flex;gap:8px}
|
|
59
61
|
.header-link{display:flex;align-items:center;gap:5px;font-size:12px;color:#8b949e;text-decoration:none;background:#21262d;border:1px solid #30363d;border-radius:6px;padding:5px 10px}
|
|
60
62
|
.header-link:hover{color:#58a6ff;border-color:#58a6ff}
|
|
63
|
+
button.header-link{cursor:pointer;border:1px solid #30363d;font:inherit;background:#21262d;color:#8b949e}
|
|
64
|
+
button.header-link:hover{color:#58a6ff;border-color:#58a6ff}
|
|
61
65
|
.header-link.owasp-link{color:#F68B1F;border-color:#F68B1F44}.header-link.owasp-link:hover{color:#F68B1F;border-color:#F68B1F;background:#F68B1F11}
|
|
62
66
|
.summary-bar{padding:20px 32px;display:flex;gap:12px;border-bottom:1px solid #21262d}
|
|
63
67
|
.sev-card{flex:1;background:#161b22;border:1px solid #30363d;border-radius:8px;padding:14px 16px;display:flex;flex-direction:column;gap:4px}
|
|
@@ -96,6 +100,10 @@ body{background:#0d1117;color:#e6edf3;font-family:-apple-system,BlinkMacSystemFo
|
|
|
96
100
|
.filter-btn{font-size:11px;border-radius:20px;padding:4px 12px;border:1px solid #30363d;background:transparent;color:#8b949e;cursor:pointer}
|
|
97
101
|
.filter-btn:hover{border-color:#58a6ff;color:#58a6ff}
|
|
98
102
|
.filter-btn.active{background:#1f6feb22;border-color:#58a6ff;color:#58a6ff}
|
|
103
|
+
.search-input{font-size:12px;background:#0d1117;border:1px solid #30363d;border-radius:6px;color:#e6edf3;padding:4px 10px;width:200px;outline:none}
|
|
104
|
+
.search-input::placeholder{color:#6b7280}
|
|
105
|
+
.search-input:focus{border-color:#58a6ff}
|
|
106
|
+
.no-results{text-align:center;padding:32px;color:#8b949e;font-size:13px;display:none}
|
|
99
107
|
.findings-table{width:100%;border-collapse:collapse}
|
|
100
108
|
.findings-table thead th{text-align:left;font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.4px;color:#8b949e;padding:10px 14px;border-bottom:1px solid #21262d;background:#161b22;cursor:pointer;white-space:nowrap;user-select:none}
|
|
101
109
|
.findings-table thead th:hover{color:#e6edf3}
|
|
@@ -137,6 +145,24 @@ body{background:#0d1117;color:#e6edf3;font-family:-apple-system,BlinkMacSystemFo
|
|
|
137
145
|
.fix-cmd-inline code{flex:1;font-family:monospace;font-size:12px;color:#3fb950}
|
|
138
146
|
.fix-cmd-inline .copy-btn{font-size:11px;color:#8b949e;background:#21262d;border:1px solid #30363d;border-radius:4px;padding:3px 8px;cursor:pointer}
|
|
139
147
|
.report-footer{margin:0 32px 32px;padding:12px 0;border-top:1px solid #21262d;display:flex;justify-content:space-between;font-size:11px;color:#8b949e}
|
|
148
|
+
.scan-notes{margin:0 32px 16px}
|
|
149
|
+
.scan-notes-toggle{display:flex;align-items:center;gap:6px;font-size:11px;color:#8b949e;background:none;border:none;cursor:pointer;padding:0}
|
|
150
|
+
.scan-notes-toggle:hover{color:#e6edf3}
|
|
151
|
+
.scan-notes-toggle .arrow{font-size:9px;transition:transform .15s}
|
|
152
|
+
.scan-notes-toggle.open .arrow{transform:rotate(90deg)}
|
|
153
|
+
.scan-notes-body{display:none;margin-top:6px;padding:10px 14px;background:#161b22;border:1px solid #21262d;border-radius:6px}
|
|
154
|
+
.scan-notes-body.open{display:block}
|
|
155
|
+
.scan-notes-body ul{margin:0;padding:0 0 0 16px;display:flex;flex-direction:column;gap:3px}
|
|
156
|
+
.scan-notes-body li{font-size:11px;color:#8b949e;line-height:1.5}
|
|
157
|
+
.scan-notes-body li.warning{color:#e6b84a}
|
|
158
|
+
.fix-targets-list{display:flex;flex-direction:column;gap:4px;margin-top:6px;padding:8px 10px;background:#161b22;border:1px solid #21262d;border-radius:5px}
|
|
159
|
+
.fix-target-row{display:flex;align-items:center;gap:8px;font-size:11px;flex-wrap:wrap}
|
|
160
|
+
.fix-target-pkg{font-family:'SF Mono','Cascadia Code','Fira Code',monospace;color:#8b949e}
|
|
161
|
+
.fix-target-arrow{color:#8b949e}
|
|
162
|
+
.fix-target-to{font-family:'SF Mono','Cascadia Code','Fira Code',monospace;color:#3fb950}
|
|
163
|
+
.fix-target-stats{color:#6b7280;font-size:10px}
|
|
164
|
+
.fix-target-note{color:#6b7280;font-style:italic;font-size:10px}
|
|
165
|
+
.break-badge{font-size:10px;font-weight:700;background:#fb850022;color:#fb8500;border:1px solid #fb850066;border-radius:4px;padding:1px 5px}
|
|
140
166
|
</style>
|
|
141
167
|
</head>
|
|
142
168
|
<body>
|
|
@@ -163,6 +189,10 @@ body{background:#0d1117;color:#e6edf3;font-family:-apple-system,BlinkMacSystemFo
|
|
|
163
189
|
</div>
|
|
164
190
|
<div class="header-links">
|
|
165
191
|
<a class="header-link owasp-link" href="https://owasp.org/cve-lite-cli/" target="_blank"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 261.49332 261.50668" width="16" height="16" style="flex-shrink:0"><g transform="matrix(1.3333333,0,0,-1.3333333,0,261.50667)"><g transform="scale(0.1)"><path fill="#F68B1F" d="M 980.629,0 C 439.043,0 0,439.051 0,980.637 0,1522.22 439.043,1961.27 980.629,1961.27 1522.2,1961.27 1961.25,1522.22 1961.25,980.637 1961.25,439.051 1522.2,0 980.629,0 m -0.008,1810.35 c -458.226,0 -829.707,-371.48 -829.707,-829.705 0,-458.235 371.481,-829.715 829.707,-829.715 458.219,0 829.699,371.48 829.699,829.715 0,458.225 -371.48,829.705 -829.699,829.705"/><path fill="#F68B1F" d="m 1299.1,285.75 c -31.36,0.02 -145.64,203.41 -161,261.398 -32.11,121.411 -25.2,172.704 -23.28,189.102 5.88,50.07 54.46,75.09 57.4,142.801 0.91,20.91 11.47,125.449 19.9,207.109 -20.8,4.07 -41.52,13.45 -59.94,28 55.3,-74.17 -26.09,-163.058 -144.352,-281.332 C 862.305,707.309 583.695,590.809 583.695,590.809 c 0,0 116.508,278.613 242.024,404.132 92.269,92.259 166.636,162.079 230.101,162.079 17.89,0 34.92,-5.55 51.23,-17.7 -14.56,18.41 -23.93,39.12 -28.01,59.92 -81.661,-8.45 -186.208,-18.99 -207.106,-19.91 -67.719,-2.94 -92.743,-51.52 -142.782,-57.39 -5.761,-0.68 -15.828,-1.98 -31.722,-1.98 -29.367,0 -78.629,4.42 -157.387,25.27 -63.07,16.68 -298.078,150.37 -256.512,167.17 21.196,8.58 88.75,14.38 177.715,14.38 85.559,0 190.922,-5.36 293.844,-18.77 128.328,-16.72 246,-37.87 326.19,-53.6 1.3,4.31 2.86,8.5 4.73,12.57 l -81.98,39.29 c 0,0 -65.479,75.14 -58.487,80.32 0.27,0.2 0.613,0.3 1.023,0.3 10.27,0 62.654,-59.89 67.694,-66.71 3.88,-1.29 26.09,-8.7 49.45,-16.47 l -23.19,20.28 c 0,0 -31.74,117.55 -23.47,120.32 0.1,0.03 0.21,0.05 0.33,0.05 8.71,0 37.51,-102.22 39.98,-109.56 5.66,-4.96 24.78,-12.41 48.67,-26.19 l -25.12,64.62 c 0,0 11.37,106.61 19.88,106.61 0.07,0 0.13,-0.01 0.2,-0.02 8.57,-1.71 -1.68,-88.92 -3.85,-99.78 3.11,-4.77 22.38,-34.33 41.7,-63.97 11.89,4.48 24.68,6.69 37.81,6.69 15.07,0 30.57,-2.92 45.61,-8.67 -19.26,41.01 -17.8,83.75 7.74,109.27 8.08,8.1 17.9,13.75 28.84,17.1 1.32,7.46 4.78,14.54 10.45,20.22 7.39,7.38 17.12,11.05 26.97,11.05 10.31,0 20.76,-4.03 28.76,-12.04 7.67,-7.65 11.65,-17.54 11.99,-27.39 12.33,25.41 26.88,59.7 25.86,70.81 -2.37,25.14 -31.53,69.64 -31.8,70.09 -1.9,2.87 -1.11,6.75 1.78,8.66 1.05,0.69 2.24,1.02 3.42,1.02 2.03,0 4.02,-0.99 5.21,-2.82 1.29,-1.92 31.17,-47.54 33.83,-75.79 1.48,-16.16 -17.07,-56.88 -27.18,-77.68 14.2,-7.77 28.04,-18.03 40.68,-30.67 12.63,-12.63 22.89,-26.47 30.67,-40.68 20.01,9.73 58.4,27.26 75.71,27.26 0.69,0 1.35,-0.02 1.97,-0.08 28.24,-2.66 73.87,-32.54 75.78,-33.81 2.88,-1.89 3.68,-5.77 1.78,-8.65 -1.2,-1.82 -3.19,-2.81 -5.22,-2.81 -1.17,0 -2.36,0.33 -3.41,1.03 -0.45,0.29 -44.94,29.44 -70.09,31.79 -0.38,0.04 -0.79,0.05 -1.22,0.05 -12.23,0 -45.07,-13.97 -69.61,-25.89 9.87,-0.33 19.76,-4.33 27.4,-12 15.67,-15.65 16.1,-40.59 0.99,-55.7 -5.67,-5.68 -12.74,-9.17 -20.2,-10.47 -3.37,-10.95 -9.03,-20.77 -17.11,-28.85 -14.08,-14.09 -33.38,-20.84 -54.76,-20.84 -17.38,0 -36.13,4.47 -54.52,13.1 10.77,-28.12 11.59,-57.89 1.99,-83.41 29.62,-19.32 59.22,-38.6 63.96,-41.71 7.78,1.55 54.5,7.22 81.17,7.22 10.66,0 18.13,-0.9 18.61,-3.34 1.73,-8.56 -106.57,-20.12 -106.57,-20.12 l -64.63,25.15 c 13.79,-23.91 21.21,-43.02 26.18,-48.69 7.47,-2.5 112.26,-32.04 109.5,-40.31 -0.31,-0.96 -2.15,-1.37 -5.16,-1.37 -23.1,0 -115.14,24.85 -115.14,24.85 l -20.3,23.19 c 7.79,-23.37 15.18,-45.56 16.49,-49.45 7.1,-5.25 71.57,-61.7 66.4,-68.708 -0.27,-0.363 -0.71,-0.524 -1.32,-0.524 -11.31,0 -78.99,58.992 -78.99,58.992 l -39.3,81.99 c -4.06,-1.88 -8.26,-3.42 -12.58,-4.73 15.73,-80.19 36.89,-197.861 53.63,-326.181 27.34,-209.949 21.19,-429.969 4.39,-471.571 -1.35,-3.347 -3.46,-4.898 -6.2,-4.898"/></g></g></svg> An OWASP Foundation Project</a>
|
|
192
|
+
<button class="header-link" type="button" onclick="downloadReportJson()" aria-label="Download JSON report">
|
|
193
|
+
<svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor"><path d="M7.47 10.78a.75.75 0 0 0 1.06 0l3.75-3.75a.75.75 0 1 0-1.06-1.06L8.75 8.44V1.75a.75.75 0 1 0-1.5 0v6.69L4.78 5.97a.75.75 0 1 0-1.06 1.06l3.75 3.75ZM3.75 13a.75.75 0 0 0 0 1.5h8.5a.75.75 0 0 0 0-1.5h-8.5Z"/></svg>
|
|
194
|
+
Download JSON
|
|
195
|
+
</button>
|
|
166
196
|
<a class="header-link" href="https://github.com/OWASP/cve-lite-cli" target="_blank">
|
|
167
197
|
<svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"/></svg>
|
|
168
198
|
GitHub
|
|
@@ -180,16 +210,20 @@ body{background:#0d1117;color:#e6edf3;font-family:-apple-system,BlinkMacSystemFo
|
|
|
180
210
|
</div>
|
|
181
211
|
|
|
182
212
|
${fixPlanHtml}
|
|
213
|
+
${noticesHtml}
|
|
183
214
|
|
|
184
215
|
<div class="findings-section">
|
|
185
216
|
<div class="findings-header">
|
|
186
217
|
<h2>Findings</h2>
|
|
187
|
-
<div
|
|
188
|
-
<
|
|
189
|
-
<
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
218
|
+
<div style="display:flex;align-items:center;gap:8px;flex-wrap:wrap">
|
|
219
|
+
<input class="search-input" type="text" id="findings-search" placeholder="Search package, version, CVE…" oninput="applyFilters()" />
|
|
220
|
+
<div class="filter-bar">
|
|
221
|
+
<button class="filter-btn active" onclick="setFilter('all',this)">All (${data.findings.length})</button>
|
|
222
|
+
<button class="filter-btn" onclick="setFilter('critical',this)">Critical (${counts.critical})</button>
|
|
223
|
+
<button class="filter-btn" onclick="setFilter('high',this)">High (${counts.high})</button>
|
|
224
|
+
<button class="filter-btn" onclick="setFilter('medium',this)">Medium (${counts.medium})</button>
|
|
225
|
+
<button class="filter-btn" onclick="setFilter('direct',this)">Direct only</button>
|
|
226
|
+
</div>
|
|
193
227
|
</div>
|
|
194
228
|
</div>
|
|
195
229
|
<table class="findings-table" id="findings-table">
|
|
@@ -205,6 +239,7 @@ ${fixPlanHtml}
|
|
|
205
239
|
</thead>
|
|
206
240
|
<tbody id="findings-tbody">
|
|
207
241
|
${findingRowsHtml}
|
|
242
|
+
<tr id="no-results-row" style="display:none"><td colspan="6" class="no-results">No findings match your search.</td></tr>
|
|
208
243
|
</tbody>
|
|
209
244
|
</table>
|
|
210
245
|
</div>
|
|
@@ -221,6 +256,18 @@ let sortCol = 'severity';
|
|
|
221
256
|
let sortAsc = false;
|
|
222
257
|
let activeFilter = 'all';
|
|
223
258
|
|
|
259
|
+
function downloadReportJson() {
|
|
260
|
+
const blob = new Blob([JSON.stringify(reportData, null, 2)], { type: 'application/json' });
|
|
261
|
+
const url = URL.createObjectURL(blob);
|
|
262
|
+
const a = document.createElement('a');
|
|
263
|
+
a.href = url;
|
|
264
|
+
a.download = 'cve-lite-report.json';
|
|
265
|
+
document.body.appendChild(a);
|
|
266
|
+
a.click();
|
|
267
|
+
document.body.removeChild(a);
|
|
268
|
+
URL.revokeObjectURL(url);
|
|
269
|
+
}
|
|
270
|
+
|
|
224
271
|
function toggleRow(idx) {
|
|
225
272
|
const detail = document.getElementById('detail-' + idx);
|
|
226
273
|
const mainRow = document.getElementById('row-' + idx);
|
|
@@ -236,10 +283,12 @@ function setFilter(filter, btn) {
|
|
|
236
283
|
activeFilter = filter;
|
|
237
284
|
document.querySelectorAll('.filter-btn').forEach(b => b.classList.remove('active'));
|
|
238
285
|
btn.classList.add('active');
|
|
239
|
-
|
|
286
|
+
applyFilters();
|
|
240
287
|
}
|
|
241
288
|
|
|
242
|
-
function
|
|
289
|
+
function applyFilters() {
|
|
290
|
+
const query = (document.getElementById('findings-search').value || '').toLowerCase().trim();
|
|
291
|
+
let visibleCount = 0;
|
|
243
292
|
reportData.findings.forEach((f, i) => {
|
|
244
293
|
const mainRow = document.getElementById('row-' + i);
|
|
245
294
|
const detailRow = document.getElementById('detail-' + i);
|
|
@@ -248,6 +297,10 @@ function applyFilter() {
|
|
|
248
297
|
else if (activeFilter === 'high') visible = f.severity === 'high';
|
|
249
298
|
else if (activeFilter === 'medium') visible = f.severity === 'medium';
|
|
250
299
|
else if (activeFilter === 'direct') visible = f.relationship === 'direct';
|
|
300
|
+
if (visible && query) {
|
|
301
|
+
const ids = [...(f.cves || []), ...(f.vulnerabilities || []).map(v => v.id)].join(' ').toLowerCase();
|
|
302
|
+
visible = f.package.toLowerCase().includes(query) || f.version.toLowerCase().includes(query) || ids.includes(query);
|
|
303
|
+
}
|
|
251
304
|
if (mainRow) mainRow.style.display = visible ? '' : 'none';
|
|
252
305
|
if (detailRow && !visible) {
|
|
253
306
|
detailRow.classList.remove('visible');
|
|
@@ -255,7 +308,10 @@ function applyFilter() {
|
|
|
255
308
|
const icon = document.getElementById('icon-' + i);
|
|
256
309
|
if (icon) icon.textContent = '▶';
|
|
257
310
|
}
|
|
311
|
+
if (visible) visibleCount++;
|
|
258
312
|
});
|
|
313
|
+
const noResults = document.getElementById('no-results-row');
|
|
314
|
+
if (noResults) noResults.style.display = visibleCount === 0 ? '' : 'none';
|
|
259
315
|
}
|
|
260
316
|
|
|
261
317
|
function sortBy(col) {
|
|
@@ -294,6 +350,11 @@ function toggleSkipped() {
|
|
|
294
350
|
});
|
|
295
351
|
}
|
|
296
352
|
|
|
353
|
+
function toggleNotes(btn) {
|
|
354
|
+
btn.classList.toggle('open');
|
|
355
|
+
btn.nextElementSibling.classList.toggle('open');
|
|
356
|
+
}
|
|
357
|
+
|
|
297
358
|
document.addEventListener('click', function(e) {
|
|
298
359
|
const btn = e.target.closest('.copy-btn');
|
|
299
360
|
if (btn && btn.dataset.cmd !== undefined) {
|
|
@@ -365,17 +426,49 @@ function renderFindingRow(finding, idx) {
|
|
|
365
426
|
</td>
|
|
366
427
|
</tr>`;
|
|
367
428
|
}
|
|
429
|
+
function renderNotices(notes, warnings) {
|
|
430
|
+
if (notes.length === 0 && warnings.length === 0)
|
|
431
|
+
return "";
|
|
432
|
+
const total = notes.length + warnings.length;
|
|
433
|
+
const items = [
|
|
434
|
+
...warnings.map(w => `<li class="warning">${escapeHtml(w)}</li>`),
|
|
435
|
+
...notes.map(n => `<li>${escapeHtml(n)}</li>`),
|
|
436
|
+
].join("\n");
|
|
437
|
+
return `<div class="scan-notes">
|
|
438
|
+
<button class="scan-notes-toggle" onclick="toggleNotes(this)"><span class="arrow">▶</span> Scan notes (${total})</button>
|
|
439
|
+
<div class="scan-notes-body"><ul>${items}</ul></div>
|
|
440
|
+
</div>`;
|
|
441
|
+
}
|
|
368
442
|
function renderFixPlan(plan) {
|
|
369
443
|
if (!plan || plan.sections.length === 0)
|
|
370
444
|
return "";
|
|
371
445
|
const directCount = plan.targets.filter(t => t.kind === "direct").length;
|
|
372
446
|
const skippedCount = plan.skipped.length;
|
|
373
|
-
const commandRows = plan.sections.map(section =>
|
|
447
|
+
const commandRows = plan.sections.map(section => {
|
|
448
|
+
const targetRows = section.targets.map(t => {
|
|
449
|
+
const isMajor = t.currentVersion ? isMajorVersionBump(t.currentVersion, t.targetVersion) : false;
|
|
450
|
+
const breakBadge = isMajor ? ` <span class="break-badge">⚠ breaking</span>` : "";
|
|
451
|
+
const versionHtml = t.currentVersion
|
|
452
|
+
? `<span class="fix-target-pkg">${escapeHtml(t.package)}@${escapeHtml(t.currentVersion)}</span><span class="fix-target-arrow">→</span><span class="fix-target-to">${escapeHtml(t.targetVersion)}</span>`
|
|
453
|
+
: `<span class="fix-target-pkg">${escapeHtml(t.package)}</span><span class="fix-target-arrow">→</span><span class="fix-target-to">${escapeHtml(t.targetVersion)}</span>`;
|
|
454
|
+
const statsHtml = t.scannedVersions != null
|
|
455
|
+
? ` <span class="fix-target-stats">${t.scannedVersions} scanned${t.knownVulnerableVersions != null ? ` · ${t.knownVulnerableVersions} still vulnerable` : ""}</span>`
|
|
456
|
+
: "";
|
|
457
|
+
const noteHtml = t.adjusted && t.adjustmentNote
|
|
458
|
+
? ` <span class="fix-target-note">${escapeHtml(t.adjustmentNote)}</span>`
|
|
459
|
+
: "";
|
|
460
|
+
return `<div class="fix-target-row">${versionHtml}${breakBadge}${statsHtml}${noteHtml}</div>`;
|
|
461
|
+
}).join("\n");
|
|
462
|
+
const targetsHtml = section.targets.length > 0
|
|
463
|
+
? `<div class="fix-targets-list">${targetRows}</div>`
|
|
464
|
+
: "";
|
|
465
|
+
return `
|
|
374
466
|
<div class="fix-cmd">
|
|
375
467
|
<span class="cmd-text">${escapeHtml(section.command)}</span>
|
|
376
468
|
<span class="cmd-meta">${escapeHtml(section.title)}</span>
|
|
377
469
|
<button class="copy-btn" data-cmd="${escapeHtml(section.command)}">Copy</button>
|
|
378
|
-
</div
|
|
470
|
+
</div>${targetsHtml}`;
|
|
471
|
+
}).join("\n");
|
|
379
472
|
const skippedRows = plan.skipped.map(s => `
|
|
380
473
|
<div class="skipped-row">
|
|
381
474
|
<span class="skipped-pkg">${escapeHtml(s.package)}@${escapeHtml(s.version)}</span>
|
|
@@ -406,11 +499,11 @@ export async function writeHtmlReport(params) {
|
|
|
406
499
|
fs.writeFileSync(jsonPath, JSON.stringify(params.data, null, 2), "utf8");
|
|
407
500
|
fs.writeFileSync(indexPath, renderHtmlReport(params.data), "utf8");
|
|
408
501
|
if (params.autoOpen) {
|
|
409
|
-
|
|
502
|
+
openInBrowser(indexPath);
|
|
410
503
|
}
|
|
411
504
|
return { reportPath: indexPath };
|
|
412
505
|
}
|
|
413
|
-
|
|
506
|
+
function openInBrowser(filePath) {
|
|
414
507
|
if (!path.isAbsolute(filePath))
|
|
415
508
|
return;
|
|
416
509
|
const cmd = process.platform === "darwin"
|
|
@@ -421,11 +514,11 @@ async function openInBrowser(filePath) {
|
|
|
421
514
|
const args = process.platform === "win32"
|
|
422
515
|
? ["/c", "start", "", filePath]
|
|
423
516
|
: [filePath];
|
|
424
|
-
|
|
517
|
+
try {
|
|
425
518
|
const child = spawn(cmd, args, { stdio: "ignore", detached: true, shell: false });
|
|
426
519
|
child.unref();
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
}
|
|
520
|
+
}
|
|
521
|
+
catch {
|
|
522
|
+
// Best-effort only: report creation should not fail if the OS open command is unavailable.
|
|
523
|
+
}
|
|
431
524
|
}
|
package/dist/output/printers.js
CHANGED
|
@@ -2,7 +2,8 @@ import { chalk, stripAnsi } from "../utils/chalk.js";
|
|
|
2
2
|
import { severityOrder } from "../constants.js";
|
|
3
3
|
import { buildSuggestedFixCommandPlan } from "../remediation/fix-commands.js";
|
|
4
4
|
import { isMajorVersionBump } from "../utils/version.js";
|
|
5
|
-
import {
|
|
5
|
+
import { getPrimaryParent } from "../utils/finding.js";
|
|
6
|
+
import { formatSeverityLabel, formatRelationshipLabel, getRecommendedAction, summarizeRisk, summarizeNextAction } from "./formatters.js";
|
|
6
7
|
export function printSummary(findings, packageCount, scanInput) {
|
|
7
8
|
if (findings.length === 0) {
|
|
8
9
|
if (scanInput.mode === "manifest-fallback") {
|
|
@@ -70,7 +71,10 @@ export function printPriorityFixes(findings) {
|
|
|
70
71
|
const parent = getPrimaryParent(finding);
|
|
71
72
|
if (parent)
|
|
72
73
|
console.log(` Parent: ${parent}`);
|
|
73
|
-
if (finding.
|
|
74
|
+
if (finding.recommendedNpmTransitiveRemediation?.kind === "update-parent-within-range") {
|
|
75
|
+
console.log(` Target: npm update ${finding.recommendedNpmTransitiveRemediation.package} (pulls in ${finding.pkg.name}@${finding.recommendedNpmTransitiveRemediation.targetChildVersion} within range)`);
|
|
76
|
+
}
|
|
77
|
+
else if (finding.recommendedParentUpgrade) {
|
|
74
78
|
console.log(` Target: ${finding.recommendedParentUpgrade.package} ${finding.recommendedParentUpgrade.currentVersion} -> ${finding.recommendedParentUpgrade.targetVersion}`);
|
|
75
79
|
}
|
|
76
80
|
console.log(` Next: ${summarizeNextAction(finding)}`);
|
|
@@ -135,18 +139,31 @@ export function printSuggestedFixCommands(findings, scanInput) {
|
|
|
135
139
|
for (const section of plan.sections) {
|
|
136
140
|
console.log("");
|
|
137
141
|
console.log(colorFixSectionTitle(section.severity, section.title));
|
|
138
|
-
|
|
139
|
-
if (section.kind === "direct" || section.kind === "direct-adjusted" || (section.kind === "urgent" && hasDirectTargets)) {
|
|
142
|
+
if (section.kind === "direct" || section.kind === "direct-adjusted") {
|
|
140
143
|
const validationSummary = summarizeAdjustedValidation(section.targets);
|
|
141
144
|
const remainingNotes = [];
|
|
142
|
-
|
|
143
|
-
// is not truncated by widths derived from smaller non-urgent sections.
|
|
144
|
-
const tableWidths = section.kind === "urgent" ? undefined : sharedDirectTableWidths;
|
|
145
|
-
printDirectTargetsTable(section.targets, remainingNotes, validationSummary, tableWidths);
|
|
145
|
+
printDirectTargetsTable(section.targets, remainingNotes, validationSummary, sharedDirectTableWidths);
|
|
146
146
|
for (const note of remainingNotes) {
|
|
147
147
|
console.log(chalk.gray(` Note: ${note}`));
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
|
+
else if (section.kind === "urgent") {
|
|
151
|
+
const directTargets = section.targets.filter(t => t.kind === "direct");
|
|
152
|
+
const parentUpgradeTargets = section.targets.filter(t => t.kind === "parent-upgrade" || t.kind === "parent-update");
|
|
153
|
+
if (directTargets.length > 0) {
|
|
154
|
+
const validationSummary = summarizeAdjustedValidation(directTargets);
|
|
155
|
+
const remainingNotes = [];
|
|
156
|
+
// Urgent sections compute their own widths so the Breaking? column
|
|
157
|
+
// is not truncated by widths derived from smaller non-urgent sections.
|
|
158
|
+
printDirectTargetsTable(directTargets, remainingNotes, validationSummary, undefined);
|
|
159
|
+
for (const note of remainingNotes) {
|
|
160
|
+
console.log(chalk.gray(` Note: ${note}`));
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (parentUpgradeTargets.length > 0) {
|
|
164
|
+
printParentUpgradeTargetsTable(parentUpgradeTargets, undefined);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
150
167
|
else if (shouldRenderParentUpgradeTable(section.targets)) {
|
|
151
168
|
printParentUpgradeTargetsTable(section.targets, sharedParentUpgradeTableWidths);
|
|
152
169
|
}
|
|
@@ -274,7 +291,10 @@ export function printPathHints(findings) {
|
|
|
274
291
|
for (const example of examples) {
|
|
275
292
|
console.log(` ${chalk.gray(example)}`);
|
|
276
293
|
}
|
|
277
|
-
if (finding.
|
|
294
|
+
if (finding.recommendedNpmTransitiveRemediation?.kind === "update-parent-within-range") {
|
|
295
|
+
console.log(` Recommended parent update: ${chalk.bold.cyan(`npm update ${finding.recommendedNpmTransitiveRemediation.package}`)}`);
|
|
296
|
+
}
|
|
297
|
+
else if (finding.recommendedParentUpgrade) {
|
|
278
298
|
console.log(` Recommended parent upgrade: ${chalk.bold.cyan(finding.recommendedParentUpgrade.package)} ${finding.recommendedParentUpgrade.currentVersion} -> ${finding.recommendedParentUpgrade.targetVersion}`);
|
|
279
299
|
}
|
|
280
300
|
}
|
|
@@ -341,19 +361,36 @@ export function printCompactOutput(findings, scanInput) {
|
|
|
341
361
|
}
|
|
342
362
|
console.log(`${formatSeverityLabel(sevLabel)} ${chalk.whiteBright(finding.pkg.name)}@${finding.pkg.version}`);
|
|
343
363
|
console.log(` ${typeLabel}${usageContext}`);
|
|
344
|
-
if (finding.
|
|
364
|
+
if (finding.recommendedNpmTransitiveRemediation?.kind === "update-parent-within-range") {
|
|
365
|
+
console.log(` ${chalk.gray(`Fix: update ${finding.recommendedNpmTransitiveRemediation.package} within its current dependency range`)}`);
|
|
366
|
+
}
|
|
367
|
+
else if (finding.recommendedParentUpgrade) {
|
|
345
368
|
console.log(` ${chalk.gray(`Fix: upgrade ${finding.recommendedParentUpgrade.package} to ${finding.recommendedParentUpgrade.targetVersion}`)}`);
|
|
346
369
|
}
|
|
347
370
|
else if (finding.firstFixedVersion) {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
371
|
+
let action;
|
|
372
|
+
if (finding.relationship === "direct") {
|
|
373
|
+
action = `upgrade to ${finding.firstFixedVersion}`;
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
const parent = getPrimaryParent(finding);
|
|
377
|
+
action = parent
|
|
378
|
+
? `Upgrade ${parent} — check for release resolving ${finding.pkg.name} to ${finding.firstFixedVersion}+`
|
|
379
|
+
: `No dependency path found — inspect lockfile to identify which package pulls in ${finding.pkg.name}`;
|
|
380
|
+
}
|
|
351
381
|
console.log(` ${chalk.gray(`Fix: ${action}`)}`);
|
|
352
382
|
}
|
|
353
383
|
else {
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
384
|
+
let action;
|
|
385
|
+
if (finding.relationship === "direct") {
|
|
386
|
+
action = "review and upgrade directly";
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
const parent = getPrimaryParent(finding);
|
|
390
|
+
action = parent
|
|
391
|
+
? `Upgrade ${parent} to resolve ${finding.pkg.name}`
|
|
392
|
+
: `No dependency path found — inspect lockfile to identify which package pulls in ${finding.pkg.name}`;
|
|
393
|
+
}
|
|
357
394
|
console.log(` ${chalk.gray(`Fix: ${action}`)}`);
|
|
358
395
|
}
|
|
359
396
|
console.log("");
|
|
@@ -397,6 +434,9 @@ export function printCompactOutput(findings, scanInput) {
|
|
|
397
434
|
else if (topFinding.relationship === "direct") {
|
|
398
435
|
console.log(`Upgrade ${chalk.whiteBright(topFinding.pkg.name)} to latest safe version`);
|
|
399
436
|
}
|
|
437
|
+
else if (topFinding.recommendedNpmTransitiveRemediation?.kind === "update-parent-within-range") {
|
|
438
|
+
console.log(`Update ${chalk.whiteBright(topFinding.recommendedNpmTransitiveRemediation.package)} within current range`);
|
|
439
|
+
}
|
|
400
440
|
else if (topFinding.recommendedParentUpgrade) {
|
|
401
441
|
console.log(`Upgrade ${chalk.whiteBright(topFinding.recommendedParentUpgrade.package)} ${topFinding.recommendedParentUpgrade.currentVersion} → ${topFinding.recommendedParentUpgrade.targetVersion}`);
|
|
402
442
|
}
|
|
@@ -406,7 +446,7 @@ export function printCompactOutput(findings, scanInput) {
|
|
|
406
446
|
console.log(`Upgrade ${chalk.whiteBright(parent)} to resolve ${topFinding.pkg.name}`);
|
|
407
447
|
}
|
|
408
448
|
else {
|
|
409
|
-
console.log(`
|
|
449
|
+
console.log(`No dependency path found — inspect lockfile to identify which package pulls in ${chalk.whiteBright(topFinding.pkg.name)}`);
|
|
410
450
|
}
|
|
411
451
|
}
|
|
412
452
|
if (plan) {
|
|
@@ -495,6 +535,11 @@ function renderCommandCallout(command) {
|
|
|
495
535
|
}
|
|
496
536
|
function findSuggestedCommandForFinding(plan, finding) {
|
|
497
537
|
const target = plan.targets.find(item => {
|
|
538
|
+
if (finding.recommendedNpmTransitiveRemediation?.kind === "update-parent-within-range") {
|
|
539
|
+
return (item.kind === "parent-update" &&
|
|
540
|
+
item.package === finding.recommendedNpmTransitiveRemediation.package &&
|
|
541
|
+
item.targetVersion === finding.recommendedNpmTransitiveRemediation.targetChildVersion);
|
|
542
|
+
}
|
|
498
543
|
if (finding.recommendedParentUpgrade) {
|
|
499
544
|
return (item.package === finding.recommendedParentUpgrade.package &&
|
|
500
545
|
item.targetVersion === finding.recommendedParentUpgrade.targetVersion);
|
|
@@ -504,6 +549,8 @@ function findSuggestedCommandForFinding(plan, finding) {
|
|
|
504
549
|
});
|
|
505
550
|
if (!target)
|
|
506
551
|
return null;
|
|
552
|
+
if (target.command)
|
|
553
|
+
return target.command;
|
|
507
554
|
return `${packageManagerCommandPrefix(plan.packageManager)} ${target.package}@${target.targetVersion}`;
|
|
508
555
|
}
|
|
509
556
|
function packageManagerCommandPrefix(packageManager) {
|
|
@@ -594,14 +641,15 @@ function printParentUpgradeTargetsTable(targets, widthsOverride) {
|
|
|
594
641
|
return [
|
|
595
642
|
target.package,
|
|
596
643
|
target.currentVersion ?? "-",
|
|
597
|
-
chalk.cyan(target.targetVersion),
|
|
644
|
+
chalk.cyan(target.displayTargetVersion ?? target.targetVersion),
|
|
598
645
|
usageText,
|
|
599
646
|
chalk.gray(target.reason),
|
|
600
647
|
];
|
|
601
648
|
});
|
|
602
649
|
if (rows.length === 0)
|
|
603
650
|
return;
|
|
604
|
-
|
|
651
|
+
// Allow the Context column (index 4) up to 60 chars so reason text is not truncated.
|
|
652
|
+
const widths = widthsOverride ?? computeTableWidths(headers, rows, [40, 40, 40, 40, 60]);
|
|
605
653
|
const line = (left, mid, right) => left + widths.map(w => "─".repeat(w + 2)).join(mid) + right;
|
|
606
654
|
console.log(line("┌", "┬", "┐"));
|
|
607
655
|
console.log(renderRow(headers, widths));
|
|
@@ -611,8 +659,11 @@ function printParentUpgradeTargetsTable(targets, widthsOverride) {
|
|
|
611
659
|
}
|
|
612
660
|
console.log(line("└", "┴", "┘"));
|
|
613
661
|
}
|
|
614
|
-
function computeTableWidths(headers, rows) {
|
|
615
|
-
return headers.map((header, index) =>
|
|
662
|
+
function computeTableWidths(headers, rows, columnMaxWidths) {
|
|
663
|
+
return headers.map((header, index) => {
|
|
664
|
+
const maxWidth = columnMaxWidths?.[index] ?? 40;
|
|
665
|
+
return Math.min(maxWidth, Math.max(header.length, ...rows.map(row => stripAnsi(String(row[index])).length)));
|
|
666
|
+
});
|
|
616
667
|
}
|
|
617
668
|
function computeSharedDirectTableWidths(sections) {
|
|
618
669
|
const directSections = sections.filter(section => section.kind === "direct" || section.kind === "direct-adjusted");
|
|
@@ -643,7 +694,7 @@ function computeSharedDirectTableWidths(sections) {
|
|
|
643
694
|
return computeTableWidths(headers, rows);
|
|
644
695
|
}
|
|
645
696
|
function shouldRenderParentUpgradeTable(targets) {
|
|
646
|
-
return targets.length > 0 && targets.every(target => target.kind === "parent-upgrade");
|
|
697
|
+
return targets.length > 0 && targets.every(target => target.kind === "parent-upgrade" || target.kind === "parent-update");
|
|
647
698
|
}
|
|
648
699
|
function computeSharedParentUpgradeTableWidths(sections) {
|
|
649
700
|
const parentSections = sections.filter(section => shouldRenderParentUpgradeTable(section.targets));
|
|
@@ -660,11 +711,11 @@ function computeSharedParentUpgradeTableWidths(sections) {
|
|
|
660
711
|
rows.push([
|
|
661
712
|
target.package,
|
|
662
713
|
target.currentVersion ?? "-",
|
|
663
|
-
target.targetVersion,
|
|
714
|
+
target.displayTargetVersion ?? target.targetVersion,
|
|
664
715
|
usageText,
|
|
665
716
|
target.reason,
|
|
666
717
|
]);
|
|
667
718
|
}
|
|
668
719
|
}
|
|
669
|
-
return computeTableWidths(headers, rows);
|
|
720
|
+
return computeTableWidths(headers, rows, [40, 40, 40, 40, 60]);
|
|
670
721
|
}
|