UNPKG

@hijiriishi/piece-myjvn

Version:

This package is an Activepieces piece for integrating with MyJVM. Information on vulnerabilities and countermeasures for software used in Japan, provided through the MyJVN API.

166 lines 6.99 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getVulnOverviewList = void 0; const tslib_1 = require("tslib"); const pieces_framework_1 = require("@activepieces/pieces-framework"); const pieces_common_1 = require("@activepieces/pieces-common"); const pieces_common_2 = require("@activepieces/pieces-common"); const common_1 = require("../common"); const xml2js_1 = require("xml2js"); const zod_1 = require("zod"); exports.getVulnOverviewList = (0, pieces_framework_1.createAction)({ name: 'get-vulnoverviewlist', displayName: 'Get Vuln Overview List', description: 'fetch the overview list of vulnerability countermeasures.', props: { startItem: pieces_framework_1.Property.Number({ displayName: 'startItem', description: 'Start entry index (1 or greater))', required: false, defaultValue: 1 }), maxCountItem: pieces_framework_1.Property.Number({ displayName: 'maxCountItem', description: 'Number of Entries to Retrieve (1 to 50)', required: false, defaultValue: 50 }), cpeName: pieces_framework_1.Property.Array({ displayName: 'cpeNames', description: 'CPE Product Name (Format: cpe:/{part}:{vendor}:{product})', required: false, defaultValue: [], }), vendorId: pieces_framework_1.Property.Array({ displayName: 'vendorIds', description: 'vendorId', required: false, defaultValue: [], }), productId: pieces_framework_1.Property.Array({ displayName: 'productIds', description: 'productId', required: false, defaultValue: [], }), keyword: pieces_framework_1.Property.ShortText({ displayName: 'keyword', description: 'Keyword for partial match search of vendor name', required: false, }), severity: pieces_framework_1.Property.StaticDropdown({ displayName: 'severity', description: 'CVSS Severity ', required: false, options: { options: [ { label: 'Critical', value: 'c' }, { label: 'Important', value: 'h' }, { label: 'Warning', value: 'm' }, { label: 'Attention', value: 'l' }, { label: 'None', value: 'n' }, ], }, }), vector: pieces_framework_1.Property.ShortText({ displayName: 'CVSS Base Metrics', description: 'CVSS Base Metrics', required: false, }), rangeDatePublic: pieces_framework_1.Property.StaticDropdown({ displayName: 'rangeDatePublic', description: 'Specify discovery date range', required: true, options: { options: [ { label: 'No date range specified', value: 'n' }, { label: 'Past week', value: 'w' }, { label: 'Past month', value: 'm' }, ], }, defaultValue: 'w' }), rangeDatePublished: pieces_framework_1.Property.StaticDropdown({ displayName: 'rangeDatePublished', description: 'Specify update date range', required: true, options: { options: [ { label: 'No date range specified', value: 'n' }, { label: 'Past week', value: 'w' }, { label: 'Past month', value: 'm' }, ], }, defaultValue: 'w' }), rangeDateFirstPublished: pieces_framework_1.Property.StaticDropdown({ displayName: 'rangeDateFirstPublished', description: 'Specify publication date range', required: true, options: { options: [ { label: 'No date range specified', value: 'n' }, { label: 'Past week', value: 'w' }, { label: 'Past month', value: 'm' }, ], }, defaultValue: 'w' }), lang: common_1.myjvnCommon.lang, ft: common_1.myjvnCommon.ft, }, run(context) { return tslib_1.__awaiter(this, void 0, void 0, function* () { yield pieces_common_2.propsValidation.validateZod(context.propsValue, { startItem: zod_1.z.number().min(1, 'startItem (1 or greater)').optional(), maxCountItem: zod_1.z.number().min(1).max(50, 'maxCountItem (1 to 50)').optional(), }); const { startItem, maxCountItem, cpeName, vendorId, productId, keyword, severity, vector, rangeDatePublic, rangeDatePublished, rangeDateFirstPublished, lang, ft } = context.propsValue; const payload = new URLSearchParams({ method: 'getVulnOverviewList', feed: 'hnd', }); if (startItem) payload.append('startItem', startItem.toString()); if (maxCountItem) payload.append('maxCountItem', maxCountItem.toString()); if (cpeName && cpeName.length > 0) payload.append('cpeName', cpeName.join('+')); if (vendorId && vendorId.length > 0) payload.append('vendorId', vendorId.join('+')); if (productId && productId.length > 0) payload.append('productId', productId.join('+')); if (keyword) payload.append('keyword', keyword); if (severity) payload.append('severity', severity); if (vector) payload.append('vector', vector); if (rangeDatePublic) payload.append('rangeDatePublic', rangeDatePublic); if (rangeDatePublished) payload.append('rangeDatePublished', rangeDatePublished); if (rangeDateFirstPublished) payload.append('rangeDateFirstPublished', rangeDateFirstPublished); if (lang) payload.append('lang', lang); const res = yield pieces_common_1.httpClient.sendRequest({ method: pieces_common_1.HttpMethod.POST, url: common_1.myjvnCommon.baseUrl, headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, body: payload.toString(), }); if (ft === 'json') { const parser = new xml2js_1.Parser({ explicitArray: false }); const jsonData = yield parser.parseStringPromise(res.body); return jsonData; } else { return res.body; } }); }, }); //# sourceMappingURL=get-vulnoverviewlist.js.map