Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Add CVSS missing range (0.1-0.9) #3867

Merged
merged 2 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions 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) && isDefined(end) && start >= 0) {
const startTerm = FilterTerm.fromString(`severity>${start}`);
const endTerm = FilterTerm.fromString(`severity<${end}`);

Expand All @@ -69,9 +69,7 @@ class CvssDisplay extends React.Component {
let statusTerm;

if (isDefined(start)) {
if (start > 0) {
statusTerm = FilterTerm.fromString(`severity>${start}`);
} else if (start === NA_VALUE) {
if (start === NA_VALUE) {
statusTerm = FilterTerm.fromString('severity=""');
} else {
statusTerm = FilterTerm.fromString(`severity=${start}`);
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 cvssData = {
[NA_VALUE]: 0,
[LOG_VALUE]: 0,
0.1: 0,
1: 0,
2: 0,
3: 0,
Expand All @@ -78,7 +79,14 @@

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 @@
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