diff --git a/components/block.js b/components/block.js index 9812a0b..cccd7fd 100644 --- a/components/block.js +++ b/components/block.js @@ -1,6 +1,12 @@ polarity.export = PolarityComponent.extend({ details: Ember.computed.alias('block.data.details'), - timezone: Ember.computed('Intl', function() { + timezone: Ember.computed('Intl', function () { return Intl.DateTimeFormat().resolvedOptions().timeZone; + }), + isKbEntity: Ember.computed('block.entity.types.[]', function () { + return this.get('block.entity.types').includes('custom.kb'); + }), + isCveEntity: Ember.computed('block.entity.types.[]', function () { + return this.get('block.entity.types').includes('cve'); }) }); diff --git a/components/summary.js b/components/summary.js deleted file mode 100644 index a7de17c..0000000 --- a/components/summary.js +++ /dev/null @@ -1,3 +0,0 @@ -polarity.export = PolarityComponent.extend({ - details: Ember.computed.alias('block.data.details') -}); diff --git a/config/config.js b/config/config.js index d4d3960..9627379 100644 --- a/config/config.js +++ b/config/config.js @@ -23,14 +23,11 @@ module.exports = { * @optional */ description: 'The Community Driven Vulnerability Database', + entityTypes: ['cve'], customTypes: [ { key: 'kb', regex: /KB\s?[0-9]{7}/ - }, - { - key: 'cve', - regex: /CVE-\d{4}-\d{4,7}/ } ], defaultColor: 'light-pink', @@ -51,14 +48,6 @@ module.exports = { file: './templates/block.hbs' } }, - summary: { - component: { - file: './components/summary.js' - }, - template: { - file: './templates/summary.hbs' - } - }, request: { // Provide the path to your certFile. Leave an empty string to ignore this option. // Relative paths are relative to the integration's root directory @@ -74,7 +63,7 @@ module.exports = { ca: '', // An HTTP proxy to be used. Supports proxy Auth with Basic Auth, identical to support for // the url parameter (by embedding the auth info in the uri) - proxy: "" + proxy: '' }, logging: { level: 'info' //trace, debug, info, warn, error, fatal @@ -102,8 +91,8 @@ module.exports = { description: 'Valid VulDB API Key.', default: '', type: 'password', - userCanEdit: true, - adminOnly: false + userCanEdit: false, + adminOnly: true } ] }; diff --git a/config/config.json b/config/config.json index 3f64e20..b7c47e6 100644 --- a/config/config.json +++ b/config/config.json @@ -3,18 +3,19 @@ "name": "VulDB", "acronym": "VULDB", "description": "The Community Driven Vulnerability Database", + "entityTypes": [ + "cve" + ], "customTypes": [ { "key": "kb", "regex": "KB\\s?[0-9]{7}" - }, - { - "key": "cve", - "regex": "CVE-\\d{4}-\\d{4,7}" } ], "defaultColor": "light-pink", - "styles": ["./styles/styles.less"], + "styles": [ + "./styles/styles.less" + ], "block": { "component": { "file": "./components/block.js" @@ -57,9 +58,8 @@ "description": "Valid VulDB API Key.", "default": "", "type": "password", - "userCanEdit": true, - "adminOnly": false + "userCanEdit": false, + "adminOnly": true } - ], - "entityTypes": [] + ] } \ No newline at end of file diff --git a/integration.js b/integration.js index 83c370c..81761be 100644 --- a/integration.js +++ b/integration.js @@ -60,16 +60,21 @@ function doLookup(entities, options, cb) { method: 'POST', uri: `${options.url}/?api`, form: { - apikey: options.apiKey, - search: entity.value + apikey: options.apiKey }, json: true }; + if (entity.types.includes('cve')) { + requestOptions.form.advancedsearch = `cve:${entity.value}`; + } else { + requestOptions.form.search = entity.value; + } + Logger.trace({ uri: requestOptions }, 'Request URI'); - tasks.push(function(done) { - requestWithDefaults(requestOptions, function(httpError, res, body) { + tasks.push(function (done) { + requestWithDefaults(requestOptions, function (httpError, res, body) { if (httpError) { return done({ detail: 'HTTP Request Error', @@ -148,6 +153,7 @@ function doLookup(entities, options, cb) { results.forEach((result) => { if ( result.body === null || + !result.body.result || (result.body && Array.isArray(result.body.result) && result.body.result.length === 0) ) { // body.result is an array of result items. If it is empty or does not exist then there are no results @@ -160,7 +166,7 @@ function doLookup(entities, options, cb) { lookupResults.push({ entity: result.entity, data: { - summary: [], + summary: [`Results: ${result.body.result.length}`], details: result.body } }); diff --git a/package-lock.json b/package-lock.json index 547dac9..88328d1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "VulDB", - "version": "3.0.6", + "version": "3.0.8", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -58,9 +58,9 @@ "integrity": "sha512-NfJ4UzBCcQGLDlQq7nHxH+tv3kyZ0hHQqF5BO6J7tNJeP5do1llPr8dZ8zHonfhAu0PHAdMkSo+8o0wxg9lZWw==" }, "async": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz", - "integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==" + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.5.tgz", + "integrity": "sha512-baNZyqaaLhyLVKm/DlvdW051MSgO6b8eVfIezl9E5PqWxFgzLm/wQntEW4zOytVburDEr0JlALEpdOFwvErLsg==" }, "asynckit": { "version": "0.4.0", diff --git a/package.json b/package.json index 084e683..8475f67 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { "name": "VulDB", - "version": "3.0.6", + "version": "3.0.8", "main": "./integration.js", "private": true, "dependencies": { - "async": "^3.2.4", - "postman-request": "^2.88.1-postman.32" + "async": "^3.2.5", + "postman-request": "^2.88.1-postman.33" } } diff --git a/templates/block.hbs b/templates/block.hbs index 85114c5..8a475cc 100644 --- a/templates/block.hbs +++ b/templates/block.hbs @@ -1,9 +1,9 @@ -{{#if (eq block.entity.subtype "custom.kb")}} +{{#if isKbEntity}}
{{/if}} -{{#if (eq block.entity.subtype "custom.cve")}} +{{#if isCveEntity}} diff --git a/templates/summary.hbs b/templates/summary.hbs deleted file mode 100644 index 4896f1e..0000000 --- a/templates/summary.hbs +++ /dev/null @@ -1,6 +0,0 @@ -{{#if (gt details.result.length 0)}} - - {{block.acronym}} - Results: {{details.result.length}} - -{{/if}}