refactor(backend): hoist severity Sets to utils/severity.ts (#795)

Replaces five inline new Set([...]) literals scattered across
routes/security.ts and routes/fleet.ts with two shared constants
(FINDING_SEVERITIES, POLICY_SEVERITIES) exported from
utils/severity.ts. Pure refactor: no error response or status code
changes.

Closes #749
This commit is contained in:
Anso
2026-04-27 00:05:12 -04:00
committed by GitHub
parent 4c4394b97e
commit 8460ae9ede
3 changed files with 23 additions and 12 deletions
+15
View File
@@ -8,6 +8,21 @@ export const SEVERITY_ORDER: VulnSeverity[] = [
'CRITICAL',
];
export const FINDING_SEVERITIES: ReadonlySet<string> = new Set<VulnSeverity>([
'CRITICAL',
'HIGH',
'MEDIUM',
'LOW',
'UNKNOWN',
]);
export const POLICY_SEVERITIES: ReadonlySet<string> = new Set<VulnSeverity>([
'CRITICAL',
'HIGH',
'MEDIUM',
'LOW',
]);
export function severityRank(severity: VulnSeverity | null | undefined): number {
if (!severity) return -1;
return SEVERITY_ORDER.indexOf(severity);