From 21b1282016774fe9b246dd47cdf9888a8a380bfe Mon Sep 17 00:00:00 2001 From: Ahmed Abdelsalam Date: Fri, 15 Sep 2023 16:12:37 +0200 Subject: [PATCH] Fix: Add CVSS missing range (0.1-0.9) --- .../dashboard/display/cvss/cvssdisplay.js | 2 +- .../dashboard/display/cvss/cvsstransform.js | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/web/components/dashboard/display/cvss/cvssdisplay.js b/src/web/components/dashboard/display/cvss/cvssdisplay.js index aaa5dc9005..62e41346ca 100644 --- a/src/web/components/dashboard/display/cvss/cvssdisplay.js +++ b/src/web/components/dashboard/display/cvss/cvssdisplay.js @@ -52,7 +52,7 @@ class CvssDisplay extends React.Component { let statusFilter; - if (isDefined(start) && start > 0 && end < 10) { + if (isDefined(start) && start >= 0 && end < 10) { const startTerm = FilterTerm.fromString(`severity>${start}`); const endTerm = FilterTerm.fromString(`severity<${end}`); diff --git a/src/web/components/dashboard/display/cvss/cvsstransform.js b/src/web/components/dashboard/display/cvss/cvsstransform.js index 48eeeb8bcb..9f08620f72 100644 --- a/src/web/components/dashboard/display/cvss/cvsstransform.js +++ b/src/web/components/dashboard/display/cvss/cvsstransform.js @@ -61,6 +61,7 @@ const transformCvssData = (data = {}) => { const cvssData = { [NA_VALUE]: 0, [LOG_VALUE]: 0, + 0.1: 0, 1: 0, 2: 0, 3: 0, @@ -78,7 +79,14 @@ const transformCvssData = (data = {}) => { const severity = parseSeverity(value); - const cvss = isDefined(severity) ? Math.floor(severity) : NA_VALUE; + let cvss; + if (!isDefined(severity)) { + cvss = NA_VALUE; + } else if (severity >= 0.1 && severity <= 0.9) { + cvss = 0.1; + } else { + cvss = Math.floor(severity); + } count = parseInt(count); @@ -108,12 +116,18 @@ const transformCvssData = (data = {}) => { start: value, }; toolTip = `10.0 (${label}): ${perc}% (${count})`; - } else if (value > 0) { + } else if (value > 1) { filterValue = { start: format(value - 0.1), end: format(value + 1), }; toolTip = `${value}.0 - ${value}.9 (${label}): ${perc}% (${count})`; + } else if (value > 0) { + filterValue = { + start: format(value - 0.1), + end: '1.0', + }; + toolTip = `${value} - 0.9 (${label}): ${perc}% (${count})`; } else { filterValue = { start: value,