Skip to content

Commit 04e1fc1

Browse files
Account for CCS '::' index pattern (#4258)
1 parent ebb3675 commit 04e1fc1

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

detection_rules/beats.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,11 @@ def parse_beats_from_index(index: Optional[list]) -> List[str]:
288288
"""Parse beats schema types from index."""
289289
indexes = index or []
290290
beat_types = []
291-
# Need to split on : to support cross-cluster search
291+
# Need to split on : or :: to support cross-cluster search
292292
# e.g. mycluster:logs-* -> logs-*
293293
for index in indexes:
294294
if "beat-*" in index:
295-
index_parts = index.split(':', 1)
295+
index_parts = index.replace('::', ':').split(':', 1)
296296
last_part = index_parts[-1]
297297
beat_type = last_part.split("-")[0]
298298
beat_types.append(beat_type)

detection_rules/ecs.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def get_custom_index_schema(index_name: str, stack_version: str = None):
187187
"""Load custom schema."""
188188
custom_schemas = get_custom_schemas(stack_version)
189189
index_schema = custom_schemas.get(index_name, {})
190-
ccs_schema = custom_schemas.get(index_name.split(":", 1)[-1], {})
190+
ccs_schema = custom_schemas.get(index_name.replace('::', ':').split(":", 1)[-1], {})
191191
index_schema.update(ccs_schema)
192192
return index_schema
193193

@@ -197,7 +197,7 @@ def get_index_schema(index_name):
197197
"""Load non-ecs schema."""
198198
non_ecs_schema = get_non_ecs_schema()
199199
index_schema = non_ecs_schema.get(index_name, {})
200-
ccs_schema = non_ecs_schema.get(index_name.split(":", 1)[-1], {})
200+
ccs_schema = non_ecs_schema.get(index_name.replace('::', ':').split(":", 1)[-1], {})
201201
index_schema.update(ccs_schema)
202202
return index_schema
203203

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "detection_rules"
3-
version = "0.1.7"
3+
version = "0.2.0"
44
description = "Detection Rules is the home for rules used by Elastic Security. This repository is used for the development, maintenance, testing, validation, and release of rules for Elastic Security’s Detection Engine."
55
readme = "README.md"
66
requires-python = ">=3.12"

0 commit comments

Comments
 (0)