From 4f862a7e35517725e0638c5975e01d5dcd9bafe6 Mon Sep 17 00:00:00 2001 From: daniele-mng Date: Wed, 11 Dec 2024 11:57:36 +0100 Subject: [PATCH] change: epss score to be displayed in percentage --- public/locales/gsa-de.json | 4 +- src/web/pages/cves/__tests__/detailspage.jsx | 2 +- src/web/pages/cves/__tests__/listpage.jsx | 2 +- src/web/pages/cves/details.jsx | 7 +-- src/web/pages/cves/filterdialog.jsx | 2 +- src/web/pages/cves/row.jsx | 7 ++- src/web/pages/cves/table.jsx | 4 +- src/web/pages/nvts/__tests__/detailspage.jsx | 4 +- src/web/pages/nvts/__tests__/listpage.jsx | 4 +- src/web/pages/nvts/details.jsx | 10 ++-- src/web/pages/nvts/filterdialog.jsx | 2 +- src/web/pages/nvts/row.jsx | 7 ++- src/web/pages/nvts/table.jsx | 4 +- .../pages/results/__tests__/detailspage.jsx | 4 +- src/web/pages/results/__tests__/row.jsx | 6 +-- src/web/pages/results/detailspage.jsx | 46 +++++++++++-------- src/web/pages/results/filterdialog.jsx | 4 +- src/web/pages/results/row.jsx | 22 ++++----- src/web/pages/results/table.jsx | 20 +++----- 19 files changed, 75 insertions(+), 86 deletions(-) diff --git a/public/locales/gsa-de.json b/public/locales/gsa-de.json index 69ae377472..cd124e0f66 100644 --- a/public/locales/gsa-de.json +++ b/public/locales/gsa-de.json @@ -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)", @@ -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", diff --git a/src/web/pages/cves/__tests__/detailspage.jsx b/src/web/pages/cves/__tests__/detailspage.jsx index 177f46bdcb..0ca6ad7230 100644 --- a/src/web/pages/cves/__tests__/detailspage.jsx +++ b/src/web/pages/cves/__tests__/detailspage.jsx @@ -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'); diff --git a/src/web/pages/cves/__tests__/listpage.jsx b/src/web/pages/cves/__tests__/listpage.jsx index b6095ad80c..b05b57d58e 100644 --- a/src/web/pages/cves/__tests__/listpage.jsx +++ b/src/web/pages/cves/__tests__/listpage.jsx @@ -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 () => { diff --git a/src/web/pages/cves/details.jsx b/src/web/pages/cves/details.jsx index 14e815520f..d583be8a61 100644 --- a/src/web/pages/cves/details.jsx +++ b/src/web/pages/cves/details.jsx @@ -3,7 +3,6 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ - import React from 'react'; import {_, _l} from 'gmp/locale/lang'; @@ -102,8 +101,8 @@ const CveDetails = ({entity}) => { {epss.score.toFixed(5)} - {_('Percentile')} - {epss.percentile.toFixed(5)} + {_('Percentage')} + {`${(epss?.percentile * 100).toFixed(3)}%`} @@ -137,5 +136,3 @@ CveDetails.propTypes = { }; export default CveDetails; - -// vim: set ts=2 sw=2 tw=80: diff --git a/src/web/pages/cves/filterdialog.jsx b/src/web/pages/cves/filterdialog.jsx index 88bd914aa9..071caa79e6 100644 --- a/src/web/pages/cves/filterdialog.jsx +++ b/src/web/pages/cves/filterdialog.jsx @@ -75,7 +75,7 @@ const CvesFilterDialog = ({ }, { name: 'epss_percentile', - displayName: _('EPSS Percentile'), + displayName: _('EPSS Percentage'), }, ]; diff --git a/src/web/pages/cves/row.jsx b/src/web/pages/cves/row.jsx index 7e6cbe0984..f7e25b9295 100644 --- a/src/web/pages/cves/row.jsx +++ b/src/web/pages/cves/row.jsx @@ -3,7 +3,6 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ - import React from 'react'; import {_} from 'gmp/locale/lang'; @@ -66,7 +65,9 @@ const Row = ({ {isNumber(epssScore) ? epssScore.toFixed(5) : _('N/A')} - {isNumber(epssPercentile) ? epssPercentile.toFixed(5) : _('N/A')} + {isNumber(epssPercentile) + ? `${(epssPercentile * 100).toFixed(3)}%` + : _('N/A')} )} @@ -83,5 +84,3 @@ Row.propTypes = { }; export default Row; - -// vim: set ts=2 sw=2 tw=80: diff --git a/src/web/pages/cves/table.jsx b/src/web/pages/cves/table.jsx index aa44580998..8453a99ffd 100644 --- a/src/web/pages/cves/table.jsx +++ b/src/web/pages/cves/table.jsx @@ -107,7 +107,7 @@ const Header = ({ currentSortBy={currentSortBy} sortBy={sort ? 'epss_percentile' : false} onSortChange={onSortChange} - title={_('Percentile')} + title={_('Percentage')} /> )} @@ -140,5 +140,3 @@ export const CvesTable = createEntitiesTable({ }); export default CvesTable; - -// vim: set ts=2 sw=2 tw=80: diff --git a/src/web/pages/nvts/__tests__/detailspage.jsx b/src/web/pages/nvts/__tests__/detailspage.jsx index 7e528d8f9b..6cb6e08705 100644 --- a/src/web/pages/nvts/__tests__/detailspage.jsx +++ b/src/web/pages/nvts/__tests__/detailspage.jsx @@ -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'); diff --git a/src/web/pages/nvts/__tests__/listpage.jsx b/src/web/pages/nvts/__tests__/listpage.jsx index e8dadeb20a..10230777bc 100644 --- a/src/web/pages/nvts/__tests__/listpage.jsx +++ b/src/web/pages/nvts/__tests__/listpage.jsx @@ -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'); @@ -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 () => { diff --git a/src/web/pages/nvts/details.jsx b/src/web/pages/nvts/details.jsx index 2a4ac1e8d8..fcd6d3af4f 100644 --- a/src/web/pages/nvts/details.jsx +++ b/src/web/pages/nvts/details.jsx @@ -113,10 +113,10 @@ const NvtDetails = ({entity, links = true}) => { - {_('EPSS Percentile')} + {_('EPSS Percentage')} {isNumber(epss?.max_severity?.percentile) - ? epss?.max_severity?.percentile.toFixed(5) + ? `${(epss.max_severity.percentile * 100).toFixed(3)}%` : _('N/A')} @@ -154,10 +154,10 @@ const NvtDetails = ({entity, links = true}) => { - {_('EPSS Percentile')} + {_('EPSS Percentage')} {isNumber(epss?.max_epss?.percentile) - ? epss?.max_epss?.percentile.toFixed(5) + ? `${(epss?.max_epss?.percentile * 100).toFixed(3)}%` : _('N/A')} @@ -246,5 +246,3 @@ NvtDetails.propTypes = { }; export default NvtDetails; - -// vim: set ts=2 sw=2 tw=80: diff --git a/src/web/pages/nvts/filterdialog.jsx b/src/web/pages/nvts/filterdialog.jsx index 048649b882..dfc6414e59 100644 --- a/src/web/pages/nvts/filterdialog.jsx +++ b/src/web/pages/nvts/filterdialog.jsx @@ -75,7 +75,7 @@ const NvtsFilterDialog = ({ }, { name: 'epss_percentile', - displayName: _('EPSS Percentile'), + displayName: _('EPSS Percentage'), }, ]; diff --git a/src/web/pages/nvts/row.jsx b/src/web/pages/nvts/row.jsx index f655cfd8ef..65e2146839 100644 --- a/src/web/pages/nvts/row.jsx +++ b/src/web/pages/nvts/row.jsx @@ -3,7 +3,6 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ - import React from 'react'; import Filter from 'gmp/models/filter.js'; @@ -100,7 +99,9 @@ const Row = ({ {isNumber(epssScore) ? epssScore.toFixed(5) : _('N/A')} - {isNumber(epssPercentile) ? epssPercentile.toFixed(5) : _('N/A')} + {isNumber(epssPercentile) + ? `${(epssPercentile * 100).toFixed(3)}%` + : _('N/A')} )} @@ -118,5 +119,3 @@ Row.propTypes = { }; export default Row; - -// vim: set ts=2 sw=2 tw=80: diff --git a/src/web/pages/nvts/table.jsx b/src/web/pages/nvts/table.jsx index 4b41f07f21..dcf8a1c577 100644 --- a/src/web/pages/nvts/table.jsx +++ b/src/web/pages/nvts/table.jsx @@ -136,7 +136,7 @@ const Header = ({ currentSortBy={currentSortBy} sortBy={sort ? 'epss_percentile' : false} onSortChange={onSortChange} - title={_('Percentile')} + title={_('Percentage')} /> )} @@ -169,5 +169,3 @@ export const NvtsTable = createEntitiesTable({ }); export default NvtsTable; - -// vim: set ts=2 sw=2 tw=80: diff --git a/src/web/pages/results/__tests__/detailspage.jsx b/src/web/pages/results/__tests__/detailspage.jsx index 6dd47c2615..ebd5017735 100644 --- a/src/web/pages/results/__tests__/detailspage.jsx +++ b/src/web/pages/results/__tests__/detailspage.jsx @@ -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'); diff --git a/src/web/pages/results/__tests__/row.jsx b/src/web/pages/results/__tests__/row.jsx index b8f6b103cf..949d7bc167 100644 --- a/src/web/pages/results/__tests__/row.jsx +++ b/src/web/pages/results/__tests__/row.jsx @@ -52,13 +52,13 @@ describe('Should render EPSS fields', () => { const {element} = render( - +
, ); - expect(element).toHaveTextContent("0.87650"); - expect(element).toHaveTextContent("0.80000"); + expect(element).toHaveTextContent('0.87650'); + expect(element).toHaveTextContent('80.000%'); }); }); diff --git a/src/web/pages/results/detailspage.jsx b/src/web/pages/results/detailspage.jsx index 0c02ecacf0..7e99a80064 100644 --- a/src/web/pages/results/detailspage.jsx +++ b/src/web/pages/results/detailspage.jsx @@ -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, @@ -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 ( @@ -236,7 +236,7 @@ const Details = ({entity, ...props}) => { {_('Location')} {entity.port} - { gmp.settings.enableEPSS && isDefined(epss?.max_severity) && + {gmp.settings.enableEPSS && isDefined(epss?.max_severity) && ( <> {_('EPSS (CVE with highest severity)')} @@ -245,14 +245,16 @@ const Details = ({entity, ...props}) => { {_('EPSS Score')} {isNumber(epss?.max_severity?.score) - ? epss?.max_severity?.score.toFixed(5) : _("N/A")} + ? epss?.max_severity?.score.toFixed(5) + : _('N/A')} - {_('EPSS Percentile')} + {_('EPSS Percentage')} {isNumber(epss?.max_severity?.percentile) - ? epss?.max_severity?.percentile.toFixed(5) : _("N/A")} + ? `${(epss?.max_severity?.percentile * 100).toFixed(3)}%` + : _('N/A')} @@ -266,13 +268,16 @@ const Details = ({entity, ...props}) => { {_('CVE Severity')} - } - { gmp.settings.enableEPSS && isDefined(epss?.max_epss) && + )} + {gmp.settings.enableEPSS && isDefined(epss?.max_epss) && ( <> {_('EPSS (highest EPSS score)')} @@ -281,14 +286,16 @@ const Details = ({entity, ...props}) => { {_('EPSS Score')} {isNumber(epss?.max_epss?.score) - ? epss?.max_epss?.score.toFixed(5) : _("N/A")} + ? epss?.max_epss?.score.toFixed(5) + : _('N/A')} - {_('EPSS Percentile')} + {_('EPSS Percentage')} {isNumber(epss?.max_epss?.percentile) - ? epss?.max_epss?.percentile.toFixed(5) : _("N/A")} + ? `${(epss?.max_epss?.percentile * 100).toFixed(3)}%` + : _('N/A')} @@ -303,13 +310,16 @@ const Details = ({entity, ...props}) => { {_('CVE Severity')} - } + )} diff --git a/src/web/pages/results/filterdialog.jsx b/src/web/pages/results/filterdialog.jsx index 34916606b0..52ca34fc95 100644 --- a/src/web/pages/results/filterdialog.jsx +++ b/src/web/pages/results/filterdialog.jsx @@ -89,7 +89,7 @@ const ResultsFilterDialog = ({ }, { name: 'epss_percentile', - displayName: _('EPSS Percentile'), + displayName: _('EPSS Percentage'), }, ]; @@ -205,5 +205,3 @@ ResultsFilterDialog.propTypes = { }; export default ResultsFilterDialog; - -// vim: set ts=2 sw=2 tw=80: diff --git a/src/web/pages/results/row.jsx b/src/web/pages/results/row.jsx index 151ea29149..cedca01ef7 100644 --- a/src/web/pages/results/row.jsx +++ b/src/web/pages/results/row.jsx @@ -3,7 +3,6 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ - import React from 'react'; import _ from 'gmp/locale'; @@ -39,7 +38,7 @@ import EntitiesActions from 'web/entities/actions'; import PropTypes from 'web/utils/proptypes'; import ResultDelta from './delta'; -import useGmp from "web/hooks/useGmp"; +import useGmp from 'web/hooks/useGmp'; const Row = ({ actionsComponent: ActionsComponent = EntitiesActions, @@ -64,9 +63,9 @@ const Row = ({ const deltaCompliance = entity.delta?.result?.compliance; const deltaHostname = entity.delta?.result?.host?.hostname; const deltaQoD = entity.delta?.result?.qod?.value; - const epssScore = entity?.information?.epss?.max_severity?.score - const epssPercentile = entity?.information?.epss?.max_severity?.percentile - const gmp = useGmp() + const epssScore = entity?.information?.epss?.max_severity?.score; + const epssPercentile = entity?.information?.epss?.max_severity?.percentile; + const gmp = useGmp(); return ( {delta && ( @@ -161,17 +160,18 @@ const Row = ({ {entity.port} - { - gmp.settings.enableEPSS && !audit && + {gmp.settings.enableEPSS && !audit && ( <> - {isNumber(epssScore) ? epssScore.toFixed(5) : _("N/A")} + {isNumber(epssScore) ? epssScore.toFixed(5) : _('N/A')} - {isNumber(epssPercentile) ? epssPercentile.toFixed(5) : _("N/A")} + {isNumber(epssPercentile) + ? `${(epssPercentile * 100).toFixed(3)}%` + : _('N/A')} - } + )} @@ -190,5 +190,3 @@ Row.propTypes = { }; export default Row; - -// vim: set ts=2 sw=2 tw=80: diff --git a/src/web/pages/results/table.jsx b/src/web/pages/results/table.jsx index 472d8c129c..e1d6eaa768 100644 --- a/src/web/pages/results/table.jsx +++ b/src/web/pages/results/table.jsx @@ -26,7 +26,7 @@ import TableRow from 'web/components/table/row'; import ResultsRow from './row'; import ResultDetails from './details'; -import useGmp from "web/hooks/useGmp"; +import useGmp from 'web/hooks/useGmp'; const Header = ({ actionsColumn, @@ -115,12 +115,9 @@ const Header = ({ onSortChange={onSortChange} title={_('Location')} /> - { - gmp.settings.enableEPSS && !audit && - - {_("EPSS")} - - } + {gmp.settings.enableEPSS && !audit && ( + {_('EPSS')} + )} - { - gmp.settings.enableEPSS && !audit && + {gmp.settings.enableEPSS && !audit && ( <> - } + )} ); @@ -194,5 +190,3 @@ export default createEntitiesTable({ row: ResultsRow, rowDetails: withRowDetails('result', 7)(ResultDetails), }); - -// vim: set ts=2 sw=2 tw=80: