Skip to content

Commit 9574413

Browse files
committed
Merge branch 'main' of https://github.com/SigmaHQ/pySigma-backend-splunk into main
2 parents 229a4fd + f796858 commit 9574413

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

sigma/backends/splunk/splunk.py

+2
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,11 @@ def convert_condition_field_eq_val_cidr(self, cond : ConditionFieldEqualsValueEx
9595

9696
def finalize_query_savedsearches(self, rule: SigmaRule, query: str, index: int, state: ConversionState) -> str:
9797
clean_title = rule.title.translate({ord(c): None for c in "[]"}) # remove brackets from title
98+
escaped_description = "\\\n".join(rule.description.strip().split("\n")) if rule.description else "" # support multi-line descriptions
9899
escaped_query = " \\\n".join(query.split("\n")) # escape line ends for multiline queries
99100
return f"""
100101
[{clean_title}]
102+
description = {escaped_description}
101103
search = {escaped_query}"""
102104

103105
def finalize_output_savedsearches(self, queries: List[str]) -> str:

tests/test_backend_splunk.py

+6
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,9 @@ def test_splunk_cidr_or(splunk_backend : SplunkBackend):
220220
def test_splunk_savedsearch_output(splunk_backend : SplunkBackend):
221221
rules = """
222222
title: Test 1
223+
description: |
224+
this is a description
225+
across two lines
223226
status: test
224227
logsource:
225228
category: test_category
@@ -248,10 +251,13 @@ def test_splunk_savedsearch_output(splunk_backend : SplunkBackend):
248251
dispatch.latest_time = now
249252
250253
[Test 1]
254+
description = this is a description\\
255+
across two lines
251256
search = fieldB="foo" fieldC="bar" \\
252257
| regex fieldA="foo.*bar"
253258
254259
[Test 2]
260+
description =
255261
search = fieldA="foo" fieldB="bar\""""
256262

257263
def test_splunk_data_model_process_creation():

0 commit comments

Comments
 (0)