[fix] Preserve actions[].params.message field formatting during rule export from the repo (#5597)

* Preserve `message` field formatting

* Note the JSON path explicitely in the comment

* version bump fix

(cherry picked from commit 5b092d7831)
This commit is contained in:
Sergey Polzunov
2026-01-26 13:04:36 +01:00
committed by tradebot-elastic
parent ca57e721de
commit b5a42e50f7
2 changed files with 10 additions and 1 deletions
+9
View File
@@ -24,6 +24,12 @@ DQ = '"'
TRIPLE_SQ = SQ * 3
TRIPLE_DQ = DQ * 3
# Fields from nested objects (not BaseRuleData fields) that need to be perserved.
# NOTE: we treat these as globally unique which might not be true in all cases
# Excluded fields:
# - actions[].params.message
NESTED_PRESERVED_FIELD_NAMES: set[str] = {"message"}
@cached
def get_preserved_fmt_fields() -> set[str]:
@@ -34,6 +40,9 @@ def get_preserved_fmt_fields() -> set[str]:
for field in dataclasses.fields(BaseRuleData):
if field.type in (definitions.Markdown, definitions.Markdown | None):
preserved_keys.add(field.metadata.get("data_key", field.name))
preserved_keys.update(NESTED_PRESERVED_FIELD_NAMES)
return preserved_keys
+1 -1
View File
@@ -1,6 +1,6 @@
[project]
name = "detection_rules"
version = "1.5.30"
version = "1.5.31"
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 Securitys Detection Engine."
readme = "README.md"
requires-python = ">=3.12"