first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,543 @@
|
||||
import { TLPs } 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: TLPs.white,
|
||||
},
|
||||
{
|
||||
name: 'Green',
|
||||
value: TLPs.green,
|
||||
},
|
||||
{
|
||||
name: 'Amber',
|
||||
value: TLPs.amber,
|
||||
},
|
||||
{
|
||||
name: 'Red',
|
||||
value: TLPs.red,
|
||||
},
|
||||
],
|
||||
removed: true,
|
||||
},
|
||||
{
|
||||
displayName: 'PAP (Level of exposure of information)',
|
||||
id: 'pap',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'White',
|
||||
value: TLPs.white,
|
||||
},
|
||||
{
|
||||
name: 'Green',
|
||||
value: TLPs.green,
|
||||
},
|
||||
{
|
||||
name: 'Amber',
|
||||
value: TLPs.amber,
|
||||
},
|
||||
{
|
||||
name: 'Red',
|
||||
value: TLPs.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: TLPs.white,
|
||||
},
|
||||
{
|
||||
name: 'Green',
|
||||
value: TLPs.green,
|
||||
},
|
||||
{
|
||||
name: 'Amber',
|
||||
value: TLPs.amber,
|
||||
},
|
||||
{
|
||||
name: 'Red',
|
||||
value: TLPs.red,
|
||||
},
|
||||
],
|
||||
removed: false,
|
||||
},
|
||||
{
|
||||
displayName: 'PAP (Level of exposure of information)',
|
||||
id: 'pap',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'White',
|
||||
value: TLPs.white,
|
||||
},
|
||||
{
|
||||
name: 'Green',
|
||||
value: TLPs.green,
|
||||
},
|
||||
{
|
||||
name: 'Amber',
|
||||
value: TLPs.amber,
|
||||
},
|
||||
{
|
||||
name: 'Red',
|
||||
value: TLPs.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: TLPs.white,
|
||||
},
|
||||
{
|
||||
name: 'Green',
|
||||
value: TLPs.green,
|
||||
},
|
||||
{
|
||||
name: 'Amber',
|
||||
value: TLPs.amber,
|
||||
},
|
||||
{
|
||||
name: 'Red',
|
||||
value: TLPs.red,
|
||||
},
|
||||
],
|
||||
removed: false,
|
||||
},
|
||||
{
|
||||
displayName: 'PAP (Level of exposure of information)',
|
||||
id: 'pap',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'White',
|
||||
value: TLPs.white,
|
||||
},
|
||||
{
|
||||
name: 'Green',
|
||||
value: TLPs.green,
|
||||
},
|
||||
{
|
||||
name: 'Amber',
|
||||
value: TLPs.amber,
|
||||
},
|
||||
{
|
||||
name: 'Red',
|
||||
value: TLPs.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,10 @@
|
||||
export const TLPs = {
|
||||
white: 0,
|
||||
green: 1,
|
||||
amber: 2,
|
||||
red: 3,
|
||||
};
|
||||
|
||||
export type TLP = (typeof TLPs)[keyof typeof TLPs];
|
||||
|
||||
export type QueryScope = { query: string; id?: string; restrictTo?: string };
|
||||
@@ -0,0 +1,101 @@
|
||||
import get from 'lodash/get';
|
||||
import set from 'lodash/set';
|
||||
import { ApplicationError, type IDataObject } from 'n8n-workflow';
|
||||
|
||||
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 ApplicationError(`Required field "${id}" is missing in item ${i}`, {
|
||||
level: 'warning',
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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