import type { Severity } from '@cra-compliance/types'; const SEVERITY_NUMBERS: Record = { critical: 5, high: 4, medium: 3, low: 2, info: 1, }; const SEVERITY_COLORS: Record = { critical: '#dc2626', high: '#ea580c', medium: '#d97706', low: '#2563eb', info: '#6b7280', }; export function severityToNumber(severity: Severity): number { return SEVERITY_NUMBERS[severity]; } export function severityColor(severity: Severity): string { return SEVERITY_COLORS[severity]; } export function severityLabel(severity: Severity): string { return severity.charAt(0).toUpperCase() + severity.slice(1); } /** * Map a numeric CVSS score to a Severity level. * Shared across OSV, NVD, and WPScan integrations. */ export function cvssToSeverity(score: number | null | undefined): Severity { if (score === null || score === undefined) return 'medium'; if (score >= 9.0) return 'critical'; if (score >= 7.0) return 'high'; if (score >= 4.0) return 'medium'; if (score >= 0.1) return 'low'; return 'info'; }