{ "template": { "mappings": { "properties": { "so_audit_doc_id": { "ignore_above": 1024, "type": "keyword" }, "@timestamp": { "type": "date" }, "so_kind": { "ignore_above": 1024, "type": "keyword" }, "so_operation": { "ignore_above": 1024, "type": "keyword" }, "so_detection": { "properties": { "publicId": { "ignore_above": 1024, "type": "keyword" }, "title": { "ignore_above": 1024, "type": "keyword" }, "severity": { "ignore_above": 1024, "type": "keyword" }, "author": { "ignore_above": 1024, "type": "keyword" }, "description": { "type": "text" }, "category": { "ignore_above": 1024, "type": "keyword" }, "product": { "ignore_above": 1024, "type": "keyword" }, "service": { "ignore_above": 1024, "type": "keyword" }, "content": { "type": "text" }, "isEnabled": { "type": "boolean" }, "isReporting": { "type": "boolean" }, "isCommunity": { "type": "boolean" }, "tags": { "ignore_above": 1024, "type": "keyword" }, "ruleset": { "ignore_above": 1024, "type": "keyword" }, "engine": { "ignore_above": 1024, "type": "keyword" }, "language": { "ignore_above": 1024, "type": "keyword" }, "license": { "ignore_above": 1024, "type": "keyword" }, "sourceCreated": { "type": "date" }, "sourceUpdated": { "type": "date" }, "overrides": { "properties": { "type": { "ignore_above": 1024, "type": "keyword" }, "isEnabled": { "type": "boolean" }, "createdAt": { "type": "date" }, "updatedAt": { "type": "date" }, "note": { "type": "text" }, "regex": { "type": "text" }, "value": { "type": "text" }, "thresholdType": { "ignore_above": 1024, "type": "keyword" }, "track": { "ignore_above": 1024, "type": "keyword" }, "ip": { "type": "text" }, "count": { "type": "long" }, "seconds": { "type": "long" }, "customFilter": { "type": "text" } } } } }, "so_detectioncomment": { "properties": { "createTime": { "type": "date" }, "detectionId": { "ignore_above": 1024, "type": "keyword" }, "value": { "type": "text" }, "userId": { "ignore_above": 1024, "type": "keyword" } } } }, "runtime": { "so_detection.sigmaKind": { "type": "keyword", "script": { "source": "if (doc['so_detection.language'].size() == 0 || doc['so_detection.language'].value != 'sigma') { return; } def d = params._source.so_detection; if (d == null || d.content == null) { return; } String c = d.content; String NL = String.valueOf((char) 10); emit(c.startsWith('correlation:') || c.contains(NL + 'correlation:') ? 'correlation' : 'single');" } }, "so_detection.sigmaCorrelationType": { "type": "keyword", "script": { "source": "if (doc['so_detection.language'].size() == 0 || doc['so_detection.language'].value != 'sigma') { return; } def d = params._source.so_detection; if (d == null || d.content == null) { return; } String c = d.content; String NL = String.valueOf((char) 10); int i = c.startsWith('correlation:') ? 0 : c.indexOf(NL + 'correlation:'); if (i < 0) { return; } i = c.indexOf(NL, i + 1); while (i >= 0 && i + 1 < c.length()) { int e = c.indexOf(NL, i + 1); String line = e < 0 ? c.substring(i + 1) : c.substring(i + 1, e); if (line.length() > 0 && !Character.isWhitespace(line.charAt(0)) && line.charAt(0) != (char) 35) { return; } String t = line.trim(); if (t.startsWith('type:')) { String v = t.substring(5).trim(); int h = v.indexOf(' ' + String.valueOf((char) 35)); if (h >= 0) { v = v.substring(0, h).trim(); } if (v.length() > 1 && (v.charAt(0) == (char) 39 || v.charAt(0) == (char) 34)) { v = v.substring(1, v.length() - 1); } emit(v); return; } i = e; }" } } } } }, "_meta": { "ecs_version": "1.12.2" } }