2023-05-11 15:00:20 +00:00
|
|
|
const severityOrder: Record<string, number> = {
|
|
|
|
LOW: 1,
|
2023-05-16 15:38:23 +00:00
|
|
|
MEDIUM: 2,
|
2023-05-11 15:00:20 +00:00
|
|
|
MODERATE: 2,
|
|
|
|
HIGH: 3,
|
|
|
|
CRITICAL: 4,
|
2023-05-16 15:38:23 +00:00
|
|
|
UNKNOWN: 5,
|
2023-05-11 15:00:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export function getHighestVulnerabilitySeverity<
|
|
|
|
T extends Record<string, any>,
|
2023-11-07 15:50:29 +00:00
|
|
|
TChild extends Record<string, any> | undefined,
|
2023-05-11 15:00:20 +00:00
|
|
|
>(parent: T, child: TChild): string {
|
|
|
|
const parentVulSeverity = parent.vulnerabilitySeverity?.toUpperCase();
|
|
|
|
const childVulSeverity = child?.vulnerabilitySeverity?.toUpperCase();
|
|
|
|
|
|
|
|
if (childVulSeverity === undefined) {
|
|
|
|
return parentVulSeverity;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parentVulSeverity === undefined) {
|
|
|
|
return childVulSeverity;
|
|
|
|
}
|
|
|
|
|
|
|
|
return severityOrder[parentVulSeverity] >= severityOrder[childVulSeverity]
|
|
|
|
? parentVulSeverity
|
|
|
|
: childVulSeverity;
|
|
|
|
}
|