diff --git a/packages/nodes-base/credentials/CortexApi.credentials.ts b/packages/nodes-base/credentials/CortexApi.credentials.ts index eb07506bbf..5cdc70f13a 100644 --- a/packages/nodes-base/credentials/CortexApi.credentials.ts +++ b/packages/nodes-base/credentials/CortexApi.credentials.ts @@ -20,7 +20,7 @@ export class CortexApi implements ICredentialType { type: 'string' as NodePropertyTypes, description: 'The URL of the Cortex instance', default: '', - placeholder:'https://localhost:9001' + placeholder: 'https://localhost:9001', }, ]; } diff --git a/packages/nodes-base/credentials/TheHiveApi.credentials.ts b/packages/nodes-base/credentials/TheHiveApi.credentials.ts index 3476ea38bc..5298da770c 100644 --- a/packages/nodes-base/credentials/TheHiveApi.credentials.ts +++ b/packages/nodes-base/credentials/TheHiveApi.credentials.ts @@ -27,16 +27,16 @@ export class TheHiveApi implements ICredentialType { default: '', type: 'options' as NodePropertyTypes, description: 'The version of api to be used', - options:[ + options: [ { - name:'Version 1', - value:'v1', - description:'API version supported by TheHive 4' + name: 'Version 1', + value: 'v1', + description: 'API version supported by TheHive 4', }, { - name:'Version 0', - value:'', - description:'API version supported by TheHive 3' + name: 'Version 0', + value: '', + description: 'API version supported by TheHive 3', }, ], }, diff --git a/packages/nodes-base/nodes/Cortex/AnalyzerDescriptions.ts b/packages/nodes-base/nodes/Cortex/AnalyzerDescriptions.ts index 318e5b7fa0..d677c1a70e 100644 --- a/packages/nodes-base/nodes/Cortex/AnalyzerDescriptions.ts +++ b/packages/nodes-base/nodes/Cortex/AnalyzerDescriptions.ts @@ -4,7 +4,7 @@ import { import { TLP, -}from './AnalyzerInterface'; +} from './AnalyzerInterface'; export const analyzersOperations = [ { @@ -31,7 +31,7 @@ export const analyzersOperations = [ }, ] as INodeProperties[]; -export const analyzerFields: INodeProperties[] =[ +export const analyzerFields: INodeProperties[] = [ { displayName: 'Analyzer Type', name: 'analyzer', @@ -40,12 +40,12 @@ export const analyzerFields: INodeProperties[] =[ typeOptions: { loadOptionsMethod: 'loadActiveAnalyzers', }, - displayOptions:{ + displayOptions: { show: { resource: [ 'analyzer', ], - operation:[ + operation: [ 'execute', ], }, @@ -58,22 +58,22 @@ export const analyzerFields: INodeProperties[] =[ name: 'observableType', type: 'options', required: true, - displayOptions:{ + displayOptions: { show: { resource: [ 'analyzer', ], - operation:[ + operation: [ 'execute', ], }, - hide:{ - analyzer:[ + hide: { + analyzer: [ '', ], }, }, - typeOptions:{ + typeOptions: { loadOptionsMethod: 'loadObservableOptions', loadOptionsDependsOn: [ 'analyzer', @@ -94,15 +94,15 @@ export const analyzerFields: INodeProperties[] =[ resource: [ 'analyzer', ], - operation:[ + operation: [ 'execute', ], }, - hide:{ + hide: { observableType: [ 'file', ], - analyzer:[ + analyzer: [ '', ], }, @@ -136,7 +136,7 @@ export const analyzerFields: INodeProperties[] =[ name: 'tlp', type: 'options', required: false, - displayOptions:{ + displayOptions: { show: { resource: [ 'analyzer', @@ -145,7 +145,7 @@ export const analyzerFields: INodeProperties[] =[ 'execute', ], }, - hide:{ + hide: { observableType: [ '', ], @@ -166,10 +166,10 @@ export const analyzerFields: INodeProperties[] =[ { name: 'Amber', value: TLP.amber, - },{ + }, { name: 'Red', value: TLP.red, - } + }, ], default: 2, description: 'The TLP of the analyzed observable', diff --git a/packages/nodes-base/nodes/Cortex/AnalyzerInterface.ts b/packages/nodes-base/nodes/Cortex/AnalyzerInterface.ts index 608fef6ed6..842f84f4f2 100644 --- a/packages/nodes-base/nodes/Cortex/AnalyzerInterface.ts +++ b/packages/nodes-base/nodes/Cortex/AnalyzerInterface.ts @@ -1,39 +1,39 @@ import { - IDataObject, -}from 'n8n-workflow'; + IDataObject, +} from 'n8n-workflow'; export enum JobStatus { WAITING = 'Waiting', INPROGRESS = 'InProgress', SUCCESS = 'Success', FAILURE = 'Failure', - DELETED = 'Deleted' + DELETED = 'Deleted', } export enum TLP { - white, - green, - amber, - red + white, + green, + amber, + red, } export enum ObservableDataType { - 'domain'= 'domain', - 'file'= 'file', - 'filename'= 'filename', - 'fqdn'= 'fqdn', - 'hash'= 'hash', - 'ip'= 'ip', - 'mail'= 'mail', - 'mail_subject'= 'mail_subject', - 'other'= 'other', - 'regexp'= 'regexp', - 'registry'= 'registry', - 'uri_path'= 'uri_path', - 'url'= 'url', - 'user-agent'= 'user-agent' + 'domain' = 'domain', + 'file' = 'file', + 'filename' = 'filename', + 'fqdn' = 'fqdn', + 'hash' = 'hash', + 'ip' = 'ip', + 'mail' = 'mail', + 'mail_subject' = 'mail_subject', + 'other' = 'other', + 'regexp' = 'regexp', + 'registry' = 'registry', + 'uri_path' = 'uri_path', + 'url' = 'url', + 'user-agent' = 'user-agent', } -export interface IJob{ +export interface IJob { id?: string; organization?: string; analyzerDefinitionId?: string; @@ -44,7 +44,7 @@ export interface IJob{ data?: string; attachment?: IDataObject; parameters?: IDataObject; - message? :string; + message?: string; tlp?: TLP; startDate?: Date; endDate?: Date; @@ -54,10 +54,10 @@ export interface IJob{ updatedBy?: Date; report?: IDataObject | string; } -export interface IAnalyzer{ +export interface IAnalyzer { id?: string; analyzerDefinitionId?: string; - name? :string; + name?: string; version?: string; description?: string; author?: string; @@ -74,7 +74,7 @@ export interface IAnalyzer{ updatedBy?: Date; } -export interface IResponder{ +export interface IResponder { id?: string; name?: string; version?: string; diff --git a/packages/nodes-base/nodes/Cortex/Cortex.node.ts b/packages/nodes-base/nodes/Cortex/Cortex.node.ts index 97eb108ab2..b759594146 100644 --- a/packages/nodes-base/nodes/Cortex/Cortex.node.ts +++ b/packages/nodes-base/nodes/Cortex/Cortex.node.ts @@ -1,6 +1,6 @@ import { - IExecuteFunctions, BINARY_ENCODING, + IExecuteFunctions, } from 'n8n-core'; import { @@ -11,23 +11,23 @@ import { } from './GenericFunctions'; import { - analyzersOperations, analyzerFields, + analyzersOperations, } from './AnalyzerDescriptions'; import { + IBinaryData, + IDataObject, + ILoadOptionsFunctions, INodeExecutionData, + INodePropertyOptions, INodeType, INodeTypeDescription, - INodePropertyOptions, - ILoadOptionsFunctions, - IDataObject, - IBinaryData, } from 'n8n-workflow'; import { - respondersOperations, responderFields, + respondersOperations, } from './ResponderDescription'; import { @@ -43,7 +43,7 @@ import { IJob, } from './AnalyzerInterface'; -import { +import { createHash, } from 'crypto'; @@ -74,21 +74,21 @@ export class Cortex implements INodeType { // Node properties which the user gets displayed and // can change on the node. { - displayName:'Resource', - name:'resource', - type:'options', - options:[ + displayName: 'Resource', + name: 'resource', + type: 'options', + options: [ { name: 'Analyzer', - value:'analyzer', - }, - { - name: 'Responder', - value:'responder', + value: 'analyzer', }, { name: 'Job', - value:'job', + value: 'job', + }, + { + name: 'Responder', + value: 'responder', }, ], default: 'analyzer', @@ -100,7 +100,7 @@ export class Cortex implements INodeType { ...respondersOperations, ...responderFields, ...jobOperations, - ...jobFields + ...jobFields, ], }; @@ -183,7 +183,7 @@ export class Cortex implements INodeType { returnData.push( { value: (dataType as string).split(':')[1], - name: changeCase.capitalCase((dataType as string).split(':')[1]) + name: changeCase.capitalCase((dataType as string).split(':')[1]), }, ); } @@ -249,13 +249,13 @@ export class Cortex implements INodeType { options: { contentType: item.binary[binaryPropertyName].mimeType, filename: item.binary[binaryPropertyName].fileName, - } + }, }, _json: JSON.stringify({ dataType: observableType, tlp, - }) - } + }), + }, }; responseData = await cortexApiRequest.call( @@ -327,15 +327,13 @@ export class Cortex implements INodeType { const entityType = this.getNodeParameter('entityType', i) as string; - const isJSON = this.getNodeParameter('jsonObject',i) as boolean; - let body:IDataObject; - - - if(isJSON){ + const isJSON = this.getNodeParameter('jsonObject', i) as boolean; + let body: IDataObject; + if (isJSON) { const entityJson = JSON.parse(this.getNodeParameter('objectData', i) as string); - + body = { responderId, label: getEntityLabel(entityJson), @@ -344,29 +342,29 @@ export class Cortex implements INodeType { tlp: entityJson.tlp || 2, pap: entityJson.pap || 2, message: entityJson.message || '', - parameters:[], + parameters: [], }; - - }else{ - const values = (this.getNodeParameter('parameters',i) as IDataObject).values as IDataObject; + } else { - body= { + const values = (this.getNodeParameter('parameters', i) as IDataObject).values as IDataObject; + + body = { responderId, dataType: `thehive:${entityType}`, - data: { + data: { _type: entityType, - ...prepareParameters(values) - } + ...prepareParameters(values), + }, }; - if( entityType === 'alert'){ + if (entityType === 'alert') { // deal with alert artifacts const artifacts = (body.data as IDataObject).artifacts as IDataObject; if (artifacts) { - + const artifactValues = (artifacts as IDataObject).artifactValues as IDataObject[]; - + if (artifactValues) { const artifactData = []; @@ -404,51 +402,51 @@ export class Cortex implements INodeType { artifactData.push(element); } - + (body.data as IDataObject).artifacts = artifactData; } } } - if(entityType ==='case_artifact'){ + if (entityType === 'case_artifact') { // deal with file observable if ((body.data as IDataObject).dataType === 'file') { const item = items[i]; - + if (item.binary === undefined) { throw new Error('No binary data exists on item!'); } - + const binaryPropertyName = (body.data as IDataObject).binaryPropertyName as string; if (item.binary[binaryPropertyName] === undefined) { throw new Error(`No binary data property "${binaryPropertyName}" does not exists on item!`); } - + const fileBufferData = Buffer.from(item.binary[binaryPropertyName].data, BINARY_ENCODING); const sha256 = createHash('sha256').update(fileBufferData).digest('hex'); - + (body.data as IDataObject).attachment = { name: item.binary[binaryPropertyName].fileName, hashes: [ - sha256, - createHash('sha1').update(fileBufferData).digest('hex'), - createHash('md5').update(fileBufferData).digest('hex') + sha256, + createHash('sha1').update(fileBufferData).digest('hex'), + createHash('md5').update(fileBufferData).digest('hex'), ], - size:fileBufferData.byteLength, + size: fileBufferData.byteLength, contentType: item.binary[binaryPropertyName].mimeType, - id:sha256, - }; - + id: sha256, + }; + delete (body.data as IDataObject).binaryPropertyName; } } // add the job label after getting all entity attributes body = { label: getEntityLabel(body.data as IDataObject), - ...body + ...body, }; - + } responseData = await cortexApiRequest.call( this, diff --git a/packages/nodes-base/nodes/Cortex/GenericFunctions.ts b/packages/nodes-base/nodes/Cortex/GenericFunctions.ts index 0c301ff3dd..c0945e932b 100644 --- a/packages/nodes-base/nodes/Cortex/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Cortex/GenericFunctions.ts @@ -10,9 +10,9 @@ import { import { IExecuteFunctions, + IExecuteSingleFunctions, IHookFunctions, ILoadOptionsFunctions, - IExecuteSingleFunctions, } from 'n8n-core'; import { @@ -29,7 +29,7 @@ export async function cortexApiRequest(this: IHookFunctions | IExecuteFunctions throw new Error('No credentials got returned!'); } - const headerWithAuthentication = Object.assign({}, { Authorization: ` Bearer ${credentials.cortexApiKey}`}); + const headerWithAuthentication = Object.assign({}, { Authorization: ` Bearer ${credentials.cortexApiKey}` }); let options: OptionsWithUri = { headers: headerWithAuthentication, @@ -41,45 +41,45 @@ export async function cortexApiRequest(this: IHookFunctions | IExecuteFunctions }; if (Object.keys(option).length !== 0) { - options = Object.assign({},options, option); + options = Object.assign({}, options, option); } - if (Object.keys(body).length === 0) { + if (Object.keys(body).length === 0) { delete options.body; } - if (Object.keys(query).length === 0) { + if (Object.keys(query).length === 0) { delete options.qs; } try { return await this.helpers.request!(options); } catch (error) { - if (error.error ) { + if (error.error) { const errorMessage = `Cortex error response [${error.statusCode}]: ${error.error.message}`; throw new Error(errorMessage); } else throw error; } } -export function getEntityLabel(entity: IDataObject): string{ +export function getEntityLabel(entity: IDataObject): string { let label = ''; switch (entity._type) { - case 'case': + case 'case': label = `#${entity.caseId} ${entity.title}`; break; - case 'case_artifact': + case 'case_artifact': //@ts-ignore - label = `[${entity.dataType}] ${entity.data?entity.data:(entity.attachment.name)}`; + label = `[${entity.dataType}] ${entity.data ? entity.data : (entity.attachment.name)}`; break; - case 'alert': + case 'alert': label = `[${entity.source}:${entity.sourceRef}] ${entity.title}`; break; - case 'case_task_log': + case 'case_task_log': label = `${entity.message} from ${entity.createdBy}`; break; - case 'case_task': + case 'case_task': label = `${entity.title} (${entity.status})`; break; - case 'job': + case 'job': label = `${entity.analyzerName} (${entity.status})`; break; default: @@ -95,7 +95,7 @@ export function splitTags(tags: string): string[] { export function prepareParameters(values: IDataObject): IDataObject { const response: IDataObject = {}; for (const key in values) { - if (values[key]!== undefined && values[key]!==null && values[key]!=='') { + if (values[key] !== undefined && values[key] !== null && values[key] !== '') { if (moment(values[key] as string, moment.ISO_8601).isValid()) { response[key] = Date.parse(values[key] as string); } else if (key === 'tags') { diff --git a/packages/nodes-base/nodes/Cortex/JobDescription.ts b/packages/nodes-base/nodes/Cortex/JobDescription.ts index 1db9f41f69..800455b089 100644 --- a/packages/nodes-base/nodes/Cortex/JobDescription.ts +++ b/packages/nodes-base/nodes/Cortex/JobDescription.ts @@ -7,7 +7,7 @@ export const jobOperations = [ displayName: 'Operation', name: 'operation', type: 'options', - description:'Choose an operation', + description: 'Choose an operation', required: true, displayOptions: { show: { @@ -32,13 +32,13 @@ export const jobOperations = [ }, ] as INodeProperties[]; -export const jobFields: INodeProperties[] =[ +export const jobFields: INodeProperties[] = [ { displayName: 'Job ID', name: 'jobId', type: 'string', required: true, - displayOptions:{ + displayOptions: { show: { resource: [ 'job', @@ -49,7 +49,7 @@ export const jobFields: INodeProperties[] =[ ], }, }, - default:'', + default: '', description: 'ID of the job', }, ]; diff --git a/packages/nodes-base/nodes/Cortex/ResponderDescription.ts b/packages/nodes-base/nodes/Cortex/ResponderDescription.ts index 14362a61e4..b341667348 100644 --- a/packages/nodes-base/nodes/Cortex/ResponderDescription.ts +++ b/packages/nodes-base/nodes/Cortex/ResponderDescription.ts @@ -1,8 +1,8 @@ -import { +import { INodeProperties, } from 'n8n-workflow'; -import { +import { TLP, } from './AnalyzerInterface'; @@ -12,7 +12,7 @@ export const respondersOperations = [ name: 'operation', type: 'options', required: true, - description: 'Choose an operation', + description: 'Choose an operation.', displayOptions: { show: { resource: [ @@ -24,11 +24,11 @@ export const respondersOperations = [ { name: 'Execute', value: 'execute', - description: 'Execute Responder' - } + description: 'Execute Responder', + }, ], - default: 'execute' - } + default: 'execute', + }, ] as INodeProperties[]; export const responderFields: INodeProperties[] = [ @@ -38,7 +38,7 @@ export const responderFields: INodeProperties[] = [ type: 'options', required: true, typeOptions: { - loadOptionsMethod: 'loadActiveResponders' + loadOptionsMethod: 'loadActiveResponders', }, default: '', displayOptions: { @@ -48,7 +48,7 @@ export const responderFields: INodeProperties[] = [ ], }, }, - description: 'Choose the responder' + description: 'Choose the responder.', }, { displayName: 'Entity Type', @@ -59,7 +59,7 @@ export const responderFields: INodeProperties[] = [ show: { resource: [ 'responder', - ] + ], }, }, typeOptions: { @@ -69,14 +69,14 @@ export const responderFields: INodeProperties[] = [ ], }, default: '', - description: 'Choose the Data type', + description: 'Choose the Data type.', }, { displayName: 'JSON Parameters', name: 'jsonObject', type: 'boolean', default: false, - description: 'Choose between providing JSON object or seperated attributes', + description: 'Choose between providing JSON object or seperated attributes.', displayOptions: { show: { resource: [ @@ -100,7 +100,7 @@ export const responderFields: INodeProperties[] = [ ], }, }, - default: '' + default: '', }, { displayName: 'Parameters', @@ -125,7 +125,7 @@ export const responderFields: INodeProperties[] = [ name: 'description', type: 'string', default: '', - description: 'Description of the case', + description: 'Description of the case', }, { displayName: 'Severity', @@ -160,14 +160,14 @@ export const responderFields: INodeProperties[] = [ name: 'owner', type: 'string', default: '', - description: `User who owns the case. This is automatically set to current user when status is set to InProgress`, + description: `User who owns the case. This is automatically set to current user when status is set to InProgress.`, }, { displayName: 'Flag', name: 'flag', type: 'boolean', default: false, - description: 'Flag of the case default=false', + description: 'Flag of the case default=false.', }, { displayName: 'TLP', @@ -199,13 +199,13 @@ export const responderFields: INodeProperties[] = [ name: 'tags', type: 'string', default: '', - placeholder:'tag1,tag2,...', + placeholder: 'tag1,tag2,...', }, ], }, ], - typeOptions:{ - loadOptionsDependsOn:[ + typeOptions: { + loadOptionsDependsOn: [ 'entityType', ], }, @@ -231,7 +231,7 @@ export const responderFields: INodeProperties[] = [ ], }, }, - default: {} + default: {}, }, { displayName: 'Parameters', @@ -263,14 +263,14 @@ export const responderFields: INodeProperties[] = [ name: 'severity', type: 'options', default: 2, - options:[ + options: [ { name: 'Low', - value: 1 + value: 1, }, { name: 'Medium', - value: 2 + value: 2, }, { name: 'High', @@ -284,14 +284,14 @@ export const responderFields: INodeProperties[] = [ name: 'date', type: 'dateTime', default: '', - description: 'Date and time when the alert was raised default=now', + description: 'Date and time when the alert was raised default=now.', }, { displayName: 'Tags', name: 'tags', type: 'string', - placeholder:'tag1,tag2,...', - default: '' + placeholder: 'tag1,tag2,...', + default: '', }, { displayName: 'TLP', @@ -300,19 +300,19 @@ export const responderFields: INodeProperties[] = [ default: 2, options: [ { - name:'White', - value:TLP.white, + name: 'White', + value: TLP.white, }, { - name:'Green', - value:TLP.green, + name: 'Green', + value: TLP.green, }, { - name:'Amber', - value:TLP.amber, - },{ - name:'Red', - value:TLP.red, + name: 'Amber', + value: TLP.amber, + }, { + name: 'Red', + value: TLP.red, } ], description: 'Traffict Light Protocol (TLP). Default=Amber', @@ -322,7 +322,7 @@ export const responderFields: INodeProperties[] = [ name: 'status', type: 'options', default: 'New', - options:[ + options: [ { name: 'New', value: 'New', @@ -333,28 +333,28 @@ export const responderFields: INodeProperties[] = [ }, { name: 'Ignored', - value: 'Ignored' + value: 'Ignored', }, { name: 'Imported', value: 'Imported', }, ], - description: 'Status of the alert. Default=New' + description: 'Status of the alert. Default=New', }, { displayName: 'Type', name: 'type', type: 'string', default: '', - description: 'Type of the alert', + description: 'Type of the alert.', }, { displayName: 'Source', name: 'source', type: 'string', default: '', - description: 'Source of the alert', + description: 'Source of the alert.', }, { displayName: 'SourceRef', @@ -367,13 +367,13 @@ export const responderFields: INodeProperties[] = [ displayName: 'Follow', name: 'follow', type: 'boolean', - default: false + default: false, }, { displayName: 'Artifacts', name: 'artifacts', type: 'fixedCollection', - placeholder:'Add an artifact', + placeholder: 'Add an artifact', required: false, typeOptions: { multipleValues: true, @@ -397,55 +397,55 @@ export const responderFields: INodeProperties[] = [ }, { name: 'File', - value: 'file' + value: 'file', }, { name: 'Filename', - value: 'filename' + value: 'filename', }, { name: 'Fqdn', - value: 'fqdn' + value: 'fqdn', }, { name: 'Hash', - value: 'hash' + value: 'hash', }, { name: 'IP', - value: 'ip' + value: 'ip', }, { name: 'Mail', - value: 'mail' + value: 'mail', }, { name: 'Mail Subject', - value: 'mail_subject' + value: 'mail_subject', }, { name: 'Other', - value: 'other' + value: 'other', }, { name: 'Regexp', - value: 'regexp' + value: 'regexp', }, { name: 'Registry', - value: 'registry' + value: 'registry', }, { name: 'Uri Path', - value: 'uri_path' + value: 'uri_path', }, { name: 'URL', - value: 'url' + value: 'url', }, { name: 'User Agent', - value: 'user-agent' + value: 'user-agent', }, ], description: '', @@ -493,14 +493,14 @@ export const responderFields: INodeProperties[] = [ description: '', }, ], - } - ] + }, + ], }, - ] - } + ], + }, ], - typeOptions:{ - loadOptionsDependsOn:[ + typeOptions: { + loadOptionsDependsOn: [ 'entityType', ], }, @@ -554,55 +554,55 @@ export const responderFields: INodeProperties[] = [ }, { name: 'File', - value: 'file' + value: 'file', }, { name: 'Filename', - value: 'filename' + value: 'filename', }, { name: 'Fqdn', - value: 'fqdn' + value: 'fqdn', }, { name: 'Hash', - value: 'hash' + value: 'hash', }, { name: 'IP', - value: 'ip' + value: 'ip', }, { name: 'Mail', - value: 'mail' + value: 'mail', }, { name: 'Mail Subject', - value: 'mail_subject' + value: 'mail_subject', }, { name: 'Other', - value: 'other' + value: 'other', }, { name: 'Regexp', - value: 'regexp' + value: 'regexp', }, { name: 'Registry', - value: 'registry' + value: 'registry', }, { name: 'Uri Path', - value: 'uri_path' + value: 'uri_path', }, { name: 'URL', - value: 'url' + value: 'url', }, { name: 'User Agent', - value: 'user-agent' + value: 'user-agent', }, ], }, @@ -611,9 +611,9 @@ export const responderFields: INodeProperties[] = [ name: 'data', type: 'string', default: '', - displayOptions:{ - hide:{ - dataType:[ + displayOptions: { + hide: { + dataType: [ 'file', ], }, @@ -626,25 +626,25 @@ export const responderFields: INodeProperties[] = [ default: 'data', displayOptions: { show: { - dataType:[ + dataType: [ 'file', ], }, }, - description: 'Name of the binary property which contains the attachement data', + description: 'Name of the binary property which contains the attachement data.', }, { displayName: 'Message', name: 'message', type: 'string', - default: '' + default: '', }, { displayName: 'Start Date', name: 'startDate', type: 'dateTime', default: '', - description: 'Date and time of the begin of the case default=now', + description: 'Date and time of the begin of the case default=now.', }, { displayName: 'TLP', @@ -653,20 +653,20 @@ export const responderFields: INodeProperties[] = [ default: 2, options: [ { - name:'White', - value:TLP.white, + name: 'White', + value: TLP.white, }, { - name:'Green', - value:TLP.green, + name: 'Green', + value: TLP.green, }, { - name:'Amber', - value:TLP.amber, - },{ - name:'Red', - value:TLP.red, - } + name: 'Amber', + value: TLP.amber, + }, { + name: 'Red', + value: TLP.red, + }, ], description: 'Traffict Light Protocol (TLP). Default=Amber', }, @@ -675,7 +675,7 @@ export const responderFields: INodeProperties[] = [ name: 'ioc', type: 'boolean', default: false, - description: 'Indicates if the observable is an IOC (Indicator of compromise)', + description: 'Indicates if the observable is an IOC (Indicator of compromise).', }, { displayName: 'Status', @@ -692,13 +692,13 @@ export const responderFields: INodeProperties[] = [ value: 'Deleted', }, ], - description: 'Status of the observable (Ok or Deleted) default=Ok', - } + description: 'Status of the observable (Ok or Deleted) default=Ok.', + }, ], }, ], - typeOptions:{ - loadOptionsDependsOn:[ + typeOptions: { + loadOptionsDependsOn: [ 'entityType', ], }, @@ -746,7 +746,7 @@ export const responderFields: INodeProperties[] = [ type: 'string', required: false, default: '', - description: 'Title of the task', + description: 'Title of the task.', }, { displayName: 'Status', @@ -776,13 +776,13 @@ export const responderFields: INodeProperties[] = [ displayName: 'Flag', name: 'flag', type: 'boolean', - default: false - } - ] - } + default: false, + }, + ], + }, ], - typeOptions:{ - loadOptionsDependsOn:[ + typeOptions: { + loadOptionsDependsOn: [ 'entityType', ], }, @@ -828,7 +828,7 @@ export const responderFields: INodeProperties[] = [ displayName: 'Message', name: 'message', type: 'string', - default: '' + default: '', }, { displayName: 'Start Date', @@ -857,8 +857,8 @@ export const responderFields: INodeProperties[] = [ ], }, ], - typeOptions:{ - loadOptionsDependsOn:[ + typeOptions: { + loadOptionsDependsOn: [ 'entityType', ], }, @@ -889,4 +889,4 @@ export const responderFields: INodeProperties[] = [ }, default: {}, }, -]; \ No newline at end of file +]; diff --git a/packages/nodes-base/nodes/Cortex/cortex.png b/packages/nodes-base/nodes/Cortex/cortex.png index b750755749..e517928ed6 100644 Binary files a/packages/nodes-base/nodes/Cortex/cortex.png and b/packages/nodes-base/nodes/Cortex/cortex.png differ diff --git a/packages/nodes-base/nodes/TheHive/GenericFunctions.ts b/packages/nodes-base/nodes/TheHive/GenericFunctions.ts index 8c260b0587..3e3e9ae4a3 100644 --- a/packages/nodes-base/nodes/TheHive/GenericFunctions.ts +++ b/packages/nodes-base/nodes/TheHive/GenericFunctions.ts @@ -33,20 +33,20 @@ export async function theHiveApiRequest(this: IHookFunctions | IExecuteFunctions }; if (Object.keys(option).length !== 0) { - options = Object.assign({},options, option); + options = Object.assign({}, options, option); } - if (Object.keys(body).length === 0) { + if (Object.keys(body).length === 0) { delete options.body; } - if (Object.keys(query).length === 0) { + if (Object.keys(query).length === 0) { delete options.qs; } try { return await this.helpers.request!(options); } catch (error) { - if (error.error ) { + if (error.error) { const errorMessage = `TheHive error response [${error.statusCode}]: ${error.error.message || error.error.type}`; throw new Error(errorMessage); } else throw error; @@ -78,7 +78,7 @@ export function splitTags(tags: string): string[] { export function prepareOptional(optionals: IDataObject): IDataObject { const response: IDataObject = {}; for (const key in optionals) { - if (optionals[key]!== undefined && optionals[key]!==null && optionals[key]!=='') { + if (optionals[key] !== undefined && optionals[key] !== null && optionals[key] !== '') { if (moment(optionals[key] as string, moment.ISO_8601).isValid()) { response[key] = Date.parse(optionals[key] as string); } else if (key === 'artifacts') { @@ -116,8 +116,8 @@ export function prepareRangeQuery(range: string, body: { 'query': Array<{}> }) { { '_name': 'page', 'from': parseInt(range.split('-')[0], 10), - 'to': parseInt(range.split('-')[1], 10) - } + 'to': parseInt(range.split('-')[1], 10), + }, ); } } diff --git a/packages/nodes-base/nodes/TheHive/QueryFunctions.ts b/packages/nodes-base/nodes/TheHive/QueryFunctions.ts index cd5b984b8a..b9cf7a2830 100644 --- a/packages/nodes-base/nodes/TheHive/QueryFunctions.ts +++ b/packages/nodes-base/nodes/TheHive/QueryFunctions.ts @@ -1,81 +1,81 @@ // Query types -export declare type queryIndexSignature = '_field'|'_gt'|'_value'|'_gte'|'_lt'|'_lte'|'_and'|'_or'|'_not'|'_in'|'_contains'|'_id'|'_between'|'_parent'|'_parent'|'_child'|'_type'|'_string'|'_like'|'_wildcard'; +export declare type queryIndexSignature = '_field' | '_gt' | '_value' | '_gte' | '_lt' | '_lte' | '_and' | '_or' | '_not' | '_in' | '_contains' | '_id' | '_between' | '_parent' | '_parent' | '_child' | '_type' | '_string' | '_like' | '_wildcard'; export type IQueryObject = { - [key in queryIndexSignature]?: IQueryObject|IQueryObject[]|string|number|object + [key in queryIndexSignature]?: IQueryObject | IQueryObject[] | string | number | object }; // Query Functions -export function Eq(field: string, value: any):IQueryObject{ +export function Eq(field: string, value: any): IQueryObject { // tslint:disable-line:no-any return { '_field': field, '_value': value }; } -export function Gt(field: string, value: any):IQueryObject{ +export function Gt(field: string, value: any): IQueryObject { // tslint:disable-line:no-any return { '_gt': { field: value } }; } -export function Gte(field: string, value: any):IQueryObject{ +export function Gte(field: string, value: any): IQueryObject { // tslint:disable-line:no-any return { '_gte': { field: value } }; } -export function Lt(field: string, value: any):IQueryObject{ +export function Lt(field: string, value: any): IQueryObject { // tslint:disable-line:no-any return { '_lt': { field: value } }; } -export function Lte(field: string, value: any):IQueryObject{ +export function Lte(field: string, value: any): IQueryObject { // tslint:disable-line:no-any return { '_lte': { field: value } }; } -export function And(...criteria: IQueryObject[]): IQueryObject{ +export function And(...criteria: IQueryObject[]): IQueryObject { return { '_and': criteria }; } -export function Or(...criteria: IQueryObject[]): IQueryObject{ +export function Or(...criteria: IQueryObject[]): IQueryObject { return { '_or': criteria }; } -export function Not(criteria: IQueryObject[]): IQueryObject{ +export function Not(criteria: IQueryObject[]): IQueryObject { return { '_not': criteria }; } -export function In(field: string, values: any[]): IQueryObject{ +export function In(field: string, values: any[]): IQueryObject { // tslint:disable-line:no-any return { '_in': { '_field': field, '_values': values } }; } -export function Contains(field: string): IQueryObject{ +export function Contains(field: string): IQueryObject { return { '_contains': field }; } -export function Id(id: string|number): IQueryObject{ - return {'_id': id }; +export function Id(id: string | number): IQueryObject { + return { '_id': id }; } -export function Between(field:string, from_value: any, to_value: any): IQueryObject{ - return {'_between': {'_field': field, '_from': from_value, '_to': to_value } }; +export function Between(field: string, fromValue: any, toValue: any): IQueryObject { // tslint:disable-line:no-any + return { '_between': { '_field': field, '_from': fromValue, '_to': toValue } }; } -export function ParentId(tpe:string, id:string):IQueryObject{ - return { '_parent': {'_type': tpe, '_id': id } }; +export function ParentId(tpe: string, id: string): IQueryObject { + return { '_parent': { '_type': tpe, '_id': id } }; } -export function Parent(tpe:string, criterion:IQueryObject):IQueryObject{ - return { '_parent': {'_type': tpe, '_query': criterion } }; +export function Parent(tpe: string, criterion: IQueryObject): IQueryObject { + return { '_parent': { '_type': tpe, '_query': criterion } }; } -export function Child(tpe:string, criterion:IQueryObject):IQueryObject{ - return { '_child': {'_type': tpe, '_query': criterion } }; +export function Child(tpe: string, criterion: IQueryObject): IQueryObject { + return { '_child': { '_type': tpe, '_query': criterion } }; } -export function Type(tpe:string):IQueryObject{ +export function Type(tpe: string): IQueryObject { return { '_type': tpe }; } -export function queryString(query_string:string):IQueryObject{ - return { '_string': query_string }; +export function queryString(queryString: string): IQueryObject { + return { '_string': queryString }; } -export function Like(field:string, value:string):IQueryObject{ +export function Like(field: string, value: string): IQueryObject { return { '_like': { '_field': field, '_value': value } }; } -export function StartsWith(field:string, value:string){ - if (!value.startsWith('*')){ +export function StartsWith(field: string, value: string) { + if (!value.startsWith('*')) { value = value + '*'; } return { '_wildcard': { '_field': field, '_value': value } }; } -export function EndsWith(field:string, value:string){ - if (!value.endsWith('*')){ +export function EndsWith(field: string, value: string) { + if (!value.endsWith('*')) { value = '*' + value; } return { '_wildcard': { '_field': field, '_value': value } }; } -export function ContainsString(field:string, value:string){ - if (!value.endsWith('*')){ +export function ContainsString(field: string, value: string) { + if (!value.endsWith('*')) { value = value + '*'; } - if (!value.startsWith('*')){ + if (!value.startsWith('*')) { value = '*' + value; } return { '_wildcard': { '_field': field, '_value': value } }; diff --git a/packages/nodes-base/nodes/TheHive/TheHive.node.ts b/packages/nodes-base/nodes/TheHive/TheHive.node.ts index 2e25e23811..72155b8044 100644 --- a/packages/nodes-base/nodes/TheHive/TheHive.node.ts +++ b/packages/nodes-base/nodes/TheHive/TheHive.node.ts @@ -1,42 +1,42 @@ import { - IExecuteFunctions, - BINARY_ENCODING + BINARY_ENCODING, + IExecuteFunctions } from 'n8n-core'; import { - INodeExecutionData, - INodeType, - INodeTypeDescription, + IBinaryData, IDataObject, - INodeParameters, ILoadOptionsFunctions, + INodeExecutionData, + INodeParameters, INodePropertyOptions, - IBinaryData + INodeType, + INodeTypeDescription } from 'n8n-workflow'; import { - alertOperations, alertFields, + alertOperations, } from './descriptions/AlertDescription'; import { - observableOperations, observableFields, + observableOperations, } from './descriptions/ObservableDescription'; import { - caseOperations, caseFields, + caseOperations, } from './descriptions/CaseDescription'; import { - taskOperations, taskFields, + taskOperations, } from './descriptions/TaskDescription'; import { - logOperations, logFields, + logOperations, } from './descriptions/LogDescription'; import { @@ -44,23 +44,23 @@ import { } from 'buffer'; import { - IQueryObject, - Parent, - Id, - Eq, And, Between, - In, ContainsString, + Eq, + Id, + In, + IQueryObject, + Parent, } from './QueryFunctions'; import { - theHiveApiRequest, mapResource, - splitTags, prepareOptional, - prepareSortQuery, prepareRangeQuery, + prepareSortQuery, + splitTags, + theHiveApiRequest, } from './GenericFunctions'; export class TheHive implements INodeType { @@ -164,7 +164,7 @@ export class TheHive implements INodeType { const requestResult = await theHiveApiRequest.call( this, 'GET', - endpoint as string + endpoint as string, ); const returnData: INodePropertyOptions[] = []; @@ -183,35 +183,35 @@ export class TheHive implements INodeType { // if v1 is not used we remove 'count' option const version = this.getCredentials('theHiveApi')?.apiVersion; - const options= [ - ...(version==='v1')?[{name:'Count',value:'count',description:'Count observables'}]:[], - {name:'Create',value:'create',description:'Create observable'}, - {name:'Execute Analyzer',value:'executeAnalyzer',description:'Execute an responder on selected observable'}, - {name:'Execute Responder',value:'executeResponder',description:'Execute a responder on selected observable'}, - {name:'Get All',value:'getAll',description:'Get all observables of a specific case'}, - {name:'Get', value: 'get', description: 'Get a single observable' }, - {name:'Search',value:'search',description:'Search observables'}, - {name:'Update',value:'update',description:'Update observable'}, + const options = [ + ...(version === 'v1') ? [{ name: 'Count', value: 'count', description: 'Count observables' }] : [], + { name: 'Create', value: 'create', description: 'Create observable' }, + { name: 'Execute Analyzer', value: 'executeAnalyzer', description: 'Execute an responder on selected observable' }, + { name: 'Execute Responder', value: 'executeResponder', description: 'Execute a responder on selected observable' }, + { name: 'Get All', value: 'getAll', description: 'Get all observables of a specific case' }, + { name: 'Get', value: 'get', description: 'Get a single observable' }, + { name: 'Search', value: 'search', description: 'Search observables' }, + { name: 'Update', value: 'update', description: 'Update observable' }, ]; return options; }, - async loadTaskOptions(this:ILoadOptionsFunctions): Promise{ - const version = this.getCredentials('theHiveApi')?.apiVersion; - const options =[ - ...(version==='v1')?[{name:'Count',value:'count',description:'Count tasks'}]:[], - {name:'Create',value:'create',description:'Create a task'}, - {name:'Execute Responder', value: 'executeResponder', description: 'Execute a responder on the specified task' }, - {name:'Get All',value:'getAll',description:'Get all asks of a specific case'}, - {name:'Get', value: 'get', description: 'Get a single task' }, - {name:'Search',value:'search',description:'Search tasks'}, - {name:'Update',value:'update',description:'Update a task'}, - ]; - return options; - }, - async loadAlertOptions(this:ILoadOptionsFunctions):Promise{ + async loadTaskOptions(this: ILoadOptionsFunctions): Promise { const version = this.getCredentials('theHiveApi')?.apiVersion; const options = [ - ...(version ==='v1')?[{ name: 'Count', value: 'count', description: 'Count alerts' }]:[], + ...(version === 'v1') ? [{ name: 'Count', value: 'count', description: 'Count tasks' }] : [], + { name: 'Create', value: 'create', description: 'Create a task' }, + { name: 'Execute Responder', value: 'executeResponder', description: 'Execute a responder on the specified task' }, + { name: 'Get All', value: 'getAll', description: 'Get all asks of a specific case' }, + { name: 'Get', value: 'get', description: 'Get a single task' }, + { name: 'Search', value: 'search', description: 'Search tasks' }, + { name: 'Update', value: 'update', description: 'Update a task' }, + ]; + return options; + }, + async loadAlertOptions(this: ILoadOptionsFunctions): Promise { + const version = this.getCredentials('theHiveApi')?.apiVersion; + const options = [ + ...(version === 'v1') ? [{ name: 'Count', value: 'count', description: 'Count alerts' }] : [], { name: 'Create', value: 'create', description: 'Create alert' }, { name: 'Execute Responder', value: 'executeResponder', description: 'Execute a responder on the specified alert' }, { name: 'Get', value: 'get', description: 'Get an alert' }, @@ -222,10 +222,10 @@ export class TheHive implements INodeType { ]; return options; }, - async loadCaseOptions(this:ILoadOptionsFunctions):Promise{ + async loadCaseOptions(this: ILoadOptionsFunctions): Promise { const version = this.getCredentials('theHiveApi')?.apiVersion; - const options=[ - ...(version ==='v1')?[{ name: 'Count', value: 'count', description: 'Count a case' }]:[], + const options = [ + ...(version === 'v1') ? [{ name: 'Count', value: 'count', description: 'Count a case' }] : [], { name: 'Create', value: 'create', description: 'Create a case' }, { name: 'Execute Responder', value: 'executeResponder', description: 'Execute a responder on the specified case' }, { name: 'Get All', value: 'getAll', description: 'Get all cases' }, @@ -233,8 +233,8 @@ export class TheHive implements INodeType { { name: 'Update', value: 'update', description: 'Update a case' }, ]; return options; - } - } + }, + }, }; async execute(this: IExecuteFunctions): Promise { @@ -249,22 +249,22 @@ export class TheHive implements INodeType { for (let i = 0; i < length; i++) { if (resource === 'alert') { if (operation === 'count') { - const countQueryAttributs: any = prepareOptional(this.getNodeParameter('filters', i, {}) as INodeParameters); + const countQueryAttributs: any = prepareOptional(this.getNodeParameter('filters', i, {}) as INodeParameters); // tslint:disable-line:no-any const _countSearchQuery: IQueryObject = And(); for (const key of Object.keys(countQueryAttributs)) { - if ( key === 'tags') { + if (key === 'tags') { (_countSearchQuery['_and'] as IQueryObject[]).push( - In(key, countQueryAttributs[key] as string[]) + In(key, countQueryAttributs[key] as string[]), ); - } else if (key === 'description' || key === 'title' ) { + } else if (key === 'description' || key === 'title') { (_countSearchQuery['_and'] as IQueryObject[]).push( - ContainsString(key, countQueryAttributs[key] as string) + ContainsString(key, countQueryAttributs[key] as string), ); } else { (_countSearchQuery['_and'] as IQueryObject[]).push( - Eq(key, countQueryAttributs[key] as string) + Eq(key, countQueryAttributs[key] as string), ); } } @@ -276,20 +276,19 @@ export class TheHive implements INodeType { }, { '_name': 'filter', - '_and': _countSearchQuery['_and'] + '_and': _countSearchQuery['_and'], }, - ] + ], }; body['query'].push( { '_name': 'count', - } + }, ); qs.name = 'count-Alert'; - responseData = await theHiveApiRequest.call( this, 'POST', @@ -299,7 +298,6 @@ export class TheHive implements INodeType { ); responseData = { count: responseData }; - } if (operation === 'create') { @@ -315,10 +313,10 @@ export class TheHive implements INodeType { source: this.getNodeParameter('source', i), sourceRef: this.getNodeParameter('sourceRef', i), follow: this.getNodeParameter('follow', i, true), - ...prepareOptional(this.getNodeParameter('optionals', i, {}) as INodeParameters) + ...prepareOptional(this.getNodeParameter('optionals', i, {}) as INodeParameters), }; - const artifactUi = this.getNodeParameter('artifactUi', i)as IDataObject; + const artifactUi = this.getNodeParameter('artifactUi', i) as IDataObject; if (artifactUi) { @@ -378,16 +376,16 @@ export class TheHive implements INodeType { if it doesn't interfere with n8n standards then we should keep it */ - if (operation === 'executeResponder'){ + if (operation === 'executeResponder') { const alertId = this.getNodeParameter('id', i); const responderId = this.getNodeParameter('responder', i) as string; - let body:IDataObject; + let body: IDataObject; let response; responseData = []; body = { responderId, - objectId:alertId, - objectType: 'alert' + objectId: alertId, + objectType: 'alert', }; response = await theHiveApiRequest.call( this, @@ -398,26 +396,26 @@ export class TheHive implements INodeType { body = { query: [ { - '_name': 'listAction' + '_name': 'listAction', }, { '_name': 'filter', '_and': [ { '_field': 'cortexId', - '_value': response.cortexId + '_value': response.cortexId, }, { '_field': 'objectId', - '_value': response.objectId + '_value': response.objectId, }, { '_field': 'startDate', - '_value': response.startDate - } + '_value': response.startDate, + }, - ] - } + ], + }, ], }; qs.name = 'log-actions'; @@ -427,9 +425,9 @@ export class TheHive implements INodeType { 'POST', `/v1/query`, body, - qs + qs, ); - } while (response.status === 'Waiting' || response.status === 'InProgress' ); + } while (response.status === 'Waiting' || response.status === 'InProgress'); responseData = response; } @@ -452,24 +450,24 @@ export class TheHive implements INodeType { const version = credentials.apiVersion; - const queryAttributs: any = prepareOptional(this.getNodeParameter('filters', i, {}) as INodeParameters); + const queryAttributs: any = prepareOptional(this.getNodeParameter('filters', i, {}) as INodeParameters); // tslint:disable-line:no-any - const options = this.getNodeParameter('options', i) as IDataObject; + const options = this.getNodeParameter('options', i) as IDataObject; const _searchQuery: IQueryObject = And(); for (const key of Object.keys(queryAttributs)) { - if ( key === 'tags') { + if (key === 'tags') { (_searchQuery['_and'] as IQueryObject[]).push( - In(key, queryAttributs[key] as string[]) + In(key, queryAttributs[key] as string[]), ); - } else if (key === 'description' || key === 'title' ) { + } else if (key === 'description' || key === 'title') { (_searchQuery['_and'] as IQueryObject[]).push( - ContainsString(key, queryAttributs[key] as string) + ContainsString(key, queryAttributs[key] as string), ); } else { (_searchQuery['_and'] as IQueryObject[]).push( - Eq(key, queryAttributs[key] as string) + Eq(key, queryAttributs[key] as string), ); } } @@ -498,7 +496,7 @@ export class TheHive implements INodeType { }, { '_name': 'filter', - '_and': _searchQuery['_and'] + '_and': _searchQuery['_and'], }, ], }; @@ -631,32 +629,32 @@ export class TheHive implements INodeType { } } - if(resource === 'observable'){ - if(operation === 'count'){ - const countQueryAttributs: any = prepareOptional(this.getNodeParameter('filters', i, {}) as INodeParameters); + if (resource === 'observable') { + if (operation === 'count') { + const countQueryAttributs: any = prepareOptional(this.getNodeParameter('filters', i, {}) as INodeParameters); // tslint:disable-line:no-any const _countSearchQuery: IQueryObject = And(); for (const key of Object.keys(countQueryAttributs)) { if (key === 'dataType' || key === 'tags') { (_countSearchQuery['_and'] as IQueryObject[]).push( - In(key, countQueryAttributs[key] as string[]) + In(key, countQueryAttributs[key] as string[]), ); } else if (key === 'description' || key === 'keywork' || key === 'message') { (_countSearchQuery['_and'] as IQueryObject[]).push( - ContainsString(key, countQueryAttributs[key] as string) + ContainsString(key, countQueryAttributs[key] as string), ); } else if (key === 'range') { (_countSearchQuery['_and'] as IQueryObject[]).push( Between( 'startDate', countQueryAttributs['range']['dateRange']['fromDate'], - countQueryAttributs['range']['dateRange']['toDate'] - ) + countQueryAttributs['range']['dateRange']['toDate'], + ), ); } else { (_countSearchQuery['_and'] as IQueryObject[]).push( - Eq(key, countQueryAttributs[key] as string) + Eq(key, countQueryAttributs[key] as string), ); } } @@ -664,19 +662,19 @@ export class TheHive implements INodeType { const body = { 'query': [ { - '_name': 'listObservable' + '_name': 'listObservable', }, { '_name': 'filter', - '_and': _countSearchQuery['_and'] + '_and': _countSearchQuery['_and'], }, - ] + ], }; body['query'].push( { - '_name': 'count' - } + '_name': 'count', + }, ); qs.name = 'count-observables'; @@ -692,23 +690,23 @@ export class TheHive implements INodeType { responseData = { count: responseData }; } - if (operation === 'executeAnalyzer'){ + if (operation === 'executeAnalyzer') { const observableId = this.getNodeParameter('id', i); const analyzers = (this.getNodeParameter('analyzers', i) as string[]) .map(analyzer => { const parts = analyzer.split('::'); return { analyzerId: parts[0], - cortexId: parts[1] + cortexId: parts[1], }; }); - let response: any; + let response: any; // tslint:disable-line:no-any let body: IDataObject; responseData = []; for (const analyzer of analyzers) { body = { ...analyzer, - artifactId:observableId, + artifactId: observableId, }; // execute the analyzer response = await theHiveApiRequest.call( @@ -716,19 +714,19 @@ export class TheHive implements INodeType { 'POST', '/connector/cortex/job' as string, body, - qs + qs, ); const jobId = response.id; qs.name = 'observable-jobs'; // query the job result (including the report) do { - responseData = await theHiveApiRequest.call(this,'GET',`/connector/cortex/job/${jobId}`,body,qs); - } while (responseData.status === 'Waiting' || responseData.status === 'InProgress' ); + responseData = await theHiveApiRequest.call(this, 'GET', `/connector/cortex/job/${jobId}`, body, qs); + } while (responseData.status === 'Waiting' || responseData.status === 'InProgress'); } } - if (operation === 'executeResponder'){ + if (operation === 'executeResponder') { const observableId = this.getNodeParameter('id', i); const responderId = this.getNodeParameter('responder', i) as string; let body: IDataObject; @@ -736,8 +734,8 @@ export class TheHive implements INodeType { responseData = []; body = { responderId, - objectId:observableId, - objectType: 'case_artifact' + objectId: observableId, + objectType: 'case_artifact', }; response = await theHiveApiRequest.call( this, @@ -748,27 +746,27 @@ export class TheHive implements INodeType { body = { query: [ { - '_name': 'listAction' + '_name': 'listAction', }, { '_name': 'filter', '_and': [ { '_field': 'cortexId', - '_value': response.cortexId + '_value': response.cortexId, }, { '_field': 'objectId', - '_value': response.objectId + '_value': response.objectId, }, { '_field': 'startDate', - '_value': response.startDate - } + '_value': response.startDate, + }, - ] - } - ] + ], + }, + ], }; qs.name = 'log-actions'; do { @@ -777,14 +775,14 @@ export class TheHive implements INodeType { 'POST', `/v1/query`, body, - qs + qs, ); - } while (response.status === 'Waiting' || response.status === 'InProgress' ); + } while (response.status === 'Waiting' || response.status === 'InProgress'); responseData = response; } - if(operation === 'create'){ + if (operation === 'create') { const caseId = this.getNodeParameter('caseId', i); let body: IDataObject = { @@ -795,7 +793,7 @@ export class TheHive implements INodeType { ioc: this.getNodeParameter('ioc', i) as boolean, sighted: this.getNodeParameter('sighted', i) as boolean, status: this.getNodeParameter('status', i) as string, - ...prepareOptional(this.getNodeParameter('options', i, {}) as INodeParameters) + ...prepareOptional(this.getNodeParameter('options', i, {}) as INodeParameters), }; let options: IDataObject = {}; @@ -820,15 +818,15 @@ export class TheHive implements INodeType { attachment: { value: Buffer.from(binaryData.data, BINARY_ENCODING), options: { - contentType: binaryData.mimeType, + contentType: binaryData.mimeType, filename: binaryData.fileName, - } + }, }, - _json: JSON.stringify(body) - } + _json: JSON.stringify(body), + }, }; body = {}; - }else{ + } else { body.data = this.getNodeParameter('data', i) as string; } @@ -839,11 +837,11 @@ export class TheHive implements INodeType { body, qs, '', - options + options, ); } - if(operation === 'get'){ + if (operation === 'get') { const observableId = this.getNodeParameter('id', i) as string; const credentials = this.getCredentials('theHiveApi') as IDataObject; @@ -866,9 +864,9 @@ export class TheHive implements INodeType { 'query': [ { '_name': 'getObservable', - 'idOrName': observableId - } - ] + 'idOrName': observableId, + }, + ], }; qs.name = `get-observable-${observableId}`; @@ -890,14 +888,14 @@ export class TheHive implements INodeType { ); } - if(operation === 'getAll'){ + if (operation === 'getAll') { const credentials = this.getCredentials('theHiveApi') as IDataObject; const returnAll = this.getNodeParameter('returnAll', i) as boolean; const version = credentials.apiVersion; - const options = this.getNodeParameter('options', i) as IDataObject; + const options = this.getNodeParameter('options', i) as IDataObject; const caseId = this.getNodeParameter('caseId', i); @@ -914,8 +912,6 @@ export class TheHive implements INodeType { } if (version === 'v1') { - - endpoint = '/v1/query'; method = 'POST'; @@ -924,12 +920,12 @@ export class TheHive implements INodeType { 'query': [ { '_name': 'getCase', - 'idOrName': caseId + 'idOrName': caseId, }, { - '_name': 'observables' + '_name': 'observables', }, - ] + ], }; //@ts-ignore @@ -943,7 +939,6 @@ export class TheHive implements INodeType { qs.name = 'observables'; } else { - method = 'POST'; endpoint = '/case/artifact/_search'; @@ -952,7 +947,7 @@ export class TheHive implements INodeType { qs.range = `0-${limit}`; } - body.query = Parent('case', Id(caseId as string)); + body.query = Parent('case', Id(caseId as string)); Object.assign(qs, prepareOptional(options)); } @@ -966,39 +961,39 @@ export class TheHive implements INodeType { ); } - if(operation === 'search'){ + if (operation === 'search') { const credentials = this.getCredentials('theHiveApi') as IDataObject; const returnAll = this.getNodeParameter('returnAll', i) as boolean; const version = credentials.apiVersion; - const queryAttributs: any = prepareOptional(this.getNodeParameter('filters', i, {}) as INodeParameters); + const queryAttributs: any = prepareOptional(this.getNodeParameter('filters', i, {}) as INodeParameters); // tslint:disable-line:no-any const _searchQuery: IQueryObject = And(); - const options = this.getNodeParameter('options', i) as IDataObject; + const options = this.getNodeParameter('options', i) as IDataObject; for (const key of Object.keys(queryAttributs)) { if (key === 'dataType' || key === 'tags') { (_searchQuery['_and'] as IQueryObject[]).push( - In(key, queryAttributs[key] as string[]) + In(key, queryAttributs[key] as string[]), ); } else if (key === 'description' || key === 'keywork' || key === 'message') { (_searchQuery['_and'] as IQueryObject[]).push( - ContainsString(key, queryAttributs[key] as string) + ContainsString(key, queryAttributs[key] as string), ); } else if (key === 'range') { (_searchQuery['_and'] as IQueryObject[]).push( Between( 'startDate', queryAttributs['range']['dateRange']['fromDate'], - queryAttributs['range']['dateRange']['toDate'] - ) + queryAttributs['range']['dateRange']['toDate'], + ), ); } else { (_searchQuery['_and'] as IQueryObject[]).push( - Eq(key, queryAttributs[key] as string) + Eq(key, queryAttributs[key] as string), ); } } @@ -1016,7 +1011,6 @@ export class TheHive implements INodeType { } if (version === 'v1') { - endpoint = '/v1/query'; method = 'POST'; @@ -1024,13 +1018,13 @@ export class TheHive implements INodeType { body = { 'query': [ { - '_name': 'listObservable' + '_name': 'listObservable', }, { '_name': 'filter', - '_and': _searchQuery['_and'] + '_and': _searchQuery['_and'], }, - ] + ], }; //@ts-ignore @@ -1044,7 +1038,6 @@ export class TheHive implements INodeType { qs.name = 'observables'; } else { - method = 'POST'; endpoint = '/case/artifact/_search'; @@ -1068,11 +1061,11 @@ export class TheHive implements INodeType { ); } - if(operation === 'update'){ + if (operation === 'update') { const id = this.getNodeParameter('id', i) as string; const body: IDataObject = { - ...prepareOptional(this.getNodeParameter('updateFields', i, {}) as INodeParameters) + ...prepareOptional(this.getNodeParameter('updateFields', i, {}) as INodeParameters), }; responseData = await theHiveApiRequest.call( @@ -1087,24 +1080,24 @@ export class TheHive implements INodeType { } } - if (resource === 'case'){ - if(operation === 'count'){ - const countQueryAttributs: any = prepareOptional(this.getNodeParameter('filters', i, {}) as INodeParameters); + if (resource === 'case') { + if (operation === 'count') { + const countQueryAttributs: any = prepareOptional(this.getNodeParameter('filters', i, {}) as INodeParameters); // tslint:disable-line:no-any const _countSearchQuery: IQueryObject = And(); for (const key of Object.keys(countQueryAttributs)) { - if ( key === 'tags') { + if (key === 'tags') { (_countSearchQuery['_and'] as IQueryObject[]).push( - In(key, countQueryAttributs[key] as string[]) + In(key, countQueryAttributs[key] as string[]), ); } else if (key === 'description' || key === 'summary' || key === 'title') { (_countSearchQuery['_and'] as IQueryObject[]).push( - ContainsString(key, countQueryAttributs[key] as string) + ContainsString(key, countQueryAttributs[key] as string), ); } else { (_countSearchQuery['_and'] as IQueryObject[]).push( - Eq(key, countQueryAttributs[key] as string) + Eq(key, countQueryAttributs[key] as string), ); } } @@ -1116,15 +1109,15 @@ export class TheHive implements INodeType { }, { '_name': 'filter', - '_and': _countSearchQuery['_and'] + '_and': _countSearchQuery['_and'], }, - ] + ], }; body['query'].push( { '_name': 'count', - } + }, ); qs.name = 'count-cases'; @@ -1141,7 +1134,7 @@ export class TheHive implements INodeType { responseData = { count: responseData }; } - if (operation === 'executeResponder'){ + if (operation === 'executeResponder') { const caseId = this.getNodeParameter('id', i); const responderId = this.getNodeParameter('responder', i) as string; let body: IDataObject; @@ -1149,8 +1142,8 @@ export class TheHive implements INodeType { responseData = []; body = { responderId, - objectId:caseId, - objectType: 'case' + objectId: caseId, + objectType: 'case', }; response = await theHiveApiRequest.call( this, @@ -1161,27 +1154,27 @@ export class TheHive implements INodeType { body = { query: [ { - '_name': 'listAction' + '_name': 'listAction', }, { '_name': 'filter', '_and': [ { '_field': 'cortexId', - '_value': response.cortexId + '_value': response.cortexId, }, { '_field': 'objectId', - '_value': response.objectId + '_value': response.objectId, }, { '_field': 'startDate', - '_value': response.startDate - } + '_value': response.startDate, + }, - ] - } - ] + ], + }, + ], }; qs.name = 'log-actions'; do { @@ -1190,14 +1183,14 @@ export class TheHive implements INodeType { 'POST', `/v1/query`, body, - qs + qs, ); - } while (response.status === 'Waiting' || response.status === 'InProgress' ); + } while (response.status === 'Waiting' || response.status === 'InProgress'); responseData = response; } - if(operation === 'create'){ + if (operation === 'create') { const body: IDataObject = { title: this.getNodeParameter('title', i), @@ -1208,7 +1201,7 @@ export class TheHive implements INodeType { flag: this.getNodeParameter('flag', i), tlp: this.getNodeParameter('tlp', i), tags: splitTags(this.getNodeParameter('tags', i) as string), - ...prepareOptional(this.getNodeParameter('options', i, {}) as INodeParameters) + ...prepareOptional(this.getNodeParameter('options', i, {}) as INodeParameters), }; responseData = await theHiveApiRequest.call( @@ -1219,7 +1212,7 @@ export class TheHive implements INodeType { ); } - if(operation === 'get'){ + if (operation === 'get') { const caseId = this.getNodeParameter('id', i) as string; const credentials = this.getCredentials('theHiveApi') as IDataObject; @@ -1242,9 +1235,9 @@ export class TheHive implements INodeType { 'query': [ { '_name': 'getCase', - 'idOrName': caseId - } - ] + 'idOrName': caseId, + }, + ], }; qs.name = `get-case-${caseId}`; @@ -1266,31 +1259,31 @@ export class TheHive implements INodeType { ); } - if(operation === 'getAll'){ + if (operation === 'getAll') { const credentials = this.getCredentials('theHiveApi') as IDataObject; const returnAll = this.getNodeParameter('returnAll', i) as boolean; const version = credentials.apiVersion; - const queryAttributs: any = prepareOptional(this.getNodeParameter('filters', i, {}) as INodeParameters); + const queryAttributs: any = prepareOptional(this.getNodeParameter('filters', i, {}) as INodeParameters); // tslint:disable-line:no-any const _searchQuery: IQueryObject = And(); - const options = this.getNodeParameter('options', i) as IDataObject; + const options = this.getNodeParameter('options', i) as IDataObject; for (const key of Object.keys(queryAttributs)) { - if ( key === 'tags') { + if (key === 'tags') { (_searchQuery['_and'] as IQueryObject[]).push( - In(key, queryAttributs[key] as string[]) + In(key, queryAttributs[key] as string[]), ); } else if (key === 'description' || key === 'summary' || key === 'title') { (_searchQuery['_and'] as IQueryObject[]).push( - ContainsString(key, queryAttributs[key] as string) + ContainsString(key, queryAttributs[key] as string), ); } else { (_searchQuery['_and'] as IQueryObject[]).push( - Eq(key, queryAttributs[key] as string) + Eq(key, queryAttributs[key] as string), ); } } @@ -1315,13 +1308,13 @@ export class TheHive implements INodeType { body = { 'query': [ { - '_name': 'listCase' + '_name': 'listCase', }, { '_name': 'filter', - '_and': _searchQuery['_and'] + '_and': _searchQuery['_and'], }, - ] + ], }; //@ts-ignore @@ -1357,11 +1350,11 @@ export class TheHive implements INodeType { ); } - if(operation === 'update'){ + if (operation === 'update') { const id = this.getNodeParameter('id', i) as string; const body: IDataObject = { - ...prepareOptional(this.getNodeParameter('updateFields', i, {}) as INodeParameters) + ...prepareOptional(this.getNodeParameter('updateFields', i, {}) as INodeParameters), }; responseData = await theHiveApiRequest.call( @@ -1373,20 +1366,20 @@ export class TheHive implements INodeType { } } - if (resource === 'task'){ - if (operation === 'count'){ - const countQueryAttributs: any = prepareOptional(this.getNodeParameter('filters', i, {}) as INodeParameters); + if (resource === 'task') { + if (operation === 'count') { + const countQueryAttributs: any = prepareOptional(this.getNodeParameter('filters', i, {}) as INodeParameters); // tslint:disable-line:no-any const _countSearchQuery: IQueryObject = And(); for (const key of Object.keys(countQueryAttributs)) { if (key === 'title' || key === 'description') { (_countSearchQuery['_and'] as IQueryObject[]).push( - ContainsString(key, countQueryAttributs[key] as string) + ContainsString(key, countQueryAttributs[key] as string), ); } else { (_countSearchQuery['_and'] as IQueryObject[]).push( - Eq(key, countQueryAttributs[key] as string) + Eq(key, countQueryAttributs[key] as string), ); } } @@ -1394,19 +1387,19 @@ export class TheHive implements INodeType { const body = { 'query': [ { - '_name': 'listTask' + '_name': 'listTask', }, { '_name': 'filter', - '_and': _countSearchQuery['_and'] + '_and': _countSearchQuery['_and'], }, - ] + ], }; body['query'].push( { '_name': 'count', - } + }, ); qs.name = 'count-tasks'; @@ -1422,14 +1415,14 @@ export class TheHive implements INodeType { responseData = { count: responseData }; } - if (operation === 'create'){ + if (operation === 'create') { const caseId = this.getNodeParameter('caseId', i) as string; const body: IDataObject = { title: this.getNodeParameter('title', i) as string, status: this.getNodeParameter('status', i) as string, flag: this.getNodeParameter('flag', i), - ...prepareOptional(this.getNodeParameter('options', i, {}) as INodeParameters) + ...prepareOptional(this.getNodeParameter('options', i, {}) as INodeParameters), }; responseData = await theHiveApiRequest.call( @@ -1440,63 +1433,63 @@ export class TheHive implements INodeType { ); } - if (operation === 'executeResponder'){ + if (operation === 'executeResponder') { const taskId = this.getNodeParameter('id', i); const responderId = this.getNodeParameter('responder', i) as string; - let body:IDataObject; + let body: IDataObject; let response; responseData = []; - body = { - responderId, - objectId: taskId, - objectType: 'case_task' - }; + body = { + responderId, + objectId: taskId, + objectType: 'case_task', + }; + response = await theHiveApiRequest.call( + this, + 'POST', + '/connector/cortex/action' as string, + body, + ); + body = { + query: [ + { + '_name': 'listAction', + }, + { + '_name': 'filter', + '_and': [ + { + '_field': 'cortexId', + '_value': response.cortexId, + }, + { + '_field': 'objectId', + '_value': response.objectId, + }, + { + '_field': 'startDate', + '_value': response.startDate, + }, + + ], + }, + ], + }; + qs.name = 'task-actions'; + do { response = await theHiveApiRequest.call( this, 'POST', - '/connector/cortex/action' as string, + `/v1/query`, body, + qs, ); - body = { - query: [ - { - '_name': 'listAction' - }, - { - '_name': 'filter', - '_and': [ - { - '_field': 'cortexId', - '_value': response.cortexId - }, - { - '_field': 'objectId', - '_value': response.objectId - }, - { - '_field': 'startDate', - '_value': response.startDate - } + } while (response.status === 'Waiting' || response.status === 'InProgress'); - ] - } - ], - }; - qs.name = 'task-actions'; - do { - response = await theHiveApiRequest.call( - this, - 'POST', - `/v1/query`, - body, - qs - ); - } while (response.status === 'Waiting' || response.status === 'InProgress' ); - - responseData = response; + responseData = response; } - if (operation === 'get'){ + if (operation === 'get') { const taskId = this.getNodeParameter('id', i) as string; const credentials = this.getCredentials('theHiveApi') as IDataObject; @@ -1518,9 +1511,9 @@ export class TheHive implements INodeType { 'query': [ { '_name': 'getTask', - 'idOrName': taskId - } - ] + 'idOrName': taskId, + }, + ], }; qs.name = `get-task-${taskId}`; @@ -1541,7 +1534,7 @@ export class TheHive implements INodeType { ); } - if(operation === 'getAll'){ + if (operation === 'getAll') { // get all require a case id (it retursn all tasks for a specific case) const credentials = this.getCredentials('theHiveApi') as IDataObject; @@ -1551,7 +1544,7 @@ export class TheHive implements INodeType { const caseId = this.getNodeParameter('caseId', i) as string; - const options = this.getNodeParameter('options', i) as IDataObject; + const options = this.getNodeParameter('options', i) as IDataObject; let endpoint; @@ -1574,12 +1567,12 @@ export class TheHive implements INodeType { 'query': [ { '_name': 'getCase', - 'idOrName': caseId + 'idOrName': caseId, }, { - '_name': 'tasks' + '_name': 'tasks', }, - ] + ], }; //@ts-ignore @@ -1617,27 +1610,27 @@ export class TheHive implements INodeType { ); } - if(operation === 'search'){ + if (operation === 'search') { const credentials = this.getCredentials('theHiveApi') as IDataObject; const returnAll = this.getNodeParameter('returnAll', i) as boolean; const version = credentials.apiVersion; - const queryAttributs: any = prepareOptional(this.getNodeParameter('filters', i, {}) as INodeParameters); + const queryAttributs: any = prepareOptional(this.getNodeParameter('filters', i, {}) as INodeParameters); // tslint:disable-line:no-any const _searchQuery: IQueryObject = And(); - const options = this.getNodeParameter('options', i) as IDataObject; + const options = this.getNodeParameter('options', i) as IDataObject; for (const key of Object.keys(queryAttributs)) { if (key === 'title' || key === 'description') { (_searchQuery['_and'] as IQueryObject[]).push( - ContainsString(key, queryAttributs[key] as string) + ContainsString(key, queryAttributs[key] as string), ); } else { (_searchQuery['_and'] as IQueryObject[]).push( - Eq(key, queryAttributs[key] as string) + Eq(key, queryAttributs[key] as string), ); } } @@ -1662,13 +1655,13 @@ export class TheHive implements INodeType { body = { 'query': [ { - '_name': 'listTask' + '_name': 'listTask', }, { '_name': 'filter', - '_and': _searchQuery['_and'] + '_and': _searchQuery['_and'], }, - ] + ], }; //@ts-ignore @@ -1705,11 +1698,11 @@ export class TheHive implements INodeType { ); } - if(operation === 'update'){ + if (operation === 'update') { const id = this.getNodeParameter('id', i) as string; const body: IDataObject = { - ...prepareOptional(this.getNodeParameter('updateFields', i, {}) as INodeParameters) + ...prepareOptional(this.getNodeParameter('updateFields', i, {}) as INodeParameters), }; responseData = await theHiveApiRequest.call( @@ -1718,15 +1711,13 @@ export class TheHive implements INodeType { `/case/task/${id}` as string, body, ); - } - } - if (resource === 'log'){ + if (resource === 'log') { if (operation === 'create') { - const taskId = this.getNodeParameter('taskId', i) as string; + const taskId = this.getNodeParameter('taskId', i) as string; let body: IDataObject = { message: this.getNodeParameter('message', i), @@ -1735,7 +1726,7 @@ export class TheHive implements INodeType { }; const optionals = this.getNodeParameter('options', i) as IDataObject; - let options: IDataObject ={}; + let options: IDataObject = {}; if (optionals.attachementUi) { const attachmentValues = (optionals.attachementUi as IDataObject).attachmentValues as IDataObject; @@ -1760,12 +1751,12 @@ export class TheHive implements INodeType { attachment: { value: Buffer.from(binaryData.data, BINARY_ENCODING), options: { - contentType: binaryData.mimeType, + contentType: binaryData.mimeType, filename: binaryData.fileName, - } + }, }, - _json: JSON.stringify(body) - } + _json: JSON.stringify(body), + }, }; body = {}; @@ -1779,20 +1770,20 @@ export class TheHive implements INodeType { body, qs, '', - options + options, ); } - if (operation === 'executeResponder'){ + if (operation === 'executeResponder') { const logId = this.getNodeParameter('id', i); const responderId = this.getNodeParameter('responder', i) as string; - let body:IDataObject; + let body: IDataObject; let response; responseData = []; body = { responderId, - objectId:logId, - objectType: 'case_task_log' + objectId: logId, + objectType: 'case_task_log', }; response = await theHiveApiRequest.call( this, @@ -1803,27 +1794,27 @@ export class TheHive implements INodeType { body = { query: [ { - '_name': 'listAction' + '_name': 'listAction', }, { '_name': 'filter', '_and': [ { '_field': 'cortexId', - '_value': response.cortexId + '_value': response.cortexId, }, { '_field': 'objectId', - '_value': response.objectId + '_value': response.objectId, }, { '_field': 'startDate', - '_value': response.startDate - } + '_value': response.startDate, + }, - ] - } - ] + ], + }, + ], }; qs.name = 'log-actions'; do { @@ -1832,9 +1823,9 @@ export class TheHive implements INodeType { 'POST', `/v1/query`, body, - qs + qs, ); - } while (response.status ==='Waiting' || response.status === 'InProgress' ); + } while (response.status === 'Waiting' || response.status === 'InProgress'); responseData = response; } @@ -1862,21 +1853,18 @@ export class TheHive implements INodeType { query: [ { _name: 'getLog', - idOrName: logId - } - ] + idOrName: logId, + }, + ], }; qs.name = `get-log-${logId}`; - } else { - method = 'POST'; endpoint = '/case/task/log/_search'; body.query = { _id: logId }; - } responseData = await theHiveApiRequest.call( @@ -1888,15 +1876,14 @@ export class TheHive implements INodeType { ); } - if (operation === 'getAll'){ - + if (operation === 'getAll') { const credentials = this.getCredentials('theHiveApi') as IDataObject; const returnAll = this.getNodeParameter('returnAll', i) as boolean; const version = credentials.apiVersion; - const taskId = this.getNodeParameter('taskId', i) as string; + const taskId = this.getNodeParameter('taskId', i) as string; let endpoint; @@ -1919,12 +1906,12 @@ export class TheHive implements INodeType { 'query': [ { '_name': 'getTask', - 'idOrName': taskId + 'idOrName': taskId, }, { - '_name': 'logs' + '_name': 'logs', }, - ] + ], }; if (limit !== undefined) { @@ -1945,7 +1932,7 @@ export class TheHive implements INodeType { body.query = And(Parent( 'task', - Id(taskId) + Id(taskId), )); } diff --git a/packages/nodes-base/nodes/TheHive/TheHiveTrigger.node.ts b/packages/nodes-base/nodes/TheHive/TheHiveTrigger.node.ts index 968e9ef2b8..8eec6b6cc2 100644 --- a/packages/nodes-base/nodes/TheHive/TheHiveTrigger.node.ts +++ b/packages/nodes-base/nodes/TheHive/TheHiveTrigger.node.ts @@ -4,10 +4,10 @@ import { import { IDataObject, - INodeTypeDescription, - INodeType, - IWebhookResponseData, IHookFunctions, + INodeType, + INodeTypeDescription, + IWebhookResponseData, } from 'n8n-workflow'; export class TheHiveTrigger implements INodeType { @@ -111,9 +111,9 @@ export class TheHiveTrigger implements INodeType { value: 'case_task_log_create', description: 'Triggered when a task log is created', }, - ] - } - ] + ], + }, + ], }; // @ts-ignore (because of request) webhookMethods = { @@ -134,14 +134,14 @@ export class TheHiveTrigger implements INodeType { // Get the request body const bodyData = this.getBodyData(); const events = this.getNodeParameter('events', []) as string[]; - if(!bodyData.operation || !bodyData.objectType) { + if (!bodyData.operation || !bodyData.objectType) { // Don't start the workflow if mandatory fields are not specified return {}; } // Don't start the workflow if the event is not fired const event = `${(bodyData.objectType as string).toLowerCase()}_${(bodyData.operation as string).toLowerCase()}`; - if(events.indexOf('*') === -1 && events.indexOf(event) === -1) { + if (events.indexOf('*') === -1 && events.indexOf(event) === -1) { return {}; } @@ -158,7 +158,7 @@ export class TheHiveTrigger implements INodeType { return { workflowData: [ - this.helpers.returnJsonArray(returnData) + this.helpers.returnJsonArray(returnData), ], }; } diff --git a/packages/nodes-base/nodes/TheHive/descriptions/AlertDescription.ts b/packages/nodes-base/nodes/TheHive/descriptions/AlertDescription.ts index 21c50f893d..77ff3336c0 100644 --- a/packages/nodes-base/nodes/TheHive/descriptions/AlertDescription.ts +++ b/packages/nodes-base/nodes/TheHive/descriptions/AlertDescription.ts @@ -78,7 +78,7 @@ export const alertFields = [ displayOptions: { show: { resource: [ - 'alert' + 'alert', ], operation: [ 'promote', @@ -89,7 +89,7 @@ export const alertFields = [ ], }, }, - description: 'Title of the alert' + description: 'Title of the alert', }, { displayName: 'Case ID', @@ -148,14 +148,14 @@ export const alertFields = [ displayName: 'Severity', name: 'severity', type: 'options', - options:[ + options: [ { name: 'Low', - value: 1 + value: 1, }, { name: 'Medium', - value: 2 + value: 2, }, { name: 'High', @@ -192,7 +192,7 @@ export const alertFields = [ ], }, }, - description: 'Date and time when the alert was raised default=now' + description: 'Date and time when the alert was raised default=now', }, { displayName: 'Tags', @@ -200,7 +200,7 @@ export const alertFields = [ type: 'string', required: true, default: '', - placeholder:'tag,tag2,tag3...', + placeholder: 'tag,tag2,tag3...', displayOptions: { show: { resource: [ @@ -211,7 +211,7 @@ export const alertFields = [ ], }, }, - description: 'Case Tags' + description: 'Case Tags', }, { displayName: 'TLP', @@ -221,20 +221,20 @@ export const alertFields = [ default: 2, options: [ { - name:'White', - value:TLP.white, + name: 'White', + value: TLP.white, }, { - name:'Green', - value:TLP.green, + name: 'Green', + value: TLP.green, }, { - name:'Amber', - value:TLP.amber, - },{ - name:'Red', - value:TLP.red, - } + name: 'Amber', + value: TLP.amber, + }, { + name: 'Red', + value: TLP.red, + }, ], displayOptions: { show: { @@ -246,14 +246,14 @@ export const alertFields = [ ], }, }, - description: 'Traffict Light Protocol (TLP). Default=Amber' + description: 'Traffict Light Protocol (TLP). Default=Amber', }, { displayName: 'Status', name: 'status', type: 'options', required: true, - options:[ + options: [ { name: 'New', value: 'New', @@ -264,7 +264,7 @@ export const alertFields = [ }, { name: 'Ignored', - value: 'Ignored' + value: 'Ignored', }, { name: 'Imported', @@ -300,7 +300,7 @@ export const alertFields = [ ], }, }, - description: 'Type of the alert' + description: 'Type of the alert', }, { displayName: 'Source', @@ -318,7 +318,7 @@ export const alertFields = [ ], }, }, - description: 'Source of the alert' + description: 'Source of the alert', }, { displayName: 'SourceRef', @@ -336,7 +336,7 @@ export const alertFields = [ ], }, }, - description: 'Source reference of the alert' + description: 'Source reference of the alert', }, { displayName: 'Follow', @@ -446,7 +446,7 @@ export const alertFields = [ ], }, ], - description: 'Artifact attributes' + description: 'Artifact attributes', }, // required for responder execution { @@ -461,7 +461,7 @@ export const alertFields = [ ], loadOptionsMethod: 'loadResponders', }, - displayOptions:{ + displayOptions: { show: { resource: [ 'alert', @@ -496,13 +496,13 @@ export const alertFields = [ ], }, }, - options:[ + options: [ { displayName: 'Case Template', name: 'caseTemplate', - type:'string', + type: 'string', default: '', - description: `Case template to use when a case is created from this alert`, + description: `Case template to use when a case is created from this alert.`, }, ], }, @@ -557,7 +557,6 @@ export const alertFields = [ value: 'file', }, ], - description: '', }, { displayName: 'Data', @@ -571,7 +570,6 @@ export const alertFields = [ }, }, default: '', - description: '', }, { displayName: 'Binary Property', @@ -585,21 +583,18 @@ export const alertFields = [ }, }, default: 'data', - description: '', }, { displayName: 'Message', name: 'message', type: 'string', default: '', - description: '', }, { displayName: 'Case Tags', name: 'tags', type: 'string', default: '', - description: '', }, ], }, @@ -611,7 +606,7 @@ export const alertFields = [ type: 'string', required: false, default: '', - description: `Case template to use when a case is created from this alert`, + description: `Case template to use when a case is created from this alert.`, }, { displayName: 'Description', @@ -619,20 +614,20 @@ export const alertFields = [ type: 'string', required: false, default: '', - description: 'Description of the alert', + description: 'Description of the alert.', }, { displayName: 'Follow', name: 'follow', type: 'boolean', default: true, - description: 'if true, the alert becomes active when updated default=true', + description: 'if true, the alert becomes active when updated default=true.', }, { displayName: 'Severity', name: ' severity', type: 'options', - options:[ + options: [ { name: 'Low', value: 1, @@ -653,22 +648,22 @@ export const alertFields = [ displayName: 'Status', name: 'status', type: 'options', - options:[ + options: [ { name: 'New', value: 'New', }, { - name:'Updated', - value:'Updated', + name: 'Updated', + value: 'Updated', }, { name: 'Ignored', - value:'Ignored', + value: 'Ignored', }, { - name:'Imported', - value:'Imported', + name: 'Imported', + value: 'Imported', }, ], default: 'New', @@ -678,7 +673,7 @@ export const alertFields = [ name: 'tags', type: 'string', default: '', - placeholder:'tag,tag2,tag3...', + placeholder: 'tag,tag2,tag3...', }, { displayName: 'Title', @@ -686,7 +681,7 @@ export const alertFields = [ type: 'string', required: false, default: '', - description: 'Title of the alert' + description: 'Title of the alert.', }, { displayName: 'TLP', @@ -712,7 +707,7 @@ export const alertFields = [ value: TLP.red, }, ], - description: 'Traffict Light Protocol (TLP). Default=Amber' + description: 'Traffict Light Protocol (TLP). Default=Amber', }, ], }, @@ -752,7 +747,7 @@ export const alertFields = [ displayOptions: { show: { resource: [ - 'alert' + 'alert', ], operation: [ 'getAll', @@ -760,13 +755,13 @@ export const alertFields = [ ], }, }, - options:[ + options: [ { displayName: 'Description', name: 'description', type: 'string', default: '', - description: 'Description of the alert', + description: 'Description of the alert.', }, { displayName: 'Follow', @@ -782,15 +777,15 @@ export const alertFields = [ options: [ { name: 'Low', - value: 1 + value: 1, }, { name: 'Medium', - value: 2 + value: 2, }, { name: 'High', - value: 3 + value: 3, }, ], default: 2, @@ -816,24 +811,24 @@ export const alertFields = [ default: 2, options: [ { - name:'White', - value:TLP.white, + name: 'White', + value: TLP.white, }, { - name:'Green', - value:TLP.green, + name: 'Green', + value: TLP.green, }, { - name:'Amber', - value:TLP.amber, + name: 'Amber', + value: TLP.amber, }, { - name:'Red', - value:TLP.red, - } + name: 'Red', + value: TLP.red, + }, ], - description: 'Traffict Light Protocol (TLP). Default=Amber' + description: 'Traffict Light Protocol (TLP). Default=Amber', }, ], - } -] as INodeProperties[]; + }, +] as INodeProperties[]; diff --git a/packages/nodes-base/nodes/TheHive/descriptions/CaseDescription.ts b/packages/nodes-base/nodes/TheHive/descriptions/CaseDescription.ts index 6e78d07ef6..4ce4c5f051 100644 --- a/packages/nodes-base/nodes/TheHive/descriptions/CaseDescription.ts +++ b/packages/nodes-base/nodes/TheHive/descriptions/CaseDescription.ts @@ -247,7 +247,7 @@ export const caseFields = [ ], }, }, - description: 'Traffict Light Protocol (TLP). Default=Amber' + description: 'Traffict Light Protocol (TLP). Default=Amber', }, { displayName: 'Tags', @@ -385,15 +385,15 @@ export const caseFields = [ options: [ { name: 'No Impact', - value: 'NoImpact' + value: 'NoImpact', }, { name: 'With Impact', - value: 'WithImpact' + value: 'WithImpact', }, { name: 'Not Applicable', - value: 'NotApplicable' + value: 'NotApplicable', }, ], description: 'Impact status of the case', @@ -419,23 +419,23 @@ export const caseFields = [ options: [ { value: 'Indeterminate', - name: 'Indeterminate' + name: 'Indeterminate', }, { value: 'False Positive', - name: 'FalsePositive' + name: 'FalsePositive', }, { value: 'True Positive', - name: 'TruePositive' + name: 'TruePositive', }, { value: 'Other', - name: 'Other' + name: 'Other', }, { value: 'Duplicated', - name: 'Duplicated' + name: 'Duplicated', }, ], description: 'Resolution status of the case', @@ -447,15 +447,15 @@ export const caseFields = [ options: [ { name: 'Low', - value: 1 + value: 1, }, { name: 'Medium', - value: 2 + value: 2, }, { name: 'High', - value: 3 + value: 3, }, ], default: 2, @@ -493,7 +493,7 @@ export const caseFields = [ name: 'summary', type: 'string', default: '', - description: 'Summary of the case, to be provided when closing a case' + description: 'Summary of the case, to be provided when closing a case', }, { displayName: 'Tags', @@ -531,7 +531,7 @@ export const caseFields = [ value: TLP.red, }, ], - description: 'Traffict Light Protocol (TLP). Default=Amber' + description: 'Traffict Light Protocol (TLP). Default=Amber', }, ], }, @@ -574,7 +574,7 @@ export const caseFields = [ displayOptions: { show: { resource: [ - 'case' + 'case', ], operation: [ 'getAll', @@ -665,15 +665,15 @@ export const caseFields = [ options: [ { name: 'Low', - value: 1 + value: 1, }, { name: 'Medium', - value: 2 + value: 2, }, { name: 'High', - value: 3 + value: 3, }, ], default: 2, diff --git a/packages/nodes-base/nodes/TheHive/descriptions/LogDescription.ts b/packages/nodes-base/nodes/TheHive/descriptions/LogDescription.ts index 73691719b8..7062739ffb 100644 --- a/packages/nodes-base/nodes/TheHive/descriptions/LogDescription.ts +++ b/packages/nodes-base/nodes/TheHive/descriptions/LogDescription.ts @@ -25,12 +25,12 @@ export const logOperations = [ { name: 'Execute Responder', value: 'executeResponder', - description: 'Execute a responder on a selected log' + description: 'Execute a responder on a selected log', }, { name: 'Get All', value: 'getAll', - description: 'Get all task logs' + description: 'Get all task logs', }, { name: 'Get', @@ -38,7 +38,7 @@ export const logOperations = [ description: 'Get a single log', }, ], - } + }, ] as INodeProperties[]; export const logFields = [ @@ -195,7 +195,7 @@ export const logFields = [ loadOptionsDependsOn: [ 'id', ], - loadOptionsMethod: 'loadResponders' + loadOptionsMethod: 'loadResponders', }, displayOptions: { show: { @@ -258,5 +258,5 @@ export const logFields = [ description: 'File attached to the log', }, ], - } + }, ] as INodeProperties[]; diff --git a/packages/nodes-base/nodes/TheHive/descriptions/ObservableDescription.ts b/packages/nodes-base/nodes/TheHive/descriptions/ObservableDescription.ts index 36e814db7b..12aa6e9478 100644 --- a/packages/nodes-base/nodes/TheHive/descriptions/ObservableDescription.ts +++ b/packages/nodes-base/nodes/TheHive/descriptions/ObservableDescription.ts @@ -127,55 +127,55 @@ export const observableFields = [ }, { name: 'file', - value: 'file' + value: 'file', }, { name: 'filename', - value: 'filename' + value: 'filename', }, { name: 'fqdn', - value: 'fqdn' + value: 'fqdn', }, { name: 'hash', - value: 'hash' + value: 'hash', }, { name: 'ip', - value: 'ip' + value: 'ip', }, { name: 'mail', - value: 'mail' + value: 'mail', }, { name: 'mail_subject', - value: 'mail_subject' + value: 'mail_subject', }, { name: 'other', - value: 'other' + value: 'other', }, { name: 'regexp', - value: 'regexp' + value: 'regexp', }, { name: 'registry', - value: 'registry' + value: 'registry', }, { name: 'uri_path', - value: 'uri_path' + value: 'uri_path', }, { name: 'url', - value: 'url' + value: 'url', }, { name: 'user-agent', - value: 'user-agent' + value: 'user-agent', }, ], displayOptions: { @@ -243,7 +243,7 @@ export const observableFields = [ displayOptions: { show: { resource: [ - 'observable' + 'observable', ], operation: [ 'create', @@ -607,59 +607,59 @@ export const observableFields = [ options: [ { name: 'domain', - value: 'domain' + value: 'domain', }, { name: 'file', - value: 'file' + value: 'file', }, { name: 'filename', - value: 'filename' + value: 'filename', }, { name: 'fqdn', - value: 'fqdn' + value: 'fqdn', }, { name: 'hash', - value: 'hash' + value: 'hash', }, { name: 'ip', - value: 'ip' + value: 'ip', }, { name: 'mail', - value: 'mail' + value: 'mail', }, { name: 'mail_subject', - value: 'mail_subject' + value: 'mail_subject', }, { name: 'other', - value: 'other' + value: 'other', }, { name: 'regexp', - value: 'regexp' + value: 'regexp', }, { name: 'registry', - value: 'registry' + value: 'registry', }, { name: 'uri_path', - value: 'uri_path' + value: 'uri_path', }, { name: 'url', - value: 'url' + value: 'url', }, { name: 'user-agent', - value: 'user-agent' + value: 'user-agent', }, ], description: 'Type of the observable', diff --git a/packages/nodes-base/nodes/TheHive/descriptions/TaskDescription.ts b/packages/nodes-base/nodes/TheHive/descriptions/TaskDescription.ts index fad2f04e13..bcee27ae02 100644 --- a/packages/nodes-base/nodes/TheHive/descriptions/TaskDescription.ts +++ b/packages/nodes-base/nodes/TheHive/descriptions/TaskDescription.ts @@ -132,20 +132,20 @@ export const taskFields = [ default: 'Waiting', options: [ { - name: 'Waiting', - value: 'Waiting', - }, - { - name: 'InProgress', - value: 'InProgress', + name: 'Cancel', + value: 'Cancel', }, { name: 'Completed', value: 'Completed', }, { - name: 'Cancel', - value: 'Cancel', + name: 'InProgress', + value: 'InProgress', + }, + { + name: 'Waiting', + value: 'Waiting', }, ], required: true, @@ -313,26 +313,26 @@ export const taskFields = [ description: 'Date of the beginning of the task. This is automatically set when status is set to Open', }, { - displayName: 'status', + displayName: 'Status', name: 'status', type: 'options', default: 'Waiting', options: [ { - name: 'Waiting', - value: 'Waiting', - }, - { - name: 'In Progress', - value: 'InProgress', + name: 'Cancel', + value: 'Cancel', }, { name: 'Completed', value: 'Completed', }, { - name: 'Cancel', - value: 'Cancel', + name: 'In Progress', + value: 'InProgress', + }, + { + name: 'Waiting', + value: 'Waiting', }, ], description: 'Status of the task. Default=Waiting', @@ -438,20 +438,20 @@ export const taskFields = [ default: 'Waiting', options: [ { - name: 'Waiting', - value: 'Waiting', - }, - { - name: 'In Progress', - value: 'InProgress' + name: 'Cancel', + value: 'Cancel', }, { name: 'Completed', - value: 'Completed' + value: 'Completed', }, { - name: 'Cancel', - value: 'Cancel' + name: 'In Progress', + value: 'InProgress', + }, + { + name: 'Waiting', + value: 'Waiting', }, ], description: 'Status of the task. Default=Waiting', diff --git a/packages/nodes-base/nodes/TheHive/interfaces/AlertInterface.ts b/packages/nodes-base/nodes/TheHive/interfaces/AlertInterface.ts index 873d5bf927..8b3b9ec714 100644 --- a/packages/nodes-base/nodes/TheHive/interfaces/AlertInterface.ts +++ b/packages/nodes-base/nodes/TheHive/interfaces/AlertInterface.ts @@ -1,44 +1,44 @@ import { - IDataObject -}from 'n8n-workflow' -export enum AlertStatus{ - NEW="New", - UPDATED="Updated", - IGNORED="Ignored", - IMPORTED="Imported", + IDataObject, +} from 'n8n-workflow'; +export enum AlertStatus { + NEW = 'New', + UPDATED = 'Updated', + IGNORED = 'Ignored', + IMPORTED = 'Imported', } -export enum TLP{ - white, - green, - amber, - red +export enum TLP { + white, + green, + amber, + red, } -export interface IAlert{ - // Required attributes - id?:string; - title?:string; - description?:string; - severity?:number; - date?:Date; - tags?:string[]; - tlp?:TLP; - status?:AlertStatus; - type?:string; - source?:string; - sourceRef?:string; - artifacts?:IDataObject[]; - follow?:boolean; +export interface IAlert { + // Required attributes + id?: string; + title?: string; + description?: string; + severity?: number; + date?: Date; + tags?: string[]; + tlp?: TLP; + status?: AlertStatus; + type?: string; + source?: string; + sourceRef?: string; + artifacts?: IDataObject[]; + follow?: boolean; - // Optional attributes - caseTemplate?:string; + // Optional attributes + caseTemplate?: string; - // Backend generated attributes - lastSyncDate?:Date; - case?:string; + // Backend generated attributes + lastSyncDate?: Date; + case?: string; - createdBy?:string; - createdAt?:Date; - updatedBy?:string; - upadtedAt?:Date; + createdBy?: string; + createdAt?: Date; + updatedBy?: string; + upadtedAt?: Date; } diff --git a/packages/nodes-base/nodes/TheHive/interfaces/CaseInterface.ts b/packages/nodes-base/nodes/TheHive/interfaces/CaseInterface.ts index 88781526ff..9aae200d9f 100644 --- a/packages/nodes-base/nodes/TheHive/interfaces/CaseInterface.ts +++ b/packages/nodes-base/nodes/TheHive/interfaces/CaseInterface.ts @@ -1,53 +1,53 @@ -import { IDataObject } from "n8n-workflow"; +import { IDataObject } from 'n8n-workflow'; import { TLP } from './AlertInterface'; -export interface ICase{ - // Required attributes - id?:string; - title?:string; - description?:string; - severity?:number; - startDate?:Date; - owner?:string; - flag?:boolean; - tlp?:TLP; - tags?:string[]; +export interface ICase { + // Required attributes + id?: string; + title?: string; + description?: string; + severity?: number; + startDate?: Date; + owner?: string; + flag?: boolean; + tlp?: TLP; + tags?: string[]; - // Optional attributes - resolutionStatus?:CaseResolutionStatus; - impactStatus?:CaseImpactStatus; - summary?:string; - endDate?:Date; - metrics?:IDataObject; + // Optional attributes + resolutionStatus?: CaseResolutionStatus; + impactStatus?: CaseImpactStatus; + summary?: string; + endDate?: Date; + metrics?: IDataObject; - // Backend generated attributes - status?:CaseStatus; - caseId?:number; // auto-generated attribute - mergeInto?:string; - mergeFrom?:string[]; + // Backend generated attributes + status?: CaseStatus; + caseId?: number; // auto-generated attribute + mergeInto?: string; + mergeFrom?: string[]; - createdBy?:string; - createdAt?:Date; - updatedBy?:string; - upadtedAt?:Date; + createdBy?: string; + createdAt?: Date; + updatedBy?: string; + upadtedAt?: Date; } -export enum CaseStatus{ - OPEN="Open", - RESOLVED="Resolved", - DELETED="Deleted", +export enum CaseStatus { + OPEN = 'Open', + RESOLVED = 'Resolved', + DELETED = 'Deleted', } -export enum CaseResolutionStatus{ - INDETERMINATE="Indeterminate", - FALSEPOSITIVE="FalsePositive", - TRUEPOSITIVE="TruePositive", - OTHER="Other", - DUPLICATED="Duplicated", +export enum CaseResolutionStatus { + INDETERMINATE = 'Indeterminate', + FALSEPOSITIVE = 'FalsePositive', + TRUEPOSITIVE = 'TruePositive', + OTHER = 'Other', + DUPLICATED = 'Duplicated', } -export enum CaseImpactStatus{ - NOIMPACT="NoImpact", - WITHIMPACT="WithImpact", - NOTAPPLICABLE="NotApplicable", -} \ No newline at end of file +export enum CaseImpactStatus { + NOIMPACT = 'NoImpact', + WITHIMPACT = 'WithImpact', + NOTAPPLICABLE = 'NotApplicable', +} diff --git a/packages/nodes-base/nodes/TheHive/interfaces/LogInterface.ts b/packages/nodes-base/nodes/TheHive/interfaces/LogInterface.ts index a2e957313f..16141d5c17 100644 --- a/packages/nodes-base/nodes/TheHive/interfaces/LogInterface.ts +++ b/packages/nodes-base/nodes/TheHive/interfaces/LogInterface.ts @@ -1,23 +1,22 @@ -import { IDataObject } from "n8n-workflow"; -import {IAttachment} from "./ObservableInterface"; -export enum LogStatus{ - OK="Ok", - DELETED="Deleted" +import { IAttachment } from './ObservableInterface'; +export enum LogStatus { + OK = 'Ok', + DELETED = 'Deleted', } -export interface ILog{ - // Required attributes - id?:string; - message?:string; - startDate?:Date; - status?:LogStatus; - - // Optional attributes - attachment?:IAttachment; - - // Backend generated attributes +export interface ILog { + // Required attributes + id?: string; + message?: string; + startDate?: Date; + status?: LogStatus; - createdBy?:string; - createdAt?:Date; - updatedBy?:string; - upadtedAt?:Date; -} \ No newline at end of file + // Optional attributes + attachment?: IAttachment; + + // Backend generated attributes + + createdBy?: string; + createdAt?: Date; + updatedBy?: string; + upadtedAt?: Date; +} diff --git a/packages/nodes-base/nodes/TheHive/interfaces/ObservableInterface.ts b/packages/nodes-base/nodes/TheHive/interfaces/ObservableInterface.ts index ef4ca93101..9aedfe7f62 100644 --- a/packages/nodes-base/nodes/TheHive/interfaces/ObservableInterface.ts +++ b/packages/nodes-base/nodes/TheHive/interfaces/ObservableInterface.ts @@ -1,54 +1,52 @@ import { - TLP -}from './AlertInterface' -import { IDataObject } from 'n8n-workflow'; + TLP +} from './AlertInterface'; -export enum ObservableStatus{ - OK="Ok", - DELETED="Deleted", +export enum ObservableStatus { + OK = 'Ok', + DELETED = 'Deleted', } -export enum ObservableDataType{ - "domain"= "domain", - "file"= "file", - "filename"= "filename", - "fqdn"= "fqdn", - "hash"= "hash", - "ip"= "ip", - "mail"= "mail", - "mail_subject"= "mail_subject", - "other"= "other", - "regexp"= "regexp", - "registry"= "registry", - "uri_path"= "uri_path", - "url"= "url", - "user-agent"= "user-agent" +export enum ObservableDataType { + 'domain' = 'domain', + 'file' = 'file', + 'filename' = 'filename', + 'fqdn' = 'fqdn', + 'hash' = 'hash', + 'ip' = 'ip', + 'mail' = 'mail', + 'mail_subject' = 'mail_subject', + 'other' = 'other', + 'regexp' = 'regexp', + 'registry' = 'registry', + 'uri_path' = 'uri_path', + 'url' = 'url', + 'user-agent' = 'user-agent', } -export interface IAttachment{ - name?:string; - size?:number; - id?:string; - contentType?:string; - hashes:string[]; +export interface IAttachment { + name?: string; + size?: number; + id?: string; + contentType?: string; + hashes: string[]; } -export interface IObservable{ - // Required attributes - id?:string; - data?:string; - attachment?:IAttachment; - dataType?:ObservableDataType; - message?:string; - startDate?:Date; - tlp?:TLP; - ioc?:boolean; - status?:ObservableStatus; - // Optional attributes - tags:string[]; - // Backend generated attributes - - createdBy?:string; - createdAt?:Date; - updatedBy?:string; - upadtedAt?:Date; +export interface IObservable { + // Required attributes + id?: string; + data?: string; + attachment?: IAttachment; + dataType?: ObservableDataType; + message?: string; + startDate?: Date; + tlp?: TLP; + ioc?: boolean; + status?: ObservableStatus; + // Optional attributes + tags: string[]; + // Backend generated attributes + createdBy?: string; + createdAt?: Date; + updatedBy?: string; + upadtedAt?: Date; } diff --git a/packages/nodes-base/nodes/TheHive/interfaces/TaskInterface.ts b/packages/nodes-base/nodes/TheHive/interfaces/TaskInterface.ts index 4008f214c0..c453e10b1e 100644 --- a/packages/nodes-base/nodes/TheHive/interfaces/TaskInterface.ts +++ b/packages/nodes-base/nodes/TheHive/interfaces/TaskInterface.ts @@ -1,25 +1,25 @@ -export interface ITask{ - // Required attributes - id?:string; - title?:string; - status?:TaskStatus; - flag?:boolean; - // Optional attributes - owner?:string; - description?:string; - startDate?:Date; - endDate?:Date; - // Backend generated attributes +export interface ITask { + // Required attributes + id?: string; + title?: string; + status?: TaskStatus; + flag?: boolean; + // Optional attributes + owner?: string; + description?: string; + startDate?: Date; + endDate?: Date; + // Backend generated attributes - createdBy?:string; - createdAt?:Date; - updatedBy?:string; - upadtedAt?:Date; + createdBy?: string; + createdAt?: Date; + updatedBy?: string; + upadtedAt?: Date; } -export enum TaskStatus{ - WAITING="Waiting", - INPROGRESS="InProgress", - COMPLETED="Completed", - CANCEL="Cancel", +export enum TaskStatus { + WAITING = 'Waiting', + INPROGRESS = 'InProgress', + COMPLETED = 'Completed', + CANCEL = 'Cancel', } diff --git a/packages/nodes-base/nodes/TheHive/thehive.png b/packages/nodes-base/nodes/TheHive/thehive.png index 324e26df93..a28fa90b56 100644 Binary files a/packages/nodes-base/nodes/TheHive/thehive.png and b/packages/nodes-base/nodes/TheHive/thehive.png differ