Skip to content

Commit

Permalink
Merge pull request #7 from polarityio/develop
Browse files Browse the repository at this point in the history
INT-1095 Removing Need for Entity SubType
Remove custom summary components
Use built-in CVE type
Improve CVE search
  • Loading branch information
sarus authored Dec 2, 2023
2 parents f9378a5 + 9a9aae3 commit 1831f4b
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 48 deletions.
8 changes: 7 additions & 1 deletion components/block.js
Original file line number Diff line number Diff line change
@@ -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');
})
});
3 changes: 0 additions & 3 deletions components/summary.js

This file was deleted.

19 changes: 4 additions & 15 deletions config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -102,8 +91,8 @@ module.exports = {
description: 'Valid VulDB API Key.',
default: '',
type: 'password',
userCanEdit: true,
adminOnly: false
userCanEdit: false,
adminOnly: true
}
]
};
18 changes: 9 additions & 9 deletions config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -57,9 +58,8 @@
"description": "Valid VulDB API Key.",
"default": "",
"type": "password",
"userCanEdit": true,
"adminOnly": false
"userCanEdit": false,
"adminOnly": true
}
],
"entityTypes": []
]
}
16 changes: 11 additions & 5 deletions integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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
Expand All @@ -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
}
});
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
4 changes: 2 additions & 2 deletions templates/block.hbs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{{#if (eq block.entity.subtype "custom.kb")}}
{{#if isKbEntity}}
<div class="p-link">
<a href="https://www.catalog.update.microsoft.com/Search.aspx?q={{block.entity.value}}">Pivot to Microsoft Update Catalog {{fa-icon "external-link-square" class="external-link-icon" fixedWidth=true}}</a>
</div>
{{/if}}
{{#if (eq block.entity.subtype "custom.cve")}}
{{#if isCveEntity}}
<div class="p-link">
<a href="https://cve.mitre.org/cgi-bin/cvename.cgi?name={{block.entity.value}}">Pivot to MITRE CVE Search {{fa-icon "external-link-square" class="external-link-icon" fixedWidth=true}}</a>
</div>
Expand Down
6 changes: 0 additions & 6 deletions templates/summary.hbs

This file was deleted.

0 comments on commit 1831f4b

Please sign in to comment.