diff --git a/detection_rules/rule_formatter.py b/detection_rules/rule_formatter.py index c1fa33ac0..8bbab6409 100644 --- a/detection_rules/rule_formatter.py +++ b/detection_rules/rule_formatter.py @@ -216,6 +216,11 @@ def toml_write(rule_contents, outfile=None): preserved_fields = ["params.message"] v = [preserve_formatting_for_fields(action, preserved_fields) for action in v] + if k == 'note' and isinstance(v, str): + # Transform instances of \ to \\ as calling write will convert \\ to \. + # This will ensure that the output file has the correct number of backslashes. + v = v.replace("\\", "\\\\") + if isinstance(v, dict): bottom[k] = OrderedDict(sorted(v.items())) elif isinstance(v, list):