-
-
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 4 commits
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 |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ import type { OverrideFinding } from "../overrides/types.js"; | |
| import type { MaintenanceFinding } from "../maintenance/types.js"; | ||
| import { UNVERIFIED_PARENT_UPGRADE_NOTE, type SuggestedFixCommandPlan } from "../remediation/fix-commands.js"; | ||
| import { getCompletenessImpact } from "../scan/completeness.js"; | ||
| import { escape } from "node:querystring"; | ||
|
|
||
| export type SerializedFinding = ReturnType<typeof serializeHtmlFinding>; | ||
|
|
||
|
|
@@ -564,11 +565,11 @@ export function renderFindingRow(finding: SerializedFinding, idx: number, skippe | |
| : `<span class="fix-hint none" title="No known fix — consider replacing this package">⚠ No fix</span>`; | ||
|
|
||
| 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>'}`; | ||
| }).join("") | ||
| : `<span class="dep-node">${escapeHtml(finding.package)}</span>`; | ||
| ? finding.dependencyPaths[0].map((node, i, arr) => { | ||
| const isLast = i === arr.length - 1; | ||
| return `<a href="https://www.npmjs.com/package/${encodeURIComponent(node)}" target="_blank" rel="noopener noreferrer" class="dep-node${isLast ? " vulnerable" : ""}">${escapeHtml(node)}</a>${isLast ? "" : '<span class="dep-arrow">→</span>'}`; | ||
| }).join("") | ||
| : `<span class="dep-node">${escapeHtml(finding.package)}</span>`; | ||
|
|
||
|
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. Missing |
||
| const description = finding.vulnerabilities[0]?.summary ?? ""; | ||
| const runnable = finding.runnableFixCommand ?? null; | ||
|
|
@@ -586,10 +587,9 @@ export function renderFindingRow(finding: SerializedFinding, idx: number, skippe | |
| const rootDepsHtml = finding.rootDependencies.length > 0 | ||
| ? finding.rootDependencies.map(name => `<span class="root-dep">${escapeHtml(name)}</span>`).join(", ") | ||
|
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 pkg-name cell link uses <a href="https://www.npmjs.com/package/${encodeURIComponent(finding.package)}" ...> |
||
| : `<span class="root-dep-none">-</span>`; | ||
|
|
||
| return ` <tr id="row-${idx}" data-skipped="${isSkipped ? '1' : '0'}" onclick="toggleRow(${idx})"> | ||
| 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><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> | ||
| <td><span class="sev-badge ${escapeHtml(finding.severity)}">${escapeHtml(finding.severity)}</span></td> | ||
| <td>${renderRelBadge(finding)}</td> | ||
|
|
@@ -842,7 +842,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.
This import is unused -
escapefromnode:querystringis never called anywhere in the file. Remove it (it will also fail the build ifnoUnusedLocalsis enabled).