Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Field (non)existence check expression #48

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sigma/backends/splunk/splunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ class SplunkBackend(TextQueryBackend):
field_in_list_expression: ClassVar[str] = "{field} {op} ({list})"
or_in_operator: ClassVar[Optional[str]] = "IN"
list_separator: ClassVar[str] = ", "
field_exists_expression: ClassVar[str] = "{field}=*"
field_not_exists_expression: ClassVar[str] = "NOT {field}=*"

unbound_value_str_expression: ClassVar[str] = "{value}"
unbound_value_num_expression: ClassVar[str] = "{value}"
Expand Down
21 changes: 21 additions & 0 deletions tests/test_backend_splunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,27 @@ def test_splunk_fieldref_or(splunk_backend: SplunkBackend):
)
)

def test_splunk_exists(splunk_backend: SplunkBackend):
assert (
splunk_backend.convert(
SigmaCollection.from_yaml(
"""
title: Test
status: test
logsource:
category: test_category
product: test_product
detection:
sel:
fieldA|exists: yes
fieldB|exists: no
condition: sel
"""
)
)
== ['fieldA=* NOT fieldB=*']
)


def test_splunk_fields_output(splunk_backend: SplunkBackend):
rule = SigmaCollection.from_yaml(
Expand Down