n8n-nodes-tenable-community
Version:
n8n node for the Tenable One platform
85 lines (84 loc) • 3.73 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.WebAppScanning = void 0;
const n8n_workflow_1 = require("n8n-workflow");
const GenericFunctions_1 = require("./GenericFunctions");
const WebAppScanning_node_options_1 = require("./WebAppScanning.node.options");
class WebAppScanning {
constructor() {
this.description = {
displayName: 'Tenable Web App Scanning',
name: 'tenableWebAppScanning',
icon: 'file:tenable.svg',
group: ['transform'],
version: 1,
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
description: 'Interact with the Tenable Web App Scanning API',
defaults: {
name: 'Tenable Web App Scanning',
},
inputs: ["main" /* NodeConnectionType.Main */],
outputs: ["main" /* NodeConnectionType.Main */],
credentials: [
{
name: 'tenableApi',
required: true,
},
],
properties: [
{
displayName: 'Resource',
name: 'resource',
type: 'options',
noDataExpression: true,
options: [
{ name: 'Attachment', value: 'attachment' },
{ name: 'Configuration', value: 'configuration' },
{ name: 'Export', value: 'export' },
{ name: 'Filter', value: 'filter' },
{ name: 'Folder', value: 'folder' },
{ name: 'Plugin', value: 'plugin' },
{ name: 'Scan', value: 'scan' },
{ name: 'Template', value: 'template' },
{ name: 'Vulnerability', value: 'vulnerability' },
],
default: 'scan',
},
...WebAppScanning_node_options_1.webAppScanningFields,
],
};
}
async execute() {
const items = this.getInputData();
const returnData = [];
for (let i = 0; i < items.length; i++) {
try {
const resource = this.getNodeParameter('resource', i, '');
const operation = this.getNodeParameter('operation', i, '');
const additionalFields = this.getNodeParameter('additionalFields', i, {});
const body = {};
const qs = {};
// Simplified logic, a full implementation would have more branches
// and get more specific parameters.
if (resource === 'configuration' && operation === 'search') {
Object.assign(body, additionalFields);
}
else if (resource === 'attachment' && operation === 'download') {
qs.attachmentId = this.getNodeParameter('attachmentId', i, '');
}
const response = await GenericFunctions_1.webAppScanningApiRequest.call(this, resource, operation, body, qs);
returnData.push({ json: response });
}
catch (error) {
if (this.continueOnFail()) {
const nodeError = new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
returnData.push({ json: { error: nodeError.message }, error: nodeError });
continue;
}
throw error;
}
}
return [this.helpers.returnJsonArray(returnData)];
}
}
exports.WebAppScanning = WebAppScanning;