diff --git a/gsa/src/gmp/models/__tests__/nvt.js b/gsa/src/gmp/models/__tests__/nvt.js index eb33c4b964..56252013eb 100644 --- a/gsa/src/gmp/models/__tests__/nvt.js +++ b/gsa/src/gmp/models/__tests__/nvt.js @@ -21,6 +21,7 @@ import Nvt, {getRefs, hasRefType, getFilteredRefIds} from 'gmp/models/nvt'; import Info from 'gmp/models/info'; import {testModelFromElement, testModelMethods} from 'gmp/models/testing'; +import date from 'gmp/models/date'; describe('nvt Model tests', () => { testModelFromElement(Nvt, 'nvt'); @@ -160,6 +161,7 @@ describe('nvt Model tests', () => { severity: { score: 94, origin: 'Vendor', + date: '2021-03-10T06:40:13Z', }, }, cvss_base: '6.6', @@ -169,6 +171,7 @@ describe('nvt Model tests', () => { severity: { score: 74, origin: 'Greenbone', + date: '2020-03-10T06:40:13Z', }, }, cvss_base: '', @@ -184,13 +187,16 @@ describe('nvt Model tests', () => { expect(nvt1.severity).toEqual(9.4); expect(nvt1.severityOrigin).toEqual('Vendor'); + expect(nvt1.severityDate).toEqual(date('2021-03-10T06:40:13Z')); expect(nvt1.cvss_base).toBeUndefined(); expect(nvt2.severity).toEqual(7.4); expect(nvt2.cvss_base).toBeUndefined(); expect(nvt2.severityOrigin).toEqual('Greenbone'); + expect(nvt2.severityDate).toEqual(date('2020-03-10T06:40:13Z')); expect(nvt3.cvss_base).toBeUndefined(); expect(nvt3.severity).toEqual(1.0); expect(nvt3.severityOrigin).toEqual(''); + expect(nvt3.severityDate).toBeUndefined(); }); test('should parse preferences', () => { diff --git a/gsa/src/gmp/models/nvt.js b/gsa/src/gmp/models/nvt.js index 69d7ec9926..d1755545e3 100644 --- a/gsa/src/gmp/models/nvt.js +++ b/gsa/src/gmp/models/nvt.js @@ -20,7 +20,7 @@ import {isDefined, isArray, isString} from 'gmp/utils/identity'; import {isEmpty, split} from 'gmp/utils/string'; import {map} from 'gmp/utils/array'; -import {parseFloat, parseSeverity, parseText} from 'gmp/parser'; +import {parseDate, parseFloat, parseSeverity, parseText} from 'gmp/parser'; import Info from './info'; @@ -149,8 +149,11 @@ class Nvt extends Info { if (isDefined(ret.severities)) { const {severity} = ret.severities; - ret.severity = parseSeverity(severity.score / 10); - ret.severityOrigin = parseText(severity.origin); + ret.severity = parseSeverity(severity?.score / 10); + ret.severityOrigin = parseText(severity?.origin); + ret.severityDate = isDefined(severity?.date) + ? parseDate(severity.date) + : undefined; } else { ret.severity = parseSeverity(ret.cvss_base); } diff --git a/gsa/src/web/pages/nvts/details.js b/gsa/src/web/pages/nvts/details.js index 832d3a9500..06c2202b67 100644 --- a/gsa/src/web/pages/nvts/details.js +++ b/gsa/src/web/pages/nvts/details.js @@ -18,6 +18,7 @@ import React from 'react'; import _ from 'gmp/locale'; +import {dateTimeWithTimeZone} from 'gmp/locale/date'; import {isDefined} from 'gmp/utils/identity'; @@ -45,7 +46,15 @@ import Solution from './solution'; import Pre from './preformatted'; const NvtDetails = ({entity, links = true}) => { - const {tags = {}, severity, qod, family, solution, severityOrigin} = entity; + const { + tags = {}, + severity, + qod, + family, + solution, + severityOrigin, + severityDate, + } = entity; return ( {isDefined(tags.summary) && ( @@ -84,6 +93,10 @@ const NvtDetails = ({entity, links = true}) => { {na(getTranslatableSeverityOrigin(severityOrigin))} + + {_('CVSS Date')} + {dateTimeWithTimeZone(severityDate)} +