mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
feat(TheHive Node): Overhaul (#6457)
This commit is contained in:
543
packages/nodes-base/nodes/TheHiveProject/helpers/constants.ts
Normal file
543
packages/nodes-base/nodes/TheHiveProject/helpers/constants.ts
Normal file
@@ -0,0 +1,543 @@
|
||||
import { TLP } from './interfaces';
|
||||
|
||||
export const alertCommonFields = [
|
||||
{
|
||||
displayName: 'Title',
|
||||
id: 'title',
|
||||
type: 'string',
|
||||
removed: false,
|
||||
},
|
||||
{
|
||||
displayName: 'Description',
|
||||
id: 'description',
|
||||
type: 'string',
|
||||
removed: false,
|
||||
},
|
||||
{
|
||||
displayName: 'Type',
|
||||
id: 'type',
|
||||
type: 'string',
|
||||
removed: false,
|
||||
},
|
||||
{
|
||||
displayName: 'Source',
|
||||
id: 'source',
|
||||
type: 'string',
|
||||
removed: false,
|
||||
},
|
||||
{
|
||||
displayName: 'Source Reference',
|
||||
id: 'sourceRef',
|
||||
type: 'string',
|
||||
removed: false,
|
||||
},
|
||||
{
|
||||
displayName: 'External Link',
|
||||
id: 'externalLink',
|
||||
type: 'string',
|
||||
removed: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Severity (Severity of information)',
|
||||
id: 'severity',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Low',
|
||||
value: 1,
|
||||
},
|
||||
{
|
||||
name: 'Medium',
|
||||
value: 2,
|
||||
},
|
||||
{
|
||||
name: 'High',
|
||||
value: 3,
|
||||
},
|
||||
{
|
||||
name: 'Critical',
|
||||
value: 4,
|
||||
},
|
||||
],
|
||||
removed: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Date',
|
||||
id: 'date',
|
||||
type: 'dateTime',
|
||||
removed: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Last Sync Date',
|
||||
id: 'lastSyncDate',
|
||||
type: 'dateTime',
|
||||
removed: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Tags',
|
||||
id: 'tags',
|
||||
type: 'string',
|
||||
removed: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Follow',
|
||||
id: 'follow',
|
||||
type: 'boolean',
|
||||
removed: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Flag',
|
||||
id: 'flag',
|
||||
type: 'boolean',
|
||||
removed: true,
|
||||
},
|
||||
{
|
||||
displayName: 'TLP (Confidentiality of information)',
|
||||
id: 'tlp',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'White',
|
||||
value: TLP.white,
|
||||
},
|
||||
{
|
||||
name: 'Green',
|
||||
value: TLP.green,
|
||||
},
|
||||
{
|
||||
name: 'Amber',
|
||||
value: TLP.amber,
|
||||
},
|
||||
{
|
||||
name: 'Red',
|
||||
value: TLP.red,
|
||||
},
|
||||
],
|
||||
removed: true,
|
||||
},
|
||||
{
|
||||
displayName: 'PAP (Level of exposure of information)',
|
||||
id: 'pap',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'White',
|
||||
value: TLP.white,
|
||||
},
|
||||
{
|
||||
name: 'Green',
|
||||
value: TLP.green,
|
||||
},
|
||||
{
|
||||
name: 'Amber',
|
||||
value: TLP.amber,
|
||||
},
|
||||
{
|
||||
name: 'Red',
|
||||
value: TLP.red,
|
||||
},
|
||||
],
|
||||
removed: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Summary',
|
||||
id: 'summary',
|
||||
type: 'string',
|
||||
removed: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Status',
|
||||
id: 'status',
|
||||
type: 'options',
|
||||
removed: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Case Template',
|
||||
id: 'caseTemplate',
|
||||
type: 'options',
|
||||
removed: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Add Tags',
|
||||
id: 'addTags',
|
||||
type: 'string',
|
||||
canBeUsedToMatch: false,
|
||||
removed: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Remove Tags',
|
||||
id: 'removeTags',
|
||||
type: 'string',
|
||||
canBeUsedToMatch: false,
|
||||
removed: true,
|
||||
},
|
||||
];
|
||||
|
||||
export const caseCommonFields = [
|
||||
{
|
||||
displayName: 'Title',
|
||||
id: 'title',
|
||||
type: 'string',
|
||||
removed: false,
|
||||
},
|
||||
{
|
||||
displayName: 'Description',
|
||||
id: 'description',
|
||||
type: 'string',
|
||||
removed: false,
|
||||
},
|
||||
{
|
||||
displayName: 'Severity (Severity of information)',
|
||||
id: 'severity',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Low',
|
||||
value: 1,
|
||||
},
|
||||
{
|
||||
name: 'Medium',
|
||||
value: 2,
|
||||
},
|
||||
{
|
||||
name: 'High',
|
||||
value: 3,
|
||||
},
|
||||
{
|
||||
name: 'Critical',
|
||||
value: 4,
|
||||
},
|
||||
],
|
||||
removed: false,
|
||||
},
|
||||
{
|
||||
displayName: 'Start Date',
|
||||
id: 'startDate',
|
||||
type: 'dateTime',
|
||||
removed: false,
|
||||
},
|
||||
{
|
||||
displayName: 'End Date',
|
||||
id: 'endDate',
|
||||
type: 'dateTime',
|
||||
removed: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Tags',
|
||||
id: 'tags',
|
||||
type: 'string',
|
||||
removed: false,
|
||||
},
|
||||
{
|
||||
displayName: 'Flag',
|
||||
id: 'flag',
|
||||
type: 'boolean',
|
||||
removed: true,
|
||||
},
|
||||
{
|
||||
displayName: 'TLP (Confidentiality of information)',
|
||||
id: 'tlp',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'White',
|
||||
value: TLP.white,
|
||||
},
|
||||
{
|
||||
name: 'Green',
|
||||
value: TLP.green,
|
||||
},
|
||||
{
|
||||
name: 'Amber',
|
||||
value: TLP.amber,
|
||||
},
|
||||
{
|
||||
name: 'Red',
|
||||
value: TLP.red,
|
||||
},
|
||||
],
|
||||
removed: false,
|
||||
},
|
||||
{
|
||||
displayName: 'PAP (Level of exposure of information)',
|
||||
id: 'pap',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'White',
|
||||
value: TLP.white,
|
||||
},
|
||||
{
|
||||
name: 'Green',
|
||||
value: TLP.green,
|
||||
},
|
||||
{
|
||||
name: 'Amber',
|
||||
value: TLP.amber,
|
||||
},
|
||||
{
|
||||
name: 'Red',
|
||||
value: TLP.red,
|
||||
},
|
||||
],
|
||||
removed: false,
|
||||
},
|
||||
{
|
||||
displayName: 'Summary',
|
||||
id: 'summary',
|
||||
type: 'string',
|
||||
removed: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Status',
|
||||
id: 'status',
|
||||
type: 'options',
|
||||
removed: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Assignee',
|
||||
id: 'assignee',
|
||||
type: 'options',
|
||||
removed: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Case Template',
|
||||
id: 'caseTemplate',
|
||||
type: 'options',
|
||||
removed: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Tasks',
|
||||
id: 'tasks',
|
||||
type: 'array',
|
||||
removed: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Sharing Parameters',
|
||||
id: 'sharingParameters',
|
||||
type: 'array',
|
||||
removed: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Impact Status',
|
||||
id: 'impactStatus',
|
||||
type: 'string',
|
||||
removed: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Task Rule',
|
||||
id: 'taskRule',
|
||||
type: 'string',
|
||||
removed: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Observable Rule',
|
||||
id: 'observableRule',
|
||||
type: 'string',
|
||||
removed: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Add Tags',
|
||||
id: 'addTags',
|
||||
type: 'string',
|
||||
removed: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Remove Tags',
|
||||
id: 'removeTags',
|
||||
type: 'string',
|
||||
removed: true,
|
||||
},
|
||||
];
|
||||
|
||||
export const taskCommonFields = [
|
||||
{
|
||||
displayName: 'Title',
|
||||
id: 'title',
|
||||
type: 'string',
|
||||
removed: false,
|
||||
},
|
||||
{
|
||||
displayName: 'Description',
|
||||
id: 'description',
|
||||
type: 'string',
|
||||
removed: false,
|
||||
},
|
||||
{
|
||||
displayName: 'Group',
|
||||
id: 'group',
|
||||
type: 'string',
|
||||
removed: false,
|
||||
},
|
||||
{
|
||||
displayName: 'Status',
|
||||
id: 'status',
|
||||
type: 'stirng',
|
||||
removed: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Flag',
|
||||
id: 'flag',
|
||||
type: 'boolean',
|
||||
removed: false,
|
||||
},
|
||||
{
|
||||
displayName: 'Start Date',
|
||||
id: 'startDate',
|
||||
type: 'dateTime',
|
||||
removed: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Due Date',
|
||||
id: 'dueDate',
|
||||
type: 'dateTime',
|
||||
removed: false,
|
||||
},
|
||||
{
|
||||
displayName: 'End Date',
|
||||
id: 'endDate',
|
||||
type: 'dateTime',
|
||||
removed: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Assignee',
|
||||
id: 'assignee',
|
||||
type: 'options',
|
||||
removed: false,
|
||||
},
|
||||
{
|
||||
displayName: 'Mandatory',
|
||||
id: 'mandatory',
|
||||
type: 'boolean',
|
||||
removed: false,
|
||||
},
|
||||
{
|
||||
displayName: 'Order',
|
||||
id: 'order',
|
||||
type: 'number',
|
||||
removed: true,
|
||||
},
|
||||
];
|
||||
|
||||
export const observableCommonFields = [
|
||||
{
|
||||
displayName: 'Data Type',
|
||||
id: 'dataType',
|
||||
type: 'options',
|
||||
removed: false,
|
||||
},
|
||||
{
|
||||
displayName: 'Start Date',
|
||||
id: 'startDate',
|
||||
type: 'dateTime',
|
||||
removed: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Description',
|
||||
id: 'message',
|
||||
type: 'string',
|
||||
removed: false,
|
||||
},
|
||||
{
|
||||
displayName: 'Tags',
|
||||
id: 'tags',
|
||||
type: 'string',
|
||||
removed: false,
|
||||
},
|
||||
{
|
||||
displayName: 'TLP (Confidentiality of information)',
|
||||
id: 'tlp',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'White',
|
||||
value: TLP.white,
|
||||
},
|
||||
{
|
||||
name: 'Green',
|
||||
value: TLP.green,
|
||||
},
|
||||
{
|
||||
name: 'Amber',
|
||||
value: TLP.amber,
|
||||
},
|
||||
{
|
||||
name: 'Red',
|
||||
value: TLP.red,
|
||||
},
|
||||
],
|
||||
removed: false,
|
||||
},
|
||||
{
|
||||
displayName: 'PAP (Level of exposure of information)',
|
||||
id: 'pap',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'White',
|
||||
value: TLP.white,
|
||||
},
|
||||
{
|
||||
name: 'Green',
|
||||
value: TLP.green,
|
||||
},
|
||||
{
|
||||
name: 'Amber',
|
||||
value: TLP.amber,
|
||||
},
|
||||
{
|
||||
name: 'Red',
|
||||
value: TLP.red,
|
||||
},
|
||||
],
|
||||
removed: false,
|
||||
},
|
||||
{
|
||||
displayName: 'IOC',
|
||||
id: 'ioc',
|
||||
type: 'boolean',
|
||||
removed: false,
|
||||
},
|
||||
{
|
||||
displayName: 'Sighted',
|
||||
id: 'sighted',
|
||||
type: 'boolean',
|
||||
removed: false,
|
||||
},
|
||||
{
|
||||
displayName: 'Sighted At',
|
||||
id: 'sightedAt',
|
||||
type: 'dateTime',
|
||||
removed: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Ignore Similarity',
|
||||
id: 'ignoreSimilarity',
|
||||
type: 'boolean',
|
||||
removed: false,
|
||||
},
|
||||
{
|
||||
displayName: 'Is Zip',
|
||||
id: 'isZip',
|
||||
type: 'boolean',
|
||||
removed: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Zip Password',
|
||||
id: 'zipPassword',
|
||||
type: 'string',
|
||||
removed: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Add Tags',
|
||||
id: 'addTags',
|
||||
type: 'string',
|
||||
removed: true,
|
||||
},
|
||||
{
|
||||
displayName: 'Remove Tags',
|
||||
id: 'removeTags',
|
||||
type: 'string',
|
||||
removed: true,
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,8 @@
|
||||
export const enum TLP {
|
||||
white,
|
||||
green,
|
||||
amber,
|
||||
red,
|
||||
}
|
||||
|
||||
export type QueryScope = { query: string; id?: string; restrictTo?: string };
|
||||
100
packages/nodes-base/nodes/TheHiveProject/helpers/utils.ts
Normal file
100
packages/nodes-base/nodes/TheHiveProject/helpers/utils.ts
Normal file
@@ -0,0 +1,100 @@
|
||||
import type { IDataObject } from 'n8n-workflow';
|
||||
|
||||
import get from 'lodash/get';
|
||||
import set from 'lodash/set';
|
||||
|
||||
export function splitAndTrim(str: string | string[]) {
|
||||
if (typeof str === 'string') {
|
||||
return str
|
||||
.split(',')
|
||||
.map((tag) => tag.trim())
|
||||
.filter((tag) => tag);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
export function fixFieldType(fields: IDataObject) {
|
||||
const returnData: IDataObject = {};
|
||||
|
||||
for (const key of Object.keys(fields)) {
|
||||
if (
|
||||
[
|
||||
'date',
|
||||
'lastSyncDate',
|
||||
'startDate',
|
||||
'endDate',
|
||||
'dueDate',
|
||||
'includeInTimeline',
|
||||
'sightedAt',
|
||||
].includes(key)
|
||||
) {
|
||||
returnData[key] = Date.parse(fields[key] as string);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (['tags', 'addTags', 'removeTags'].includes(key)) {
|
||||
returnData[key] = splitAndTrim(fields[key] as string);
|
||||
continue;
|
||||
}
|
||||
|
||||
returnData[key] = fields[key];
|
||||
}
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
export function prepareInputItem(item: IDataObject, schema: IDataObject[], i: number) {
|
||||
const returnData: IDataObject = {};
|
||||
|
||||
for (const entry of schema) {
|
||||
const id = entry.id as string;
|
||||
const value = get(item, id);
|
||||
|
||||
if (value !== undefined) {
|
||||
set(returnData, id, value);
|
||||
} else {
|
||||
if (entry.required) {
|
||||
throw new Error(`Required field "${id}" is missing in item ${i}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
export function constructFilter(entry: IDataObject) {
|
||||
const { field, value } = entry;
|
||||
let { operator } = entry;
|
||||
|
||||
if (operator === undefined) {
|
||||
operator = '_eq';
|
||||
}
|
||||
|
||||
if (operator === '_between') {
|
||||
const { from, to } = entry;
|
||||
return {
|
||||
_between: {
|
||||
_field: field,
|
||||
_from: from,
|
||||
_to: to,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
if (operator === '_in') {
|
||||
const { values } = entry;
|
||||
return {
|
||||
_in: {
|
||||
_field: field,
|
||||
_values: typeof values === 'string' ? splitAndTrim(values) : values,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
[operator as string]: {
|
||||
_field: field,
|
||||
_value: value,
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user