Skip to content

Commit a9c2b0c

Browse files
🐛 Use vulnerability average_score on sorting tables (guacsec#605)
Signed-off-by: Carlos Feria <2582866+carlosthe19916@users.noreply.github.com>
1 parent 43ce647 commit a9c2b0c

3 files changed

Lines changed: 8 additions & 7 deletions

File tree

client/src/app/pages/package-details/vulnerabilities-by-package.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
Tr,
1515
} from "@patternfly/react-table";
1616

17-
import { getSeverityPriority } from "@app/api/model-utils";
1817
import { SeverityShieldAndText } from "@app/components/SeverityShieldAndText";
1918
import { SimplePagination } from "@app/components/SimplePagination";
2019
import {
@@ -70,9 +69,7 @@ export const VulnerabilitiesByPackage: React.FC<
7069
getSortValues: (item) => {
7170
return {
7271
identifier: item.vulnerability.identifier,
73-
severity: item.vulnerability?.average_severity
74-
? getSeverityPriority(item.vulnerability?.average_severity)
75-
: 0,
72+
severity: item.vulnerability?.average_score || 0,
7673
published: item.vulnerability?.published
7774
? dayjs(item.vulnerability?.published).valueOf()
7875
: 0,

client/src/app/pages/sbom-details/vulnerabilities-by-sbom.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import {
2929
Tr,
3030
} from "@patternfly/react-table";
3131

32-
import { getSeverityPriority } from "@app/api/model-utils";
3332
import {
3433
type VulnerabilityStatus,
3534
extendedSeverityFromSeverity,
@@ -147,7 +146,7 @@ export const VulnerabilitiesBySbom: React.FC<VulnerabilitiesBySbomProps> = ({
147146
],
148147
getSortValues: (item) => ({
149148
id: item.vulnerability.identifier,
150-
cvss: getSeverityPriority(item.vulnerability.average_severity),
149+
cvss: item.vulnerability.average_score,
151150
affectedDependencies: item.summary.totalPackages,
152151
published: item.vulnerability?.published
153152
? dayjs(item.vulnerability.published).valueOf()

client/src/app/utils/utils.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,9 @@ export const universalComparator = (
140140
// biome-ignore lint/suspicious/noExplicitAny: allowed
141141
b: any,
142142
locale: string,
143-
) => localeNumericCompare(String(a ?? ""), String(b ?? ""), locale);
143+
) => {
144+
if (typeof a === "number" && typeof b === "number") {
145+
return a - b;
146+
}
147+
return localeNumericCompare(String(a ?? ""), String(b ?? ""), locale);
148+
};

0 commit comments

Comments
 (0)