From d66c01fff4f8eb4434948b8c64c5529c3c9c7d4f Mon Sep 17 00:00:00 2001 From: Sonu Kapoor Date: Thu, 25 Jun 2026 16:12:28 +0200 Subject: [PATCH 1/4] fix: extract formatSeverityLabel and SEVERITY_ORDER to severity.ts to break circular import override-findings-terminal.ts imported formatSeverityLabel from formatters.ts while formatters.ts re-exported renderOverrideFindings from override-findings-terminal.ts. Moving the shared utilities to severity.ts removes the cycle and eliminates 35 test failures. --- src/output/formatters.ts | 11 ----------- src/utils/severity.ts | 13 +++++++++++++ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/output/formatters.ts b/src/output/formatters.ts index 1b3c502..3a67bb0 100644 --- a/src/output/formatters.ts +++ b/src/output/formatters.ts @@ -14,16 +14,6 @@ import { getPrimaryParent } from "../utils/finding.js"; import { calculatePathCoverage, formatDependencyPath } from "../utils/path-coverage.js"; import { pluralize } from "../utils/string.js"; -export function formatSeverityLabel(severity: string): string { - const lower = severity.toLowerCase(); - if (lower === "critical") return chalk.redBright(severity); - if (lower === "high") return chalk.red(severity); - if (lower === "medium") return chalk.yellow(severity); - if (lower === "low") return chalk.blueBright(severity); - if (lower === "unknown") return chalk.magenta(severity); - return severity; -} - export function formatRelationshipLabel(value: string): string { if (value.startsWith("direct")) return chalk.green(value); if (value.startsWith("transitive")) return chalk.yellow(value); @@ -349,4 +339,3 @@ export function countUniqueAdvisories(findings: Finding[]): number { return new Set(findings.flatMap(f => f.vulnerabilities.map(v => v.id))).size; } -export { renderOverrideFindings } from "./override-findings-terminal.js"; diff --git a/src/utils/severity.ts b/src/utils/severity.ts index cd99f42..680dd1d 100644 --- a/src/utils/severity.ts +++ b/src/utils/severity.ts @@ -1,4 +1,17 @@ import type { SeverityLabel } from "../types.js"; +import { chalk } from "./chalk.js"; + +export const SEVERITY_ORDER: SeverityLabel[] = ["critical", "high", "medium", "low", "unknown", "none"]; + +export function formatSeverityLabel(severity: string): string { + const lower = severity.toLowerCase(); + if (lower === "critical") return chalk.redBright(severity); + if (lower === "high") return chalk.red(severity); + if (lower === "medium") return chalk.yellow(severity); + if (lower === "low") return chalk.blueBright(severity); + if (lower === "unknown") return chalk.magenta(severity); + return severity; +} export function countBySeverity(findings: T[]): Record { const counts: Record = { From 225d4cc01ca55a6205052c53484bab58305c1256 Mon Sep 17 00:00:00 2001 From: Sonu Kapoor Date: Thu, 25 Jun 2026 16:12:32 +0200 Subject: [PATCH 2/4] feat: improve override hygiene output in terminal and HTML modes Terminal: verbose mode uses cyan header without box-drawing separators; compact mode wraps the section in separator lines. Fix commands are deduplicated per ruleId. HTML: severity group rows carry both severity-group and severity CSS classes so border styles apply. Location cells show a separator between file and jsonPath. Fix commands render as an inline block with a copy button when runnableCommand is set. --- src/cli/overrides.ts | 2 +- src/output/html-reporter.ts | 16 +-- src/output/override-findings-html.ts | 19 +++- src/output/override-findings-terminal.ts | 134 +++++++++++++++++++---- 4 files changed, 132 insertions(+), 39 deletions(-) diff --git a/src/cli/overrides.ts b/src/cli/overrides.ts index 8d6c1ac..d071a16 100644 --- a/src/cli/overrides.ts +++ b/src/cli/overrides.ts @@ -5,7 +5,7 @@ import type { OverrideFinding } from "../overrides/index.js"; import { createAuditLog } from "../audit-log/index.js"; import type { AuditLogHandle } from "../audit-log/index.js"; import { EXIT_OK, EXIT_FINDINGS, EXIT_ERROR } from "../types.js"; -import { renderOverrideFindings } from "../output/formatters.js"; +import { renderOverrideFindings } from "../output/override-findings-terminal.js"; import type { Logger } from "../overrides/context.js"; interface RunArgs { diff --git a/src/output/html-reporter.ts b/src/output/html-reporter.ts index 844b114..30b4167 100644 --- a/src/output/html-reporter.ts +++ b/src/output/html-reporter.ts @@ -206,13 +206,13 @@ button.header-link:hover{color:#58a6ff;border-color:#58a6ff} .override-hygiene table tbody tr{border-bottom:1px solid #21262d} .override-hygiene table tbody tr:last-child{border-bottom:none} .override-hygiene table tbody tr.severity-group{background:#1c2128} -.override-hygiene table tbody tr.severity-group th{font-weight:600;color:#e6edf3;padding:10px 14px} +.override-hygiene table tbody tr.severity-group th{font-weight:600;color:#e6edf3;padding:10px 14px;text-align:left} .override-hygiene table tbody tr.finding td{padding:11px 14px;font-size:12px;color:#e6edf3;vertical-align:middle} -.override-hygiene table tbody tr.finding.critical{border-left:3px solid #f85149} -.override-hygiene table tbody tr.finding.high{border-left:3px solid #fb8500} -.override-hygiene table tbody tr.finding.medium{border-left:3px solid #e3b341} -.override-hygiene table tbody tr.finding.low{border-left:3px solid #388bfd} -.override-hygiene table tbody tr.finding.info{border-left:3px solid #8b949e}`; +.override-hygiene table tbody tr.critical{border-left:3px solid #f85149} +.override-hygiene table tbody tr.high{border-left:3px solid #fb8500} +.override-hygiene table tbody tr.medium{border-left:3px solid #e3b341} +.override-hygiene table tbody tr.low{border-left:3px solid #388bfd} +.override-hygiene table tbody tr.unknown{border-left:3px solid #8b949e}`; export function renderHtmlReport(data: ReportData): string { @@ -330,10 +330,10 @@ ${findingRowsHtml} -${noticesHtml} - ${renderOverrideFindingsHtml(data.overrideFindings)} +${noticesHtml} +