-
-
Notifications
You must be signed in to change notification settings - Fork 142
feat: link package names to npm in html report #1021
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
cd43fe3
6d650c7
ba6126f
24b2ca7
d34726f
328074b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
| ? 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) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| : `<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 | ||
|
|
@@ -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> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| <td><span class="sev-badge ${escapeHtml(finding.severity)}">${escapeHtml(finding.severity)}</span></td> | ||
| <td>${renderRelBadge(finding)}</td> | ||
| <td>${rootDepsHtml}</td> | ||
|
|
@@ -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(" -> ")} -> ${safe} (safe)` | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const depPathHtmllost its indent - should be 2 spaces in to match the surrounding code.