diff --git a/src/gmp/models/__tests__/cve.js b/src/gmp/models/__tests__/cve.js index 9411b27a1a..48d087e66b 100644 --- a/src/gmp/models/__tests__/cve.js +++ b/src/gmp/models/__tests__/cve.js @@ -140,7 +140,6 @@ describe('CVE model tests', () => { }, }; const cve = Cve.fromElement(elem); - expect(cve.products).toEqual(['foo:bar/dolor', 'ipsum:lorem']); }); @@ -194,40 +193,6 @@ describe('CVE model tests', () => { expect(cve.references).toEqual(res); }); - test('should parse cvss source', () => { - const elem = { - raw_data: { - entry: { - 'published-datetime': '2018-10-10T11:41:23.022Z', - 'last-modified-datetime': '2018-10-10T11:41:23.022Z', - cvss: { - base_metrics: { - source: 'prot://url', - }, - }, - }, - }, - }; - const cve = Cve.fromElement(elem); - - expect(cve.source).toEqual('prot://url'); - }); - - test('should parse summary', () => { - const elem = { - raw_data: { - entry: { - 'published-datetime': '2018-10-10T11:41:23.022Z', - 'last-modified-datetime': '2018-10-10T11:41:23.022Z', - summary: 'lorem ipsum', - }, - }, - }; - const cve = Cve.fromElement(elem); - - expect(cve.description).toEqual('lorem ipsum'); - }); - test('should parse vulnerable products from raw data', () => { const elem = { raw_data: { @@ -245,20 +210,6 @@ describe('CVE model tests', () => { expect(cve.products).toEqual(['lorem', 'ipsum']); }); - test('should delete raw data', () => { - const elem = { - raw_data: { - entry: { - 'published-datetime': {__text: '2018-10-10T11:41:23.022Z'}, - 'last-modified-datetime': {__text: '2018-10-10T11:41:23.022Z'}, - }, - }, - }; - const cve = Cve.fromElement(elem); - - expect(cve.raw_data).toBeUndefined(); - }); - test('should return empty array for references if no raw data is given', () => { const cve = Cve.fromElement({}); diff --git a/src/gmp/models/cve.js b/src/gmp/models/cve.js index 144c65c3ce..cc0eb4706e 100644 --- a/src/gmp/models/cve.js +++ b/src/gmp/models/cve.js @@ -114,6 +114,7 @@ class Cve extends Info { } ret.cvssBaseVector = ret.cvss_vector; + ret.products = isEmpty(ret.products) ? [] : ret.products.split(' '); /* @@ -131,7 +132,7 @@ class Cve extends Info { ); ret.references = []; - if (isDefined(element.cve.references?.reference)) { + if (element.cve && isDefined(element.cve.references?.reference)) { ret.references = map(element.cve.references.reference, ref => { let tags = []; if (isArray(ref.tags.tag)) { @@ -156,6 +157,7 @@ class Cve extends Info { } if ( + ret.products && ret.products.length === 0 && isDefined(element.cve?.configuration_nodes?.node) ) { @@ -182,11 +184,11 @@ class Cve extends Info { ret.raw_data?.entry?.['vulnerable-software-list']?.product; if (productsEntry) { ret.products = isArray(productsEntry) ? productsEntry : [productsEntry]; - } else { - ret.products = []; } } + ret.products = ret.products.filter(product => product !== ''); + return ret; } }