Skip to content

Commit dfd54ab

Browse files
authored
Merge pull request #48 from SigmaHQ/field-existence
Field (non)existence check expression
2 parents 31f850a + 93ad69c commit dfd54ab

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

sigma/backends/splunk/splunk.py

+2
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ class SplunkBackend(TextQueryBackend):
157157
field_in_list_expression: ClassVar[str] = "{field} {op} ({list})"
158158
or_in_operator: ClassVar[Optional[str]] = "IN"
159159
list_separator: ClassVar[str] = ", "
160+
field_exists_expression: ClassVar[str] = "{field}=*"
161+
field_not_exists_expression: ClassVar[str] = "NOT {field}=*"
160162

161163
unbound_value_str_expression: ClassVar[str] = "{value}"
162164
unbound_value_num_expression: ClassVar[str] = "{value}"

tests/test_backend_splunk.py

+21
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,27 @@ def test_splunk_fieldref_or(splunk_backend: SplunkBackend):
376376
)
377377
)
378378

379+
def test_splunk_exists(splunk_backend: SplunkBackend):
380+
assert (
381+
splunk_backend.convert(
382+
SigmaCollection.from_yaml(
383+
"""
384+
title: Test
385+
status: test
386+
logsource:
387+
category: test_category
388+
product: test_product
389+
detection:
390+
sel:
391+
fieldA|exists: yes
392+
fieldB|exists: no
393+
condition: sel
394+
"""
395+
)
396+
)
397+
== ['fieldA=* NOT fieldB=*']
398+
)
399+
379400

380401
def test_splunk_fields_output(splunk_backend: SplunkBackend):
381402
rule = SigmaCollection.from_yaml(

0 commit comments

Comments
 (0)