Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "nodes": [
- {
- "parameters": {
- "rule": {
- "interval": [
- {
- "field": "seconds",
- "secondsInterval": 5
- }
- ]
- }
- },
- "type": "n8n-nodes-base.scheduleTrigger",
- "typeVersion": 1.3,
- "position": [
- -896,
- 208
- ],
- "id": "d19aa5a5-5710-4378-9bd0-e421901f9012",
- "name": "Trigger A"
- },
- {
- "parameters": {
- "conditions": {
- "options": {
- "caseSensitive": true,
- "leftValue": "",
- "typeValidation": "strict",
- "version": 3
- },
- "conditions": [
- {
- "id": "77b3b8cf-ef48-4eea-8c54-fe40889728c2",
- "leftValue": "={{ $json[\"MITRE existing\"] }}",
- "rightValue": "",
- "operator": {
- "type": "boolean",
- "operation": "true",
- "singleValue": true
- }
- }
- ],
- "combinator": "and"
- },
- "options": {}
- },
- "type": "n8n-nodes-base.if",
- "typeVersion": 2.3,
- "position": [
- 80,
- -128
- ],
- "id": "51dc5773-2e18-49ff-acac-386ce7b93462",
- "name": "MITRE Exist"
- },
- {
- "parameters": {
- "aggregate": "aggregateAllItemData",
- "options": {}
- },
- "type": "n8n-nodes-base.aggregate",
- "typeVersion": 1,
- "position": [
- -256,
- 176
- ],
- "id": "72ac2f80-40cf-46c4-a9a2-8f40fd29cf6d",
- "name": "Aggregate"
- },
- {
- "parameters": {
- "sessionIdType": "customKey",
- "sessionKey": "1HTWI3FuNjqRBFHE"
- },
- "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
- "typeVersion": 1.3,
- "position": [
- 16,
- 368
- ],
- "id": "073b2354-34f0-4f9a-872a-6477da342aa9",
- "name": "Simple Memory"
- },
- {
- "parameters": {
- "promptType": "define",
- "text": "=Here is the batch of detection rules to analyze:\n\n{{ JSON.stringify($json.data) }}",
- "options": {
- "systemMessage": "You are a Senior Detection Engineer and MITRE ATT&CK Specialist. Your task is to analyze security detection rules that lack technique mappings and assign them the most accurate MITRE ATT&CK Enterprise Technique.\n\nINPUT DATA:\nYou will receive a JSON Array of detection rules.\n\nAnalysis Logic (Apply to each rule):\n1- Analyze the Intent: Read the Rule Name and Description to understand what bad behavior is being caught (e.g., Phishing, Persistence, Exfiltration).\n\n2- Verify with Query: Look at the query logic (fields like event.action, process.name) to confirm the technical implementation matches the description.\n\n3- Map: Assign the specific Technique ID (e.g., T1098) and Technique Name. If the rule detects multiple techniques, choose the primary one.\n\n4- Atlas/LLM Rules: If the rule is specific to AI/LLM security (e.g., Bedrock, prohibited topics) and fits MITRE ATLAS, use the ATLAS ID (e.g., AML.T0051) if a standard Enterprise ID (Txxxx) does not fit well.\n\nOutput Format: You must return rule id, rule name, mitre id, technique, and rationale in ONLY a valid JSON object with no markdown formatting:\n\nJSON\n\n{\n \"rule_id\": \"The original rule_id from input\",\n \"rule_name\": \"Name of the rule\",\n \"mitre_id\": \"Txxxx\",\n \"technique_name\": \"The Technique Name\",\n \"rationale\": \"A single simple sentence explaining why this logic maps to this technique.\"\n}"
- }
- },
- "type": "@n8n/n8n-nodes-langchain.agent",
- "typeVersion": 3,
- "position": [
- -48,
- 176
- ],
- "id": "6fb83e8a-40ef-4ed0-b741-2c9ae216ce45",
- "name": "Map to MITRE Agent"
- },
- {
- "parameters": {
- "jsCode": "// This parses the string output from the AI into actual JSON objects\nconst aiResponse = $input.first().json.output; // Adjust '.output' to whatever the AI node outputs\n\nlet parsedRules = [];\ntry {\n // Clean up if the AI accidentally added markdown blocks\n const cleanJson = aiResponse.replace(/```json/g, '').replace(/```/g, '').trim();\n parsedRules = JSON.parse(cleanJson);\n} catch (error) {\n // Fallback if JSON is broken\n parsedRules = [{ error: \"Failed to parse AI response\", raw: aiResponse }];\n}\n\nreturn parsedRules.map(rule => ({ json: rule }));"
- },
- "type": "n8n-nodes-base.code",
- "typeVersion": 2,
- "position": [
- 288,
- 176
- ],
- "id": "a8c3bc4f-108f-49d4-ab39-56285a9966b5",
- "name": "Parse AI output"
- },
- {
- "parameters": {
- "options": {}
- },
- "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
- "typeVersion": 1,
- "position": [
- -176,
- 368
- ],
- "id": "f20ad206-b5ec-441d-a1a0-76573537870d",
- "name": "Google Gemini",
- "credentials": {
- "googlePalmApi": {
- "id": "UUKj0VZzkNCvUPkc",
- "name": "Google Gemini(PaLM) Api account"
- }
- }
- },
- {
- "parameters": {},
- "type": "n8n-nodes-base.merge",
- "typeVersion": 3.2,
- "position": [
- 992,
- 96
- ],
- "id": "1fb9abf8-a4b0-4fb2-8267-77f358159729",
- "name": "Merge 2",
- "alwaysOutputData": false
- },
- {
- "parameters": {
- "mode": "combine",
- "advanced": true,
- "mergeByFields": {
- "values": [
- {
- "field1": "data.rule_id",
- "field2": "rule_id"
- }
- ]
- },
- "options": {}
- },
- "type": "n8n-nodes-base.merge",
- "typeVersion": 3.2,
- "position": [
- 544,
- 160
- ],
- "id": "5e06839d-f181-420d-837f-2f2a8281bb8e",
- "name": "Merge 1"
- },
- {
- "parameters": {
- "assignments": {
- "assignments": [
- {
- "id": "b019376b-2a73-42ab-9def-f4e0c1568839",
- "name": "Rule ID",
- "value": "={{ $json.data.rule_id }}",
- "type": "string"
- },
- {
- "id": "9061f1ce-1ae5-46cd-b1ad-49c20fb5fc6c",
- "name": "Rule Name",
- "value": "={{ $json.data.name }}",
- "type": "string"
- },
- {
- "id": "ae4a8cd2-98f0-42e8-bddc-94dcefb154f6",
- "name": "Rule Query",
- "value": "={{ $json.data.query }}",
- "type": "string"
- },
- {
- "id": "3e00ecfb-c4d4-464f-914b-82ab53d93c3e",
- "name": "MITRE Technique",
- "value": "={{ $json.data.tags.length > 0 ? $json.data.tags[0].replace('Mitre Atlas: ', '').replace('Mitre ATT&CK: ', '') : ($json.Threat.length > 0 ? $json.Threat[0].technique[0].id : '') }}",
- "type": "string"
- },
- {
- "id": "6e15f789-ae69-41e5-8039-d2a1543e4db6",
- "name": "Technique Name",
- "value": "={{ $json.data.tags.length > 0 ? $json.data.tags[0].replace('Mitre Atlas: ', '').replace('Mitre ATT&CK: ', '') : ($json.Threat.length > 0 ? $json.Threat[0].technique[0].name : '') }}",
- "type": "string"
- },
- {
- "id": "f762079f-b0e2-4f64-ad50-d558f7f829e1",
- "name": "Mapping Method",
- "value": "Existing",
- "type": "string"
- },
- {
- "id": "684fd484-37e4-42a1-bcec-db75d4632855",
- "name": "Mapping Rationale",
- "value": "=Existing mapping",
- "type": "string"
- },
- {
- "id": "cf340f23-89e6-4a11-ad77-607068856427",
- "name": "Required Fields",
- "value": "={{ $json[\"Required Fields\"] }}",
- "type": "string"
- },
- {
- "id": "afad19fa-2452-40be-829c-db54e4e23f3e",
- "name": "Log Source Covered",
- "value": "={{ $json[\"Log Source Covered\"] }}",
- "type": "string"
- },
- {
- "id": "f100a2c7-469b-4191-84f8-77cf1ffd10f7",
- "name": "Fields Covered",
- "value": "={{ $json[\"Fields Covered\"] }}",
- "type": "string"
- },
- {
- "id": "e18fbd44-8fd5-4d23-a47a-0b9197e328e8",
- "name": "Coverage Notes",
- "value": "={{ $json[\"Coverage Notes\"] }}",
- "type": "string"
- },
- {
- "id": "719eec13-9a0e-4133-8d7d-415b1e18d9bd",
- "name": "Reviewed By",
- "value": "={{ $json[\"Reviewed By\"] }}",
- "type": "string"
- },
- {
- "id": "fc716ffe-5135-4ec0-a485-deba25685c0f",
- "name": "Rule Index",
- "value": "={{ $json.data.index }}",
- "type": "string"
- }
- ]
- },
- "options": {}
- },
- "type": "n8n-nodes-base.set",
- "typeVersion": 3.4,
- "position": [
- 560,
- -80
- ],
- "id": "ca38bfb0-6402-4e5b-a68c-75db70133d4e",
- "name": "Reformat 1"
- },
- {
- "parameters": {
- "assignments": {
- "assignments": [
- {
- "id": "61c919a3-0fcd-4475-89ab-21b5a65ac63a",
- "name": "Rule ID",
- "value": "={{ $json.data.rule_id }}",
- "type": "string"
- },
- {
- "id": "dc422ac5-973e-4db0-be03-e6bf19245cf3",
- "name": "Rule Name",
- "value": "={{ $json.data.name }}",
- "type": "string"
- },
- {
- "id": "4815a3e8-7d7f-459d-bb75-a6dcb085751f",
- "name": "Rule Query",
- "value": "={{ $json.data.query }}",
- "type": "string"
- },
- {
- "id": "1e518516-afc4-42f0-a566-03fc5af10887",
- "name": "MITRE Technique",
- "value": "={{ $('Parse AI output').item.json.mitre_id }}",
- "type": "string"
- },
- {
- "id": "cd459136-8872-40fe-8889-4a66f3a457e4",
- "name": "Technique Name",
- "value": "={{ $('Parse AI output').item.json.technique_name }}",
- "type": "string"
- },
- {
- "id": "b75228ea-3f38-402b-9597-9aaa511ee618",
- "name": "Mapping Method",
- "value": "=LLM",
- "type": "string"
- },
- {
- "id": "9d046d11-b118-4ce2-9a64-616641a28a4b",
- "name": "Mapping Rationale",
- "value": "={{ $('Parse AI output').item.json.rationale }}",
- "type": "string"
- },
- {
- "id": "67145de9-c762-4e01-802a-587b4ece1fe8",
- "name": "Required Fields",
- "value": "={{ $('MITRE Exist').item.json[\"Required Fields\"] }}",
- "type": "string"
- },
- {
- "id": "4cde6e15-e78e-4fe7-98bc-e85496fcfd9f",
- "name": "Log Source Covered",
- "value": "=",
- "type": "string"
- },
- {
- "id": "834493b7-47cc-4446-a466-68d092d9aaba",
- "name": "Fields Covered",
- "value": "=",
- "type": "string"
- },
- {
- "id": "b8c7cbd1-d099-4b3f-95c6-5744fcb57165",
- "name": "Coverage Notes",
- "value": "={{ $('MITRE Exist').item.json[\"Coverage Notes\"] }}",
- "type": "string"
- },
- {
- "id": "32565562-10dd-440c-84dc-e4cdec43f4c2",
- "name": "Reviewed By",
- "value": "={{ $json[\"Reviewed By\"] }}",
- "type": "string"
- },
- {
- "id": "1b8d3d72-3ea4-4880-9254-d505d919e522",
- "name": "Rule Index",
- "value": "={{ $json.data.index }}",
- "type": "string"
- }
- ]
- },
- "options": {}
- },
- "type": "n8n-nodes-base.set",
- "typeVersion": 3.4,
- "position": [
- 752,
- 160
- ],
- "id": "1212bb5f-a011-41bf-b26c-3951d6f167ac",
- "name": "Reformat 2"
- },
- {
- "parameters": {
- "assignments": {
- "assignments": [
- {
- "id": "b8b862dd-acce-44e0-8702-36f0b0d0911c",
- "name": "data.rule_id",
- "value": "={{ $json.data.rule_id }}",
- "type": "string"
- },
- {
- "id": "84916eb0-694f-45f1-a64b-f7a28724d66b",
- "name": "data.name",
- "value": "={{ $json.data.name }}",
- "type": "string"
- },
- {
- "id": "9ab376c0-ceba-415f-bf54-f0ff08b11bd1",
- "name": "data.description",
- "value": "={{ $json.data.description }}",
- "type": "string"
- },
- {
- "id": "029cca8e-b1cd-4caf-ac0f-8ef40b347b15",
- "name": "data.query",
- "value": "={{ $json.data.query.replace(/\\n+/g, ' ').trim() }}",
- "type": "string"
- },
- {
- "id": "e55c6f85-e298-4050-a79c-fff665322e0f",
- "name": "data.tags",
- "value": "={{ $json.data.tags.filter(t => t.startsWith('Mitre')) }}",
- "type": "array"
- },
- {
- "id": "f1188b45-f510-45e7-b313-0d619f09294c",
- "name": "MITRE existing",
- "value": "={{ \n ($json.data.tags && $json.data.tags.some(t => t.startsWith('Mitre'))) \n || \n ($json.data.threat && $json.data.threat.length > 0 && $json.data.threat[0].technique && $json.data.threat[0].technique.length > 0) \n}}",
- "type": "boolean"
- },
- {
- "id": "ba2486fa-3466-42a3-8c04-fff4eba8b3e3",
- "name": "Threat",
- "value": "={{ $json.data.threat }}",
- "type": "array"
- },
- {
- "id": "192445f8-0cc5-4ddc-82dd-f74986992c13",
- "name": "Mapping Method",
- "value": "={{ $json.mitre_existing ? 'Existing' : 'LLM' }}",
- "type": "string"
- },
- {
- "id": "6f0be795-f0dd-4e9d-9fa0-f941528ef632",
- "name": "Mapping Rationale",
- "value": "={{ '' }}",
- "type": "string"
- },
- {
- "id": "330f0fa3-39a5-44d6-a459-b4893b3517e7",
- "name": "Required Fields",
- "value": "={{ $json.data.required_fields.map(f => f.name).join(', ') }}",
- "type": "string"
- },
- {
- "id": "46a3c144-7d06-4a3f-b359-330dd2586189",
- "name": "Log Source Covered",
- "value": "={{ '' }}",
- "type": "string"
- },
- {
- "id": "e9bd835c-7e72-42d6-9012-1b83ebbe7f86",
- "name": "Fields Covered",
- "value": "={{ '' }}",
- "type": "string"
- },
- {
- "id": "f1ae2658-7863-4f75-80dc-fd0e9035e590",
- "name": "Coverage Notes",
- "value": "={{ '' }}",
- "type": "string"
- },
- {
- "id": "472bb85c-4a6c-4681-b07b-0602a8937d32",
- "name": "Reviewed By",
- "value": "Shehab",
- "type": "string"
- },
- {
- "id": "35c0f47b-017e-4caf-9c81-1cfb653f099c",
- "name": "data.index",
- "value": "={{ $json.data?.index ?? null }}",
- "type": "string"
- }
- ]
- },
- "options": {
- "ignoreConversionErrors": false
- }
- },
- "type": "n8n-nodes-base.set",
- "typeVersion": 3.4,
- "position": [
- -176,
- -128
- ],
- "id": "ddb15057-ad6a-47bf-8975-995e64f29ca3",
- "name": "Important Fields For LLM"
- },
- {
- "parameters": {
- "url": "http://208.73.204.77:5601/api/detection_engine/rules/_find?per_page=2000",
- "authentication": "genericCredentialType",
- "genericAuthType": "httpBasicAuth",
- "options": {
- "allowUnauthorizedCerts": false
- }
- },
- "type": "n8n-nodes-base.httpRequest",
- "typeVersion": 4.3,
- "position": [
- -704,
- 64
- ],
- "id": "3fe64ee0-f237-42fb-92cb-bca9ce94d0dd",
- "name": "Get Rules",
- "executeOnce": false,
- "retryOnFail": false,
- "credentials": {
- "httpBasicAuth": {
- "id": "k42XGGNE51AgavbK",
- "name": "Elastic OJT creds"
- }
- },
- "onError": "continueRegularOutput"
- },
- {
- "parameters": {
- "conditions": {
- "options": {
- "caseSensitive": true,
- "leftValue": "",
- "typeValidation": "strict",
- "version": 3
- },
- "conditions": [
- {
- "id": "a240939c-3b6e-4593-a369-d7f3e88b8176",
- "leftValue": "={{ $json.data.enabled }}",
- "rightValue": true,
- "operator": {
- "type": "boolean",
- "operation": "equals"
- }
- }
- ],
- "combinator": "and"
- },
- "options": {}
- },
- "type": "n8n-nodes-base.filter",
- "typeVersion": 2.3,
- "position": [
- -352,
- -128
- ],
- "id": "9b42061a-bab7-4790-8d9f-3da8b759b7c7",
- "name": "Filter Enabled Rules"
- },
- {
- "parameters": {
- "fieldToSplitOut": "data",
- "include": "allOtherFields",
- "options": {}
- },
- "type": "n8n-nodes-base.splitOut",
- "typeVersion": 1,
- "position": [
- -528,
- -64
- ],
- "id": "a5bd7b29-dd4a-487e-a477-8def57772926",
- "name": "Split Out 1",
- "onError": "continueRegularOutput"
- },
- {
- "parameters": {
- "jsCode": "const itemsByTechnique = {};\n\nfor (const item of items) {\n const techId = item.json[\"MITRE Technique\"];\n const techName = item.json[\"Technique Name\"];\n\n if (!itemsByTechnique[techId]) {\n itemsByTechnique[techId] = {\n technique_id: techId,\n technique_name: techName,\n count: 0,\n };\n }\n\n itemsByTechnique[techId].count++;\n}\n\nconst output = [];\n\nfor (const tech of Object.values(itemsByTechnique)) {\n let coverage;\n let notes;\n\nif (tech.count >= 5) {\n coverage = \"Good\";\n notes = \"\";\n} else if (tech.count >= 1) {\n coverage = \"Partial\";\n notes = \"Missing fields\";\n} else {\n coverage = \"Broken\";\n notes = \"No telemetry\";\n}\n\n\noutput.push({\n json: {\n // 1. The ID column (Clickable Formula)\n \"Technique ID\": `=HYPERLINK(\"https://attack.mitre.org/techniques/${\n tech.technique_id.includes('.') \n ? tech.technique_id.replace('.', '/') \n : tech.technique_id\n }\", \"${tech.technique_id}\")`,\n\n \"Technique Name\": tech.technique_name, \n\n \"Rules Mapped Count\": tech.count,\n \"Covered By Telemetry\": coverage,\n \"Coverage Notes\": notes,\n },\n});\n\n\n}\n\nreturn output;\n"
- },
- "type": "n8n-nodes-base.code",
- "typeVersion": 2,
- "position": [
- 1184,
- 320
- ],
- "id": "3969712f-9d34-42f3-b582-1192ad15aeae",
- "name": "MITRE Coverage Sheet"
- },
- {
- "parameters": {
- "assignments": {
- "assignments": [
- {
- "id": "1f612020-e810-43e4-ab2f-e85ad13e0930",
- "name": "Rule ID",
- "value": "={{ $json[\"Rule ID\"] }}",
- "type": "string"
- },
- {
- "id": "cf7a50ee-b71d-4342-a698-5843b493ccb8",
- "name": "Rule Name",
- "value": "={{ $json[\"Rule Name\"] }}",
- "type": "string"
- },
- {
- "id": "56b53d9c-9680-449b-8e51-bfad8c32abc9",
- "name": "Rule Query",
- "value": "={{ $json[\"Rule Query\"] }}",
- "type": "string"
- },
- {
- "id": "d324768b-cc0d-4684-bf1a-416b41062c1b",
- "name": "Rule Index",
- "value": "={{ JSON.parse($json[\"Rule Index\"]).join(\", \") }}",
- "type": "string"
- },
- {
- "id": "7197209d-d562-4ebf-9a19-81fbe2fd9285",
- "name": "MITRE Technique",
- "value": "==HYPERLINK(\n \"https://attack.mitre.org/techniques/{{ $json[\"MITRE Technique\"].includes('.') ? $json[\"MITRE Technique\"].replace('.', '/') + '/' : $json[\"MITRE Technique\"] + '/' }}\",\n \"{{ $json[\"MITRE Technique\"] }}\"\n)\n",
- "type": "string"
- },
- {
- "id": "73d463d7-a1d0-46e0-8ea3-07e273d255e9",
- "name": "Mapping Method",
- "value": "={{ $json[\"Mapping Method\"] }}",
- "type": "string"
- },
- {
- "id": "3286ccb8-1c32-4a79-b588-fc7b654a94f0",
- "name": "Mapping Rationale",
- "value": "={{ $json[\"Mapping Rationale\"] }}",
- "type": "string"
- },
- {
- "id": "77572f5f-2ec0-4eab-bb23-5cb61facd2fd",
- "name": "Required Fields",
- "value": "={{ $json[\"Required Fields\"] }}",
- "type": "string"
- },
- {
- "id": "b1c2631c-e528-42e6-b2e7-6b75c50c0224",
- "name": "Log Source Covered",
- "value": "={{ $json[\"Log Source Covered\"] }}",
- "type": "string"
- },
- {
- "id": "bca94689-98bf-4708-90ec-a7568e1c7ea3",
- "name": "Fields Covered",
- "value": "={{ $json[\"Fields Covered\"] }}",
- "type": "string"
- },
- {
- "id": "4cf49151-6e1f-47f0-909c-dfbdafc8bec9",
- "name": "Coverage Notes",
- "value": "={{ $json[\"Coverage Notes\"] }}",
- "type": "string"
- },
- {
- "id": "42241552-3b57-4ea0-8507-abef93c5f8a6",
- "name": "Reviewed By",
- "value": "={{ $json[\"Reviewed By\"] }}",
- "type": "string"
- }
- ]
- },
- "options": {}
- },
- "type": "n8n-nodes-base.set",
- "typeVersion": 3.4,
- "position": [
- 1232,
- 96
- ],
- "id": "e377e355-fee5-4b73-82ff-b1b515fd9e65",
- "name": "Rules Sheet"
- },
- {
- "parameters": {
- "operation": "appendOrUpdate",
- "documentId": {
- "__rl": true,
- "value": "10KcsY87LIDqYkh__e0TUK7tLMszijuiMP70ji9wNZjs",
- "mode": "list",
- "cachedResultName": "Automated Detection Coverage - Shehab",
- "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10KcsY87LIDqYkh__e0TUK7tLMszijuiMP70ji9wNZjs/edit?usp=drivesdk"
- },
- "sheetName": {
- "__rl": true,
- "value": "gid=0",
- "mode": "list",
- "cachedResultName": "Rules Sheet",
- "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10KcsY87LIDqYkh__e0TUK7tLMszijuiMP70ji9wNZjs/edit#gid=0"
- },
- "columns": {
- "mappingMode": "autoMapInputData",
- "value": {
- "Rule ID": "={{ $json[\"Rule ID\"] }}",
- "Rule Name": "={{ $json[\"Rule Name\"] }}",
- "Rule Query": "={{ $json[\"Rule Query\"] }}",
- "Rule Index": "={{ $json[\"Rule Index\"] }}",
- "MITRE Technique": "="
- },
- "matchingColumns": [
- "Rule ID"
- ],
- "schema": [
- {
- "id": "Rule ID",
- "displayName": "Rule ID",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true,
- "removed": false
- },
- {
- "id": "Rule Name",
- "displayName": "Rule Name",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true
- },
- {
- "id": "Rule Query",
- "displayName": "Rule Query",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true
- },
- {
- "id": "Rule Index",
- "displayName": "Rule Index",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true,
- "removed": false
- },
- {
- "id": "MITRE Technique",
- "displayName": "MITRE Technique",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true
- },
- {
- "id": "Mapping Method",
- "displayName": "Mapping Method",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true
- },
- {
- "id": "Mapping Rationale",
- "displayName": "Mapping Rationale",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true
- },
- {
- "id": "Required Fields",
- "displayName": "Required Fields",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true
- },
- {
- "id": "Log Source Covered",
- "displayName": "Log Source Covered",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true
- },
- {
- "id": "Fields Covered",
- "displayName": "Fields Covered",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true
- },
- {
- "id": "Coverage Notes",
- "displayName": "Coverage Notes",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true
- },
- {
- "id": "Reviewed By",
- "displayName": "Reviewed By",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true
- }
- ],
- "attemptToConvertTypes": false,
- "convertFieldsToString": false
- },
- "options": {}
- },
- "type": "n8n-nodes-base.googleSheets",
- "typeVersion": 4.7,
- "position": [
- 1440,
- 96
- ],
- "id": "608edc00-fabf-44fe-9f1e-c000fd2cc657",
- "name": "Rules Table",
- "credentials": {
- "googleSheetsOAuth2Api": {
- "id": "Ij6ijI3slM4jU3nJ",
- "name": "Google Sheets account"
- }
- }
- },
- {
- "parameters": {
- "operation": "appendOrUpdate",
- "documentId": {
- "__rl": true,
- "value": "10KcsY87LIDqYkh__e0TUK7tLMszijuiMP70ji9wNZjs",
- "mode": "list",
- "cachedResultName": "Automated Detection Coverage - Shehab",
- "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10KcsY87LIDqYkh__e0TUK7tLMszijuiMP70ji9wNZjs/edit?usp=drivesdk"
- },
- "sheetName": {
- "__rl": true,
- "value": 2059778413,
- "mode": "list",
- "cachedResultName": "MITRE Coverage",
- "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10KcsY87LIDqYkh__e0TUK7tLMszijuiMP70ji9wNZjs/edit#gid=2059778413"
- },
- "columns": {
- "mappingMode": "autoMapInputData",
- "value": {},
- "matchingColumns": [
- "Technique Name"
- ],
- "schema": [
- {
- "id": "Technique ID",
- "displayName": "Technique ID",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true,
- "removed": false
- },
- {
- "id": "Technique Name",
- "displayName": "Technique Name",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true,
- "removed": false
- },
- {
- "id": "Rules Mapped Count",
- "displayName": "Rules Mapped Count",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true
- },
- {
- "id": "Covered By Telemetry",
- "displayName": "Covered By Telemetry",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true
- },
- {
- "id": "Coverage Notes",
- "displayName": "Coverage Notes",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true
- },
- {
- "id": "Good -> have 5 or more rules per technique\nPartial -> have more than 1 and less than 5 rule per technique\nBroken -> No rules for this technique",
- "displayName": "Good -> have 5 or more rules per technique\nPartial -> have more than 1 and less than 5 rule per technique\nBroken -> No rules for this technique",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true,
- "removed": false
- }
- ],
- "attemptToConvertTypes": false,
- "convertFieldsToString": false
- },
- "options": {}
- },
- "type": "n8n-nodes-base.googleSheets",
- "typeVersion": 4.7,
- "position": [
- 1600,
- 320
- ],
- "id": "0e3667f1-f402-4250-8ab3-e9ab77c6d20e",
- "name": "MITRE Coverage Table",
- "credentials": {
- "googleSheetsOAuth2Api": {
- "id": "Ij6ijI3slM4jU3nJ",
- "name": "Google Sheets account"
- }
- }
- },
- {
- "parameters": {
- "sortFieldsUi": {
- "sortField": [
- {
- "fieldName": "Rules Mapped Count",
- "order": "descending"
- }
- ]
- },
- "options": {}
- },
- "type": "n8n-nodes-base.sort",
- "typeVersion": 1,
- "position": [
- 1392,
- 320
- ],
- "id": "2e1c1c85-d2f1-4e0a-97af-b409b79ff13f",
- "name": "Sort"
- },
- {
- "parameters": {
- "content": "## Trigger A",
- "height": 608,
- "width": 2752,
- "color": 3
- },
- "type": "n8n-nodes-base.stickyNote",
- "typeVersion": 1,
- "position": [
- -976,
- -128
- ],
- "id": "43dd8306-ef96-4132-8a93-13b4933298ef",
- "name": "Sticky Note1"
- },
- {
- "parameters": {
- "assignments": {
- "assignments": [
- {
- "id": "42cf10fd-a8e3-4deb-9947-f0a833de069f",
- "name": "Rule ID",
- "value": "={{ $('Get Rules Rows1').item.json[\"Rule ID\"] }}",
- "type": "string"
- },
- {
- "id": "3ac7403a-ed7f-404e-83c5-6a12440913e2",
- "name": "Rule Name",
- "value": "={{ $('Get Rules Rows1').item.json[\"Rule Name\"] }}",
- "type": "string"
- },
- {
- "id": "b18dd293-f1bd-4d04-91d6-8729403c3de8",
- "name": "Exclusion Reason",
- "value": "={{ ($json['Log Source Covered'] === true && $json['Fields Covered'] === true) ? 'Accepted rule' : $json['Coverage Notes'] }}",
- "type": "string"
- },
- {
- "id": "3cd52f3c-2c8b-4295-96ff-46930cad12cf",
- "name": "Reviewed By",
- "value": "Shehab ",
- "type": "string"
- }
- ]
- },
- "options": {}
- },
- "type": "n8n-nodes-base.set",
- "typeVersion": 3.4,
- "position": [
- 1168,
- 1072
- ],
- "id": "cd0d452a-0bb6-46f4-b38a-b1881e31b020",
- "name": "Format 2"
- },
- {
- "parameters": {
- "assignments": {
- "assignments": [
- {
- "id": "9cdd6c3b-09be-470d-bbd1-2b5a489142ec",
- "name": "Rule Name",
- "value": "={{ $json[\"Rule Name\"] }}",
- "type": "string"
- },
- {
- "id": "82350fda-23ce-4aaa-bc7c-af13b59c7fe0",
- "name": "Log Source Covered",
- "value": false,
- "type": "boolean"
- },
- {
- "id": "145761c0-dc2f-4f04-8d2e-ee229d8e75e7",
- "name": "Fields Covered",
- "value": false,
- "type": "boolean"
- },
- {
- "id": "9f17acd9-8ac3-45ad-a038-6d5650eef1fc",
- "name": "Coverage Notes",
- "value": "No log source found",
- "type": "string"
- }
- ]
- },
- "options": {}
- },
- "type": "n8n-nodes-base.set",
- "typeVersion": 3.4,
- "position": [
- 864,
- 944
- ],
- "id": "a42313e3-117e-4da6-8d02-a0a0fcc7b189",
- "name": "Format"
- },
- {
- "parameters": {
- "mode": "combine",
- "fieldsToMatchString": "[\"Log Source Name\"]",
- "options": {}
- },
- "type": "n8n-nodes-base.merge",
- "typeVersion": 3.2,
- "position": [
- 720,
- 704
- ],
- "id": "55108d27-0c17-4f4c-96bb-6cc45a5d1c4e",
- "name": "Merge"
- },
- {
- "parameters": {
- "jsCode": "// Normalize fields: lowercase and trimmed\nfunction normalizeFields(fields) {\n if (!fields) return [];\n return fields.split(',').map(f => f.trim().toLowerCase()).filter(f => f.length > 0);\n}\n\n// Check which required fields are covered and which are missing\nfunction checkFields(requiredFields, availableFields) {\n const availableSet = new Set(availableFields.map(f => f.toLowerCase().trim()));\n const missing = requiredFields.filter(f => !availableSet.has(f.toLowerCase().trim()));\n const allCovered = missing.length === 0;\n return { allCovered, missing };\n}\n\n// Map log source from index keywords\nconst LOG_SOURCES_INDEX = {\n \"Elastic Agent\": \"elastic_agent\",\n \"Endpoint – Elastic Agent Security\": \"endpoint_security\",\n \"Elastic Agent Filebeat\": \"filebeat\",\n \"Elastic Agent Fleet Server\": \"fleet_server\",\n \"Elastic Agent Metricbeat\": \"metricbeat\",\n \"Elastic Agent Packetbeat\": \"packetbeat\",\n \"Elastic Agent Status Change\": \"status_change\",\n \"Endpoint – Events File\": \"endpoint.events.file\",\n \"Endpoint – Events Library\": \"endpoint.events.library\",\n \"Endpoint – Events Network\": \"endpoint.events.network\",\n \"Endpoint – Events Process\": \"endpoint.events.process\",\n \"Endpoint – Events Registry\": \"endpoint.events.registry\",\n \"Network Traffic DHCPv4\": \"network_traffic.dhcpv4\",\n \"Network Traffic DNS\": \"network_traffic.dns\",\n \"Network Traffic Flow\": \"network_traffic.flow\",\n \"Network Traffic HTTP\": \"network_traffic.http\",\n \"Network Traffic ICMP\": \"network_traffic.icmp\",\n \"Network Traffic TLS\": \"network_traffic.tls\",\n \"System Application\": \"system.application\",\n \"System Security\": \"system.security\",\n \"System System\": \"system.system\",\n \"Windows PowerShell\": \"windows.powershell\",\n \"Windows PowerShell Operational\": \"windows.powershell_operational\",\n \"Windows Sysmon Operational\": \"windows.sysmon_operational\",\n \"Windows Windows Defender\": \"windows.windows_defender\",\n \"Winlog Winlog\": \"winlog.winlog\"\n};\n\n// Detect log source from rule index\nfunction detectLogSource(ruleIndex) {\n if (!ruleIndex) return \"No log source\";\n const indices = ruleIndex.split(\",\").map(i => i.trim().toLowerCase());\n for (const idx of indices) {\n for (const [source, keyword] of Object.entries(LOG_SOURCES_INDEX)) {\n if (idx.includes(keyword)) {\n return source;\n }\n }\n }\n return \"No log source\";\n}\n\nconst output = [];\n\nfor (const item of $input.all()) {\n const rule = item.json;\n\n const detectedLogSource = detectLogSource(rule[\"Rule Index\"]);\n const logSourceCovered = detectedLogSource !== \"No log source\";\n\n const availableFields = normalizeFields(rule[\"Fields Available\"]);\n const requiredFields = normalizeFields(rule[\"Required Fields\"]);\n\n const { allCovered, missing } = checkFields(requiredFields, availableFields);\n\n // Decide Coverage Notes\n let coverageNotes = \"\";\n if (!logSourceCovered && !allCovered) coverageNotes = \"No log source found and missing required fields\";\n else if (!logSourceCovered) coverageNotes = \"No log source found\";\n else if (!allCovered) coverageNotes = `Missing required fields: ${missing.join(', ')}`;\n else coverageNotes = \"All fields present\";\n\n output.push({\n json: {\n \"Rule Name\": rule[\"Rule Name\"],\n \"Log Source Covered\": logSourceCovered,\n \"Fields Covered\": allCovered,\n \"Coverage Notes\": coverageNotes\n }\n });\n}\n\nreturn output;\n"
- },
- "type": "n8n-nodes-base.code",
- "typeVersion": 2,
- "position": [
- 928,
- 704
- ],
- "id": "7c30b6f2-cf04-40e6-8699-499d2cf45138",
- "name": "Updating code"
- },
- {
- "parameters": {
- "rules": {
- "values": [
- {
- "conditions": {
- "options": {
- "caseSensitive": true,
- "leftValue": "",
- "typeValidation": "strict",
- "version": 3
- },
- "conditions": [
- {
- "leftValue": "={{ $json[\"Log Source Name\"] }}",
- "rightValue": "No log source",
- "operator": {
- "type": "string",
- "operation": "notEquals"
- },
- "id": "34a2c78a-eb95-4619-893a-d4c6f6376e9b"
- }
- ],
- "combinator": "and"
- },
- "renameOutput": true,
- "outputKey": "Has Log Source "
- },
- {
- "conditions": {
- "options": {
- "caseSensitive": true,
- "leftValue": "",
- "typeValidation": "strict",
- "version": 3
- },
- "conditions": [
- {
- "id": "3115bb9c-e13c-46df-bf41-2409ea2e87d5",
- "leftValue": "={{ $json[\"Log Source Name\"] }}",
- "rightValue": "No log source",
- "operator": {
- "type": "string",
- "operation": "equals"
- }
- }
- ],
- "combinator": "and"
- },
- "renameOutput": true,
- "outputKey": "No Log Source"
- }
- ]
- },
- "options": {}
- },
- "type": "n8n-nodes-base.switch",
- "typeVersion": 3.4,
- "position": [
- 464,
- 816
- ],
- "id": "9a315c16-dd45-40a5-9be6-307aaa10889b",
- "name": "Log source check"
- },
- {
- "parameters": {
- "url": "https://208.73.204.77:9200/_data_stream",
- "authentication": "genericCredentialType",
- "genericAuthType": "httpBasicAuth",
- "options": {
- "allowUnauthorizedCerts": true
- }
- },
- "type": "n8n-nodes-base.httpRequest",
- "typeVersion": 4.3,
- "position": [
- -528,
- 608
- ],
- "id": "f3ce8264-eee5-4d49-857e-0d0a80eacb43",
- "name": "Get Data Streams1",
- "credentials": {
- "httpBasicAuth": {
- "id": "k42XGGNE51AgavbK",
- "name": "Elastic OJT creds"
- }
- }
- },
- {
- "parameters": {
- "operation": "appendOrUpdate",
- "documentId": {
- "__rl": true,
- "value": "10KcsY87LIDqYkh__e0TUK7tLMszijuiMP70ji9wNZjs",
- "mode": "list",
- "cachedResultName": "Automated Detection Coverage - Shehab",
- "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10KcsY87LIDqYkh__e0TUK7tLMszijuiMP70ji9wNZjs/edit?usp=drivesdk"
- },
- "sheetName": {
- "__rl": true,
- "value": "gid=0",
- "mode": "list",
- "cachedResultName": "Rules Sheet",
- "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10KcsY87LIDqYkh__e0TUK7tLMszijuiMP70ji9wNZjs/edit#gid=0"
- },
- "columns": {
- "mappingMode": "autoMapInputData",
- "value": {
- "Log Source Covered": "={{ $json[\"Log Source Covered\"] }}",
- "Fields Covered": "={{ $json[\"Fields Covered\"] }}",
- "Coverage Notes": "={{ $json[\"Coverage Notes\"] }}",
- "Rule Name": "={{ $json[\"Rule Name\"] }}"
- },
- "matchingColumns": [
- "Rule Name"
- ],
- "schema": [
- {
- "id": "Rule ID",
- "displayName": "Rule ID",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true
- },
- {
- "id": "Rule Name",
- "displayName": "Rule Name",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true,
- "removed": false
- },
- {
- "id": "Rule Query",
- "displayName": "Rule Query",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true
- },
- {
- "id": "Rule Index",
- "displayName": "Rule Index",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true
- },
- {
- "id": "MITRE Technique",
- "displayName": "MITRE Technique",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true
- },
- {
- "id": "Mapping Method",
- "displayName": "Mapping Method",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true
- },
- {
- "id": "Mapping Rationale",
- "displayName": "Mapping Rationale",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true
- },
- {
- "id": "Required Fields",
- "displayName": "Required Fields",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true
- },
- {
- "id": "Log Source Covered",
- "displayName": "Log Source Covered",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true
- },
- {
- "id": "Fields Covered",
- "displayName": "Fields Covered",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true
- },
- {
- "id": "Coverage Notes",
- "displayName": "Coverage Notes",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true
- },
- {
- "id": "Reviewed By",
- "displayName": "Reviewed By",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true
- }
- ],
- "attemptToConvertTypes": false,
- "convertFieldsToString": false
- },
- "options": {}
- },
- "type": "n8n-nodes-base.googleSheets",
- "typeVersion": 4.7,
- "position": [
- 1376,
- 752
- ],
- "id": "09121a9f-40e6-4b40-a0de-3708f743c2e9",
- "name": "Update Rules Table1",
- "credentials": {
- "googleSheetsOAuth2Api": {
- "id": "Ij6ijI3slM4jU3nJ",
- "name": "Google Sheets account"
- }
- }
- },
- {
- "parameters": {
- "jsCode": "const LOG_SOURCES_INDEX = {\n \"Elastic Agent\": \"elastic_agent\",\n \"Endpoint – Elastic Agent Security\": \"endpoint_security\",\n \"Elastic Agent Filebeat\": \"filebeat\",\n \"Elastic Agent Fleet Server\": \"fleet_server\",\n \"Elastic Agent Metricbeat\": \"metricbeat\",\n \"Elastic Agent Packetbeat\": \"packetbeat\",\n \"Elastic Agent Status Change\": \"status_change\",\n \"Endpoint – Events File\": \"endpoint.events.file\",\n \"Endpoint – Events Library\": \"endpoint.events.library\",\n \"Endpoint – Events Network\": \"endpoint.events.network\",\n \"Endpoint – Events Process\": \"endpoint.events.process\",\n \"Endpoint – Events Registry\": \"endpoint.events.registry\",\n \"Network Traffic DHCPv4\": \"network_traffic.dhcpv4\",\n \"Network Traffic DNS\": \"network_traffic.dns\",\n \"Network Traffic Flow\": \"network_traffic.flow\",\n \"Network Traffic HTTP\": \"network_traffic.http\",\n \"Network Traffic ICMP\": \"network_traffic.icmp\",\n \"Network Traffic TLS\": \"network_traffic.tls\",\n \"System Application\": \"system.application\",\n \"System Security\": \"system.security\",\n \"System System\": \"system.system\",\n \"Windows PowerShell\": \"windows.powershell\",\n \"Windows PowerShell Operational\": \"windows.powershell_operational\",\n \"Windows Sysmon Operational\": \"windows.sysmon_operational\",\n \"Windows Windows Defender\": \"windows.windows_defender\",\n \"Winlog Winlog\": \"winlog.winlog\"\n};\n\nfunction detectLogSource(ruleIndex) {\n if (!ruleIndex) return \"No log source\";\n\n const indices = ruleIndex.split(\",\").map(i => i.trim().toLowerCase());\n\n for (const idx of indices) {\n for (const [source, keyword] of Object.entries(LOG_SOURCES_INDEX)) {\n if (idx.includes(keyword)) {\n return source;\n }\n }\n }\n\n return \"No log source\";\n}\n\nconst output = items.map(item => {\n return {\n json: {\n ...item.json,\n \"Log Source Name\": detectLogSource(item.json[\"Rule Index\"])\n }\n };\n});\n\nreturn output;\n"
- },
- "type": "n8n-nodes-base.code",
- "typeVersion": 2,
- "position": [
- 240,
- 816
- ],
- "id": "9e25af2c-8eb2-4039-bfa0-dd5b9bba6797",
- "name": "Maps rules to logsources1"
- },
- {
- "parameters": {
- "conditions": {
- "options": {
- "caseSensitive": true,
- "leftValue": "",
- "typeValidation": "strict",
- "version": 3
- },
- "conditions": [
- {
- "id": "f324a282-8eb6-4d1d-ad20-95891245ebf2",
- "leftValue": "={{ $json.data_streams.name }}",
- "rightValue": "metrics",
- "operator": {
- "type": "string",
- "operation": "notContains"
- }
- },
- {
- "id": "f60429b7-da25-4861-90f7-6ae1408f1085",
- "leftValue": "={{ $json.data_streams.name }}",
- "rightValue": ".",
- "operator": {
- "type": "string",
- "operation": "notStartsWith"
- }
- }
- ],
- "combinator": "and"
- },
- "options": {}
- },
- "type": "n8n-nodes-base.filter",
- "typeVersion": 2.3,
- "position": [
- -80,
- 608
- ],
- "id": "370d2d3a-b5e4-427c-b190-7f04352a469a",
- "name": "Filter1"
- },
- {
- "parameters": {
- "rule": {
- "interval": [
- {
- "field": "seconds",
- "secondsInterval": 5
- }
- ]
- }
- },
- "type": "n8n-nodes-base.scheduleTrigger",
- "typeVersion": 1.3,
- "position": [
- -752,
- 704
- ],
- "id": "e1407bde-967d-4d47-8fde-3bd15b59c9f7",
- "name": "Trigger B1"
- },
- {
- "parameters": {
- "fieldToSplitOut": "data_streams",
- "include": "allOtherFields",
- "options": {}
- },
- "type": "n8n-nodes-base.splitOut",
- "typeVersion": 1,
- "position": [
- -304,
- 608
- ],
- "id": "eab87c8b-4223-4e3c-9590-dda7c08223cc",
- "name": "Split Out "
- },
- {
- "parameters": {
- "operation": "appendOrUpdate",
- "documentId": {
- "__rl": true,
- "value": "10KcsY87LIDqYkh__e0TUK7tLMszijuiMP70ji9wNZjs",
- "mode": "list",
- "cachedResultName": "Automated Detection Coverage - Shehab",
- "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10KcsY87LIDqYkh__e0TUK7tLMszijuiMP70ji9wNZjs/edit?usp=drivesdk"
- },
- "sheetName": {
- "__rl": true,
- "value": 706068663,
- "mode": "list",
- "cachedResultName": "LogSourceTable",
- "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10KcsY87LIDqYkh__e0TUK7tLMszijuiMP70ji9wNZjs/edit#gid=706068663"
- },
- "columns": {
- "mappingMode": "autoMapInputData",
- "value": {},
- "matchingColumns": [
- "Log Source Name"
- ],
- "schema": [
- {
- "id": "Log Source Name",
- "displayName": "Log Source Name",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true,
- "removed": false
- },
- {
- "id": "Index / Data Stream",
- "displayName": "Index / Data Stream",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true
- },
- {
- "id": "Fields Available",
- "displayName": "Fields Available",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true
- },
- {
- "id": "Parsing Status",
- "displayName": "Parsing Status",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true
- },
- {
- "id": "Last Updated",
- "displayName": "Last Updated",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true
- }
- ],
- "attemptToConvertTypes": false,
- "convertFieldsToString": false
- },
- "options": {}
- },
- "type": "n8n-nodes-base.googleSheets",
- "typeVersion": 4.7,
- "position": [
- 816,
- 528
- ],
- "id": "16ae6a83-70b0-4c86-a72c-a7e3a8d3d64d",
- "name": "LogSource Table1",
- "credentials": {
- "googleSheetsOAuth2Api": {
- "id": "Ij6ijI3slM4jU3nJ",
- "name": "Google Sheets account"
- }
- }
- },
- {
- "parameters": {
- "documentId": {
- "__rl": true,
- "value": "10KcsY87LIDqYkh__e0TUK7tLMszijuiMP70ji9wNZjs",
- "mode": "list",
- "cachedResultName": "Automated Detection Coverage - Shehab",
- "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10KcsY87LIDqYkh__e0TUK7tLMszijuiMP70ji9wNZjs/edit?usp=drivesdk"
- },
- "sheetName": {
- "__rl": true,
- "value": "gid=0",
- "mode": "list",
- "cachedResultName": "Rules Sheet",
- "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10KcsY87LIDqYkh__e0TUK7tLMszijuiMP70ji9wNZjs/edit#gid=0"
- },
- "options": {}
- },
- "type": "n8n-nodes-base.googleSheets",
- "typeVersion": 4.7,
- "position": [
- -400,
- 896
- ],
- "id": "3affc445-15b4-48c2-a437-06e2aa51c3a4",
- "name": "Get Rules Rows1",
- "credentials": {
- "googleSheetsOAuth2Api": {
- "id": "Ij6ijI3slM4jU3nJ",
- "name": "Google Sheets account"
- }
- }
- },
- {
- "parameters": {
- "jsCode": "const rows = [];\n\n/**\n * Flatten Elasticsearch mapping fields\n */\nfunction getFlatKeys(obj, prefix = '') {\n let keys = [];\n\n for (const key in obj) {\n if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;\n const val = obj[key];\n\n if (key === 'properties' && typeof val === 'object') {\n keys.push(...getFlatKeys(val, prefix));\n continue;\n }\n\n if (typeof val === 'object' && val !== null && val.properties) {\n const newPrefix = prefix ? `${prefix}.${key}` : key;\n keys.push(...getFlatKeys(val, newPrefix));\n continue;\n }\n\n if (key !== 'type') {\n const fullPath = prefix ? `${prefix}.${key}` : key;\n if (!fullPath.startsWith('_')) {\n keys.push(fullPath);\n }\n }\n }\n\n return keys;\n}\n\n/**\n * Convert backing index name into SOC-friendly log source name\n */\nfunction formatLogSourceName(indexName) {\n let name = indexName;\n\n // Remove backing index markers and lifecycle noise\n name = name\n .replace(/^\\.ds-/, '')\n .replace(/^logs-/, '')\n .replace(/-default.*$/, '');\n\n // Split hierarchy\n const parts = name.split(/[._]/);\n\n const dictionary = {\n elastic: 'Elastic',\n elasticagent: 'Elastic Agent',\n agent: 'Agent',\n endpoint: 'Endpoint',\n events: 'Events',\n security: 'Security',\n file: 'File',\n process: 'Process',\n network: 'Network',\n registry: 'Registry',\n library: 'Library',\n windows: 'Windows',\n powershell: 'PowerShell',\n sysmon: 'Sysmon',\n defender: 'Defender',\n winlog: 'Winlog',\n system: 'System',\n application: 'Application',\n dns: 'DNS',\n dhcpv4: 'DHCPv4',\n tls: 'TLS',\n icmp: 'ICMP',\n http: 'HTTP',\n flow: 'Flow',\n metricbeat: 'Metricbeat',\n packetbeat: 'Packetbeat',\n filebeat: 'Filebeat',\n fleet: 'Fleet',\n server: 'Server',\n status: 'Status',\n change: 'Change'\n };\n\n const words = parts.map(p => {\n const clean = p.toLowerCase().replace(/[^a-z0-9]/g, '');\n return dictionary[clean] || clean.charAt(0).toUpperCase() + clean.slice(1);\n });\n\n // Build readable structure\n if (words.includes('Elastic Agent')) {\n const rest = words.filter(w => w !== 'Elastic Agent');\n return `Elastic Agent – ${rest.join(' ')}`;\n }\n\n if (words.includes('Endpoint')) {\n return `Endpoint – ${words.filter(w => w !== 'Endpoint').join(' ')}`;\n }\n\n return words.join(' ');\n}\n\nfor (const item of $input.all()) {\n const indexName = Object.keys(item.json)[0];\n const mappingData = item.json[indexName];\n\n if (!mappingData || !mappingData.mappings) continue;\n\n const fields = [...new Set(getFlatKeys(mappingData.mappings))].sort();\n\n rows.push({\n json: {\n \"Log Source Name\": formatLogSourceName(indexName),\n \"Index / Data Stream\": indexName,\n \"Fields Available\": fields.join(','),\n \"Parsing Status\": fields.length ? \"Good\" : \"Broken\",\n \"Last Updated\": new Date().toISOString().slice(0, 10)\n }\n });\n}\n\nreturn rows;\n"
- },
- "type": "n8n-nodes-base.code",
- "typeVersion": 2,
- "position": [
- 368,
- 608
- ],
- "id": "5d1707eb-17c4-4640-b856-48c4acd467dc",
- "name": "Reformating1"
- },
- {
- "parameters": {
- "url": "=https://208.73.204.77:9200/{{ $json.data_streams.name }}/_mapping",
- "authentication": "genericCredentialType",
- "genericAuthType": "httpBasicAuth",
- "options": {
- "allowUnauthorizedCerts": true
- }
- },
- "type": "n8n-nodes-base.httpRequest",
- "typeVersion": 4.3,
- "position": [
- 144,
- 608
- ],
- "id": "3f0b418a-068d-4ea3-bb2e-effaaf49a81b",
- "name": "Data stream mapping1",
- "credentials": {
- "httpBasicAuth": {
- "id": "k42XGGNE51AgavbK",
- "name": "Elastic OJT creds"
- }
- }
- },
- {
- "parameters": {
- "assignments": {
- "assignments": [
- {
- "id": "76a82a4e-3d5b-4f25-86e8-3399d4629113",
- "name": "Rule Name",
- "value": "={{ $json[\"Rule Name\"] }}",
- "type": "string"
- },
- {
- "id": "50292156-41c0-4d56-8bcd-2b4deb9c3b84",
- "name": "Rule Index",
- "value": "={{ $json[\"Rule Index\"] }}",
- "type": "string"
- },
- {
- "id": "4f25113b-0798-4b55-a318-ddd384b8018a",
- "name": "Required Fields",
- "value": "={{ $json[\"Required Fields\"] }}",
- "type": "string"
- }
- ]
- },
- "options": {}
- },
- "type": "n8n-nodes-base.set",
- "typeVersion": 3.4,
- "position": [
- 0,
- 832
- ],
- "id": "ba8758a0-edfe-40ad-9545-35a9b7008745",
- "name": "Edit Fields1"
- },
- {
- "parameters": {
- "operation": "appendOrUpdate",
- "documentId": {
- "__rl": true,
- "value": "10KcsY87LIDqYkh__e0TUK7tLMszijuiMP70ji9wNZjs",
- "mode": "list",
- "cachedResultName": "Automated Detection Coverage - Shehab",
- "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10KcsY87LIDqYkh__e0TUK7tLMszijuiMP70ji9wNZjs/edit?usp=drivesdk"
- },
- "sheetName": {
- "__rl": true,
- "value": 618184922,
- "mode": "list",
- "cachedResultName": "Summary Exclusions",
- "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10KcsY87LIDqYkh__e0TUK7tLMszijuiMP70ji9wNZjs/edit#gid=618184922"
- },
- "columns": {
- "mappingMode": "autoMapInputData",
- "value": {},
- "matchingColumns": [
- "Rule ID"
- ],
- "schema": [
- {
- "id": "Rule ID",
- "displayName": "Rule ID",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true,
- "removed": false
- },
- {
- "id": "Rule Name",
- "displayName": "Rule Name",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true
- },
- {
- "id": "Exclusion Reason",
- "displayName": "Exclusion Reason",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true
- },
- {
- "id": "Reviewed By",
- "displayName": "Reviewed By",
- "required": false,
- "defaultMatch": false,
- "display": true,
- "type": "string",
- "canBeUsedToMatch": true
- }
- ],
- "attemptToConvertTypes": false,
- "convertFieldsToString": false
- },
- "options": {}
- },
- "type": "n8n-nodes-base.googleSheets",
- "typeVersion": 4.7,
- "position": [
- 1568,
- 912
- ],
- "id": "af1bd14d-620b-43fd-8980-7da8c2edd4ce",
- "name": "Summary Table",
- "credentials": {
- "googleSheetsOAuth2Api": {
- "id": "Ij6ijI3slM4jU3nJ",
- "name": "Google Sheets account"
- }
- }
- },
- {
- "parameters": {
- "content": "## Trigger B",
- "height": 720,
- "width": 2576,
- "color": 6
- },
- "type": "n8n-nodes-base.stickyNote",
- "typeVersion": 1,
- "position": [
- -880,
- 512
- ],
- "id": "c4a37485-cb6a-4412-95ed-222d9361074b",
- "name": "Sticky Note"
- },
- {
- "parameters": {
- "sortFieldsUi": {
- "sortField": [
- {
- "fieldName": "Exclusion Reason"
- }
- ]
- },
- "options": {}
- },
- "type": "n8n-nodes-base.sort",
- "typeVersion": 1,
- "position": [
- 1360,
- 1024
- ],
- "id": "2f8a2ac3-51b0-4357-9fc9-81cb43d272f5",
- "name": "Sort1"
- }
- ],
- "connections": {
- "Trigger A": {
- "main": [
- [
- {
- "node": "Get Rules",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "MITRE Exist": {
- "main": [
- [
- {
- "node": "Reformat 1",
- "type": "main",
- "index": 0
- }
- ],
- [
- {
- "node": "Aggregate",
- "type": "main",
- "index": 0
- },
- {
- "node": "Merge 1",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Aggregate": {
- "main": [
- [
- {
- "node": "Map to MITRE Agent",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Simple Memory": {
- "ai_memory": [
- [
- {
- "node": "Map to MITRE Agent",
- "type": "ai_memory",
- "index": 0
- }
- ]
- ]
- },
- "Map to MITRE Agent": {
- "main": [
- [
- {
- "node": "Parse AI output",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Parse AI output": {
- "main": [
- [
- {
- "node": "Merge 1",
- "type": "main",
- "index": 1
- }
- ]
- ]
- },
- "Google Gemini": {
- "ai_languageModel": [
- [
- {
- "node": "Map to MITRE Agent",
- "type": "ai_languageModel",
- "index": 0
- }
- ]
- ]
- },
- "Merge 2": {
- "main": [
- [
- {
- "node": "MITRE Coverage Sheet",
- "type": "main",
- "index": 0
- },
- {
- "node": "Rules Sheet",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Merge 1": {
- "main": [
- [
- {
- "node": "Reformat 2",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Reformat 1": {
- "main": [
- [
- {
- "node": "Merge 2",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Reformat 2": {
- "main": [
- [
- {
- "node": "Merge 2",
- "type": "main",
- "index": 1
- }
- ]
- ]
- },
- "Important Fields For LLM": {
- "main": [
- [
- {
- "node": "MITRE Exist",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Get Rules": {
- "main": [
- [
- {
- "node": "Split Out 1",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Filter Enabled Rules": {
- "main": [
- [
- {
- "node": "Important Fields For LLM",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Split Out 1": {
- "main": [
- [
- {
- "node": "Filter Enabled Rules",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "MITRE Coverage Sheet": {
- "main": [
- [
- {
- "node": "Sort",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Rules Sheet": {
- "main": [
- [
- {
- "node": "Rules Table",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Sort": {
- "main": [
- [
- {
- "node": "MITRE Coverage Table",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Format 2": {
- "main": [
- [
- {
- "node": "Sort1",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Format": {
- "main": [
- [
- {
- "node": "Update Rules Table1",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Merge": {
- "main": [
- [
- {
- "node": "Updating code",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Updating code": {
- "main": [
- [
- {
- "node": "Format 2",
- "type": "main",
- "index": 0
- },
- {
- "node": "Update Rules Table1",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Log source check": {
- "main": [
- [
- {
- "node": "Merge",
- "type": "main",
- "index": 1
- }
- ],
- [
- {
- "node": "Format",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Get Data Streams1": {
- "main": [
- [
- {
- "node": "Split Out ",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Maps rules to logsources1": {
- "main": [
- [
- {
- "node": "Log source check",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Filter1": {
- "main": [
- [
- {
- "node": "Data stream mapping1",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Trigger B1": {
- "main": [
- [
- {
- "node": "Get Data Streams1",
- "type": "main",
- "index": 0
- },
- {
- "node": "Get Rules Rows1",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Split Out ": {
- "main": [
- [
- {
- "node": "Filter1",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Get Rules Rows1": {
- "main": [
- [
- {
- "node": "Format 2",
- "type": "main",
- "index": 0
- },
- {
- "node": "Edit Fields1",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Reformating1": {
- "main": [
- [
- {
- "node": "LogSource Table1",
- "type": "main",
- "index": 0
- },
- {
- "node": "Merge",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Data stream mapping1": {
- "main": [
- [
- {
- "node": "Reformating1",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Edit Fields1": {
- "main": [
- [
- {
- "node": "Maps rules to logsources1",
- "type": "main",
- "index": 0
- }
- ]
- ]
- },
- "Sort1": {
- "main": [
- [
- {
- "node": "Summary Table",
- "type": "main",
- "index": 0
- }
- ]
- ]
- }
- },
- "pinData": {},
- "meta": {
- "templateCredsSetupCompleted": true,
- "instanceId": "5b5c49feff61a1791b94945a856f2e513b70f058a7d673ff4fd15e9381c9e076"
- }
- }
Add Comment
Please, Sign In to add comment