Skip to content
Merged
Changes from 1 commit
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
16 changes: 9 additions & 7 deletions src/output/html-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -563,13 +563,16 @@ export function renderFindingRow(finding: SerializedFinding, idx: number, skippe
? `<span class="fix-hint none" title="Malicious code advisory — remove this package">⚠ Malicious</span>`
: `<span class="fix-hint none" title="No known fix — consider replacing this package">⚠ No fix</span>`;

const depPathHtml = finding.dependencyPaths.length > 0
const depPathHtml = finding.dependencyPaths.length > 0

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const depPathHtml lost its indent - should be 2 spaces in to match the surrounding code.

? finding.dependencyPaths[0].map((node, i, arr) => {
const isLast = i === arr.length - 1;
return `<span class="dep-node${isLast ? " vulnerable" : ""}">${escapeHtml(node)}</span>${isLast ? "" : '<span class="dep-arrow">→</span>'}`;
const isFirst = i === 0;
const label = isFirst
? escapeHtml(node)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first hop is also a package on npm - no need to skip it. Remove the isFirst check and just always wrap node in the link.

: `<a href="https://www.npmjs.com/package/${escapeHtml(node)}" target="_blank" rel="noopener noreferrer">${escapeHtml(node)}</a>`;
return `<span class="dep-node${isLast ? " vulnerable" : ""}">${label}</span>${isLast ? "" : '<span class="dep-arrow">→</span>'}`;
}).join("")
: `<span class="dep-node">${escapeHtml(finding.package)}</span>`;

: `<span class="dep-node"><a href="https://www.npmjs.com/package/${escapeHtml(finding.package)}" target="_blank" rel="noopener noreferrer">${escapeHtml(finding.package)}</a></span>`;
const description = finding.vulnerabilities[0]?.summary ?? "";
const runnable = finding.runnableFixCommand ?? null;
const recommendedActionHtml = runnable
Expand All @@ -589,8 +592,7 @@ export function renderFindingRow(finding: SerializedFinding, idx: number, skippe

return ` <tr id="row-${idx}" data-skipped="${isSkipped ? '1' : '0'}" onclick="toggleRow(${idx})">
<td><span class="expand-icon" id="icon-${idx}">▶</span></td>
<td><div class="pkg-name">${escapeHtml(finding.package)}</div><div class="pkg-version">${escapeHtml(finding.version)}</div></td>
<td>${fixHtml}</td>
<td><div class="pkg-name"><a href="https://www.npmjs.com/package/${escapeHtml(finding.package)}" target="_blank" rel="noopener noreferrer">${escapeHtml(finding.package)}</a></div><div class="pkg-version">${escapeHtml(finding.version)}</div></td> <td>${fixHtml}</td>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<td>${fixHtml}</td> got merged onto the end of the line above. Put it on its own line.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<td>${fixHtml}</td> is still on the same line as the pkg-name cell. Put it on its own line.

<td><span class="sev-badge ${escapeHtml(finding.severity)}">${escapeHtml(finding.severity)}</span></td>
<td>${renderRelBadge(finding)}</td>
<td>${rootDepsHtml}</td>
Expand Down Expand Up @@ -842,7 +844,7 @@ export function renderFixPlan(plan: SuggestedFixCommandPlan | null): string {
: "";
const chainProofHtml = t.chainProof && t.chainSafeVersion
? (() => {
const hops = t.chainProof.map(h => `${escapeHtml(h.name)}@${escapeHtml(h.version)}`);
const hops = t.chainProof.map(h => `<a href="https://www.npmjs.com/package/${escapeHtml(h.name)}" target="_blank" rel="noopener noreferrer">${escapeHtml(h.name)}</a>@${escapeHtml(h.version)}`);
const safe = escapeHtml(t.chainSafeVersion);
const proofText = hops.length > 0
? `resolves via ${hops.join(" -&gt; ")} -&gt; ${safe} (safe)`
Expand Down