Skip to content

Commit

Permalink
Fix: Add CVSS missing range (0.1-0.9)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-h-abdelsalam committed Sep 15, 2023
1 parent 20d5e51 commit 00f7878
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/web/components/dashboard/display/cvss/cvssdisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);

Expand Down
18 changes: 16 additions & 2 deletions src/web/components/dashboard/display/cvss/cvsstransform.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const transformCvssData = (data = {}) => {
const cvssData = {
[NA_VALUE]: 0,
[LOG_VALUE]: 0,
0.1: 0,
1: 0,
2: 0,
3: 0,
Expand All @@ -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;

Check warning on line 84 in src/web/components/dashboard/display/cvss/cvsstransform.js

View check run for this annotation

Codecov / codecov/patch

src/web/components/dashboard/display/cvss/cvsstransform.js#L84

Added line #L84 was not covered by tests
} else if (severity >= 0.1 && severity <= 0.9) {
cvss = 0.1;
} else {
cvss = Math.floor(severity);

Check warning on line 88 in src/web/components/dashboard/display/cvss/cvsstransform.js

View check run for this annotation

Codecov / codecov/patch

src/web/components/dashboard/display/cvss/cvsstransform.js#L86-L88

Added lines #L86 - L88 were not covered by tests
}

count = parseInt(count);

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 00f7878

Please sign in to comment.