Skip to content

Commit

Permalink
Merge pull request #4251 from greenbone/change-epss-score-to-be-displ…
Browse files Browse the repository at this point in the history
…ayed-in-percentage

change: epss score to be displayed in percentage
  • Loading branch information
a-h-abdelsalam authored Dec 12, 2024
2 parents 7bf1305 + 4f862a7 commit 4b30802
Show file tree
Hide file tree
Showing 19 changed files with 75 additions and 86 deletions.
4 changes: 2 additions & 2 deletions public/locales/gsa-de.json
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@
"Dynamic": "Dynamisch",
"Dynamic Severity": "Dynamischer Schweregrad",
"EPSS": "EPSS",
"EPSS Percentile": "EPSS-Perzentil",
"EPSS Percentage": "EPSS-Prozentsatz",
"EPSS Score": "EPSS-Score",
"EPSS (CVE with highest severity)": "EPSS (CVE mit höchstem Schweregrad)",
"EPSS (highest EPSS score)": "EPSS (Höchster EPSS-Score)",
Expand Down Expand Up @@ -1180,7 +1180,7 @@
"Password only": "Nur Passwort",
"Password: Use existing Password": "Passwort: Verwende bestehendes Passwort",
"Path": "Pfad",
"Percentile": "Perzentil",
"Percennage": "Prozentsatz",
"Performance": "Leistungsdaten",
"Period": "Zeitintervall",
"Permission": "Berechtigung",
Expand Down
2 changes: 1 addition & 1 deletion src/web/pages/cves/__tests__/detailspage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ describe('CVE Detailspage tests', () => {
);

expect(baseElement).toHaveTextContent('Score0.50000');
expect(baseElement).toHaveTextContent('Percentile0.75000');
expect(baseElement).toHaveTextContent('Percentage75.000%');

const links = baseElement.querySelectorAll('a');
const icons = getAllByTestId('svg-icon');
Expand Down
2 changes: 1 addition & 1 deletion src/web/pages/cves/__tests__/listpage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ describe('CvesPage tests', () => {
expect(row[2]).toHaveTextContent('AV:N/AC:M/Au:N/C:C/I:C/A:C');
expect(row[2]).toHaveTextContent('9.3 (High)');
expect(row[2]).toHaveTextContent('0.50000');
expect(row[2]).toHaveTextContent('0.75000');
expect(row[2]).toHaveTextContent('75.000%');
});

test('should allow to bulk action on page contents', async () => {
Expand Down
7 changes: 2 additions & 5 deletions src/web/pages/cves/details.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/


import React from 'react';

import {_, _l} from 'gmp/locale/lang';
Expand Down Expand Up @@ -102,8 +101,8 @@ const CveDetails = ({entity}) => {
<TableData>{epss.score.toFixed(5)}</TableData>
</TableRow>
<TableRow>
<TableData>{_('Percentile')}</TableData>
<TableData>{epss.percentile.toFixed(5)}</TableData>
<TableData>{_('Percentage')}</TableData>
<TableData>{`${(epss?.percentile * 100).toFixed(3)}%`}</TableData>
</TableRow>
</TableBody>
</InfoTable>
Expand Down Expand Up @@ -137,5 +136,3 @@ CveDetails.propTypes = {
};

export default CveDetails;

// vim: set ts=2 sw=2 tw=80:
2 changes: 1 addition & 1 deletion src/web/pages/cves/filterdialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const CvesFilterDialog = ({
},
{
name: 'epss_percentile',
displayName: _('EPSS Percentile'),
displayName: _('EPSS Percentage'),
},
];

Expand Down
7 changes: 3 additions & 4 deletions src/web/pages/cves/row.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/


import React from 'react';

import {_} from 'gmp/locale/lang';
Expand Down Expand Up @@ -66,7 +65,9 @@ const Row = ({
{isNumber(epssScore) ? epssScore.toFixed(5) : _('N/A')}
</TableData>
<TableData>
{isNumber(epssPercentile) ? epssPercentile.toFixed(5) : _('N/A')}
{isNumber(epssPercentile)
? `${(epssPercentile * 100).toFixed(3)}%`
: _('N/A')}
</TableData>
</>
)}
Expand All @@ -83,5 +84,3 @@ Row.propTypes = {
};

export default Row;

// vim: set ts=2 sw=2 tw=80:
4 changes: 1 addition & 3 deletions src/web/pages/cves/table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const Header = ({
currentSortBy={currentSortBy}
sortBy={sort ? 'epss_percentile' : false}
onSortChange={onSortChange}
title={_('Percentile')}
title={_('Percentage')}
/>
</TableRow>
)}
Expand Down Expand Up @@ -140,5 +140,3 @@ export const CvesTable = createEntitiesTable({
});

export default CvesTable;

// vim: set ts=2 sw=2 tw=80:
4 changes: 2 additions & 2 deletions src/web/pages/nvts/__tests__/detailspage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,8 @@ describe('Nvt Detailspage tests', () => {
expect(baseElement).toHaveTextContent('EPSS (CVE with highest severity)');
expect(baseElement).toHaveTextContent('EPSS Score');
expect(baseElement).toHaveTextContent('0.87650');
expect(baseElement).toHaveTextContent('EPSS Percentile');
expect(baseElement).toHaveTextContent('0.90000');
expect(baseElement).toHaveTextContent('EPSS Percentage');
expect(baseElement).toHaveTextContent('90.000%');
expect(baseElement).toHaveTextContent('EPSS (highest EPSS score)');
expect(baseElement).toHaveTextContent('0.98760');

Expand Down
4 changes: 2 additions & 2 deletions src/web/pages/nvts/__tests__/listpage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ describe('NvtsPage tests', () => {
expect(header[7]).toHaveTextContent('QoD');
expect(header[8]).toHaveTextContent('EPSS');
expect(header[9]).toHaveTextContent('Score');
expect(header[10]).toHaveTextContent('Percentile');
expect(header[10]).toHaveTextContent('Percentage');

const row = baseElement.querySelectorAll('tr');

Expand All @@ -223,7 +223,7 @@ describe('NvtsPage tests', () => {
expect(row[2]).toHaveTextContent('CVE-2020-5678');
expect(row[2]).toHaveTextContent('80 %');
expect(row[2]).toHaveTextContent('0.87650');
expect(row[2]).toHaveTextContent('0.90000');
expect(row[2]).toHaveTextContent('90.000%');
});

test('should allow to bulk action on page contents', async () => {
Expand Down
10 changes: 4 additions & 6 deletions src/web/pages/nvts/details.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ const NvtDetails = ({entity, links = true}) => {
</TableData>
</TableRow>
<TableRow>
<TableData>{_('EPSS Percentile')}</TableData>
<TableData>{_('EPSS Percentage')}</TableData>
<TableData>
{isNumber(epss?.max_severity?.percentile)
? epss?.max_severity?.percentile.toFixed(5)
? `${(epss.max_severity.percentile * 100).toFixed(3)}%`
: _('N/A')}
</TableData>
</TableRow>
Expand Down Expand Up @@ -154,10 +154,10 @@ const NvtDetails = ({entity, links = true}) => {
</TableData>
</TableRow>
<TableRow>
<TableData>{_('EPSS Percentile')}</TableData>
<TableData>{_('EPSS Percentage')}</TableData>
<TableData>
{isNumber(epss?.max_epss?.percentile)
? epss?.max_epss?.percentile.toFixed(5)
? `${(epss?.max_epss?.percentile * 100).toFixed(3)}%`
: _('N/A')}
</TableData>
</TableRow>
Expand Down Expand Up @@ -246,5 +246,3 @@ NvtDetails.propTypes = {
};

export default NvtDetails;

// vim: set ts=2 sw=2 tw=80:
2 changes: 1 addition & 1 deletion src/web/pages/nvts/filterdialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const NvtsFilterDialog = ({
},
{
name: 'epss_percentile',
displayName: _('EPSS Percentile'),
displayName: _('EPSS Percentage'),
},
];

Expand Down
7 changes: 3 additions & 4 deletions src/web/pages/nvts/row.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/


import React from 'react';

import Filter from 'gmp/models/filter.js';
Expand Down Expand Up @@ -100,7 +99,9 @@ const Row = ({
{isNumber(epssScore) ? epssScore.toFixed(5) : _('N/A')}
</TableData>
<TableData>
{isNumber(epssPercentile) ? epssPercentile.toFixed(5) : _('N/A')}
{isNumber(epssPercentile)
? `${(epssPercentile * 100).toFixed(3)}%`
: _('N/A')}
</TableData>
</>
)}
Expand All @@ -118,5 +119,3 @@ Row.propTypes = {
};

export default Row;

// vim: set ts=2 sw=2 tw=80:
4 changes: 1 addition & 3 deletions src/web/pages/nvts/table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const Header = ({
currentSortBy={currentSortBy}
sortBy={sort ? 'epss_percentile' : false}
onSortChange={onSortChange}
title={_('Percentile')}
title={_('Percentage')}
/>
</TableRow>
)}
Expand Down Expand Up @@ -169,5 +169,3 @@ export const NvtsTable = createEntitiesTable({
});

export default NvtsTable;

// vim: set ts=2 sw=2 tw=80:
4 changes: 2 additions & 2 deletions src/web/pages/results/__tests__/detailspage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,12 @@ describe('Result Detailspage tests', () => {
expect(baseElement).toHaveTextContent('Location80/tcp');
expect(baseElement).toHaveTextContent('EPSS (CVE with highest severity)');
expect(baseElement).toHaveTextContent('EPSS Score0.87650');
expect(baseElement).toHaveTextContent('EPSS Percentile0.80000');
expect(baseElement).toHaveTextContent('EPSS Percentage80.000%');
expect(baseElement).toHaveTextContent('CVECVE-2019-1234');
expect(baseElement).toHaveTextContent('CVE Severity5.0 (Medium)');
expect(baseElement).toHaveTextContent('EPSS (highest EPSS score)');
expect(baseElement).toHaveTextContent('EPSS Score0.98760');
expect(baseElement).toHaveTextContent('EPSS Percentile0.90000');
expect(baseElement).toHaveTextContent('EPSS Percentage90.000%');
expect(baseElement).toHaveTextContent('CVECVE-2020-5678');
expect(baseElement).toHaveTextContent('CVE Severity2.0 (Low)');
expect(heading[2]).toHaveTextContent('Summary');
Expand Down
6 changes: 3 additions & 3 deletions src/web/pages/results/__tests__/row.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ describe('Should render EPSS fields', () => {
const {element} = render(
<table>
<tbody>
<Row entity={entity}/>
<Row entity={entity} />
</tbody>
</table>,
);

expect(element).toHaveTextContent("0.87650");
expect(element).toHaveTextContent("0.80000");
expect(element).toHaveTextContent('0.87650');
expect(element).toHaveTextContent('80.000%');
});
});

Expand Down
46 changes: 28 additions & 18 deletions src/web/pages/results/detailspage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ import OverrideComponent from '../overrides/component';
import TicketComponent from '../tickets/component';

import ResultDetails from './details';
import CveLink from "web/components/link/cvelink.jsx";
import Severitybar from "web/components/bar/severitybar.jsx";
import CveLink from 'web/components/link/cvelink.jsx';
import Severitybar from 'web/components/bar/severitybar.jsx';

export const ToolBarIcons = ({
entity,
Expand Down Expand Up @@ -180,8 +180,8 @@ const Details = ({entity, ...props}) => {
const {notes, overrides, qod, host, userTags} = entity;
const active_notes = notes.filter(active_filter);
const active_overrides = overrides.filter(active_filter);
const epss = entity?.information?.epss
const gmp = useGmp()
const epss = entity?.information?.epss;
const gmp = useGmp();

return (
<React.Fragment>
Expand Down Expand Up @@ -236,7 +236,7 @@ const Details = ({entity, ...props}) => {
<TableData>{_('Location')}</TableData>
<TableData>{entity.port}</TableData>
</TableRow>
{ gmp.settings.enableEPSS && isDefined(epss?.max_severity) &&
{gmp.settings.enableEPSS && isDefined(epss?.max_severity) && (
<>
<TableData colSpan="2">
<b>{_('EPSS (CVE with highest severity)')}</b>
Expand All @@ -245,14 +245,16 @@ const Details = ({entity, ...props}) => {
<TableData>{_('EPSS Score')}</TableData>
<TableData>
{isNumber(epss?.max_severity?.score)
? epss?.max_severity?.score.toFixed(5) : _("N/A")}
? epss?.max_severity?.score.toFixed(5)
: _('N/A')}
</TableData>
</TableRow>
<TableRow>
<TableData>{_('EPSS Percentile')}</TableData>
<TableData>{_('EPSS Percentage')}</TableData>
<TableData>
{isNumber(epss?.max_severity?.percentile)
? epss?.max_severity?.percentile.toFixed(5) : _("N/A")}
? `${(epss?.max_severity?.percentile * 100).toFixed(3)}%`
: _('N/A')}
</TableData>
</TableRow>
<TableRow>
Expand All @@ -266,13 +268,16 @@ const Details = ({entity, ...props}) => {
<TableRow>
<TableData>{_('CVE Severity')}</TableData>
<Severitybar
severity={isDefined(epss?.max_severity?.cve?.severity)
? epss?.max_severity?.cve?.severity : _("N/A")}
severity={
isDefined(epss?.max_severity?.cve?.severity)
? epss?.max_severity?.cve?.severity
: _('N/A')
}
/>
</TableRow>
</>
}
{ gmp.settings.enableEPSS && isDefined(epss?.max_epss) &&
)}
{gmp.settings.enableEPSS && isDefined(epss?.max_epss) && (
<>
<TableData colSpan="2">
<b>{_('EPSS (highest EPSS score)')}</b>
Expand All @@ -281,14 +286,16 @@ const Details = ({entity, ...props}) => {
<TableData>{_('EPSS Score')}</TableData>
<TableData>
{isNumber(epss?.max_epss?.score)
? epss?.max_epss?.score.toFixed(5) : _("N/A")}
? epss?.max_epss?.score.toFixed(5)
: _('N/A')}
</TableData>
</TableRow>
<TableRow>
<TableData>{_('EPSS Percentile')}</TableData>
<TableData>{_('EPSS Percentage')}</TableData>
<TableData>
{isNumber(epss?.max_epss?.percentile)
? epss?.max_epss?.percentile.toFixed(5) : _("N/A")}
? `${(epss?.max_epss?.percentile * 100).toFixed(3)}%`
: _('N/A')}
</TableData>
</TableRow>
<TableRow>
Expand All @@ -303,13 +310,16 @@ const Details = ({entity, ...props}) => {
<TableData>{_('CVE Severity')}</TableData>
<TableData>
<Severitybar
severity={isDefined(epss?.max_epss?.cve?.severity)
? epss?.max_epss?.cve?.severity : _("N/A")}
severity={
isDefined(epss?.max_epss?.cve?.severity)
? epss?.max_epss?.cve?.severity
: _('N/A')
}
/>
</TableData>
</TableRow>
</>
}
)}
</TableBody>
</InfoTable>
</Layout>
Expand Down
4 changes: 1 addition & 3 deletions src/web/pages/results/filterdialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const ResultsFilterDialog = ({
},
{
name: 'epss_percentile',
displayName: _('EPSS Percentile'),
displayName: _('EPSS Percentage'),
},
];

Expand Down Expand Up @@ -205,5 +205,3 @@ ResultsFilterDialog.propTypes = {
};

export default ResultsFilterDialog;

// vim: set ts=2 sw=2 tw=80:
Loading

0 comments on commit 4b30802

Please sign in to comment.