n8n-nodes-tenable-community
Version:
n8n node for the Tenable One platform
159 lines (158 loc) • 6.2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TenableOneApi = void 0;
/**
* Implements the credential type for the Tenable One API.
* This class defines the properties and test request for the Tenable One API credentials.
*/
class TenableOneApi {
constructor() {
this.name = 'tenableOneApi';
this.displayName = 'Tenable API';
this.documentationUrl = 'httpsDeveloperTenableCom';
this.properties = [
{
displayName: 'Platform Type',
name: 'platformType',
type: 'options',
options: [
{
name: 'Tenable One Platform (Cloud)',
value: 'one_platform',
},
{
name: 'Tenable Security Center (On-Prem)',
value: 'sc',
},
{
name: 'Tenable Identity Exposure',
value: 'ie',
},
],
default: 'one_platform',
description: 'Select the Tenable product you want to connect to',
},
// --- Tenable One Platform (Cloud) Credentials ---
{
displayName: 'Access Key',
name: 'accessKey',
type: 'string',
typeOptions: { password: true },
default: '',
displayOptions: {
show: {
platformType: ['one_platform'],
},
},
},
{
displayName: 'Secret Key',
name: 'secretKey',
type: 'string',
typeOptions: { password: true },
default: '',
displayOptions: {
show: {
platformType: ['one_platform'],
},
},
},
// --- Tenable Security Center (On-Prem) Credentials ---
{
displayName: 'Tenable Security Center URL',
name: 'scUrl',
type: 'string',
default: 'https://your-sc-instance.example.com',
displayOptions: {
show: {
platformType: ['sc'],
},
},
},
// ... (scAccessKey and scSecretKey fields remain the same)
{
displayName: 'Access Key',
name: 'scAccessKey',
type: 'string',
typeOptions: { password: true },
default: '',
displayOptions: {
show: {
platformType: ['sc'],
},
},
},
{
displayName: 'Secret Key',
name: 'scSecretKey',
type: 'string',
typeOptions: {
password: true,
},
default: '',
displayOptions: {
show: {
platformType: ['sc'],
},
},
},
// --- Tenable Identity Exposure Credentials ---
{
displayName: 'Deployment Type',
name: 'ieDeploymentType',
type: 'options',
options: [
{ name: 'Cloud', value: 'cloud' },
{ name: 'On-Premises', value: 'onprem' },
],
default: 'cloud',
description: 'Select if you are using the Cloud or an On-Premises instance of Tenable.ie',
displayOptions: {
show: {
platformType: ['ie'],
},
},
},
{
displayName: 'API Key',
name: 'ieApiKey',
type: 'string',
typeOptions: { password: true },
default: '',
displayOptions: {
show: {
platformType: ['ie'],
},
},
},
{
displayName: 'On-Premises URL',
name: 'ieUrl',
type: 'string',
default: '',
placeholder: 'https://your-ie-instance.example.com',
displayOptions: {
show: {
platformType: ['ie'],
ieDeploymentType: ['onprem'], // Only show this field for On-Premises deployment
},
},
},
];
// --- Test Request Logic (Final Version) ---
this.test = {
request: {
baseURL: '={{ $credentials.platformType === "sc" ? $credentials.scUrl : ($credentials.platformType === "ie" && $credentials.ieDeploymentType === "onprem" ? $credentials.ieUrl : "https://cloud.tenable.com") }}',
url: '={{ $credentials.platformType === "sc" ? "/rest/system" : ($credentials.platformType === "ie" ? "/api/v3/alerts?limit=1" : "/scanners") }}',
headers: {
// Architectural Improvement: The test request now correctly handles all platform types.
// Added a condition for 'sc' to build the X-ApiKeys header, which was missing.
// This ensures the "Test" button works for Tenable.sc credentials.
'X-ApiKeys': '={{ $credentials.platformType === "one_platform" ? "accessKey=" + $credentials.accessKey + ";secretKey=" + $credentials.secretKey : ($credentials.platformType === "sc" ? "accessKey=" + $credentials.scAccessKey + ";secretKey=" + $credentials.scSecretKey : "") }}',
'Authorization': '={{ $credentials.platformType === "ie" ? "Bearer " + $credentials.ieApiKey : "" }}',
},
},
};
}
}
exports.TenableOneApi = TenableOneApi;