Skip to content

Commit

Permalink
refactor: update vulnerability report sorting method
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksey Sviridkin <f@lex.la>
  • Loading branch information
lexfrei committed May 12, 2024
1 parent e5dc87b commit d2fedb1
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/components/grid/vulnerability-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ function DataGrid({ reportUrl }) {
{
name: "Severity",
formatter: (_, row) => formatSeverity(row),
sorter: severitySorter,
sort: {
compare: (a, b) => {
const order = ["", "unknown", "low", "medium", "high", "critical"];
const indexA = order.indexOf(a.toString().toLowerCase());
const indexB = order.indexOf(b.toString().toLowerCase());
return indexA - indexB;
}
}
},
"Fixed Version",
"Installed Version",
Expand Down Expand Up @@ -54,15 +61,6 @@ function formatSeverity(row) {
}
}

function severitySorter(a, b) {
console.log("Comparing:", a, b); // Debug output to see what's being compared
const order = ["", "unknown", "low", "medium", "high", "critical"];
const indexA = order.indexOf(a.toString().toLowerCase());
const indexB = order.indexOf(b.toString().toLowerCase());
console.log("Indexes:", indexA, indexB); // Debug output to check if indexes are correct
return indexA - indexB;
}

function formatCVERecord(row) {
const cveUrl = row.cells[5]?.data;
if (cveUrl != null) {
Expand Down

0 comments on commit d2fedb1

Please sign in to comment.