mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-08-06 17:08:10 +00:00
8460ae9ede
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
37 lines
818 B
TypeScript
37 lines
818 B
TypeScript
import type { VulnSeverity } from '../services/DatabaseService';
|
|
|
|
export const SEVERITY_ORDER: VulnSeverity[] = [
|
|
'UNKNOWN',
|
|
'LOW',
|
|
'MEDIUM',
|
|
'HIGH',
|
|
'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);
|
|
}
|
|
|
|
export function isSeverityAtLeast(
|
|
actual: VulnSeverity | null | undefined,
|
|
threshold: VulnSeverity,
|
|
): boolean {
|
|
return severityRank(actual) >= severityRank(threshold);
|
|
}
|