File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
sigma/backends/elasticsearch Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -134,6 +134,10 @@ class LuceneBackend(TextQueryBackend):
134134 # List element separator
135135 list_separator : ClassVar [str ] = " OR "
136136
137+ # Check if a field exists in the log not the value
138+ field_exists_expression : ClassVar [str ] = "_exists_:{field}"
139+ field_not_exists_expression : ClassVar [str ] = "NOT _exists_:{field}"
140+
137141 # Value not bound to a field
138142 # Expression for string value not bound to a field as format string with placeholder {value}
139143 unbound_value_str_expression : ClassVar [str ] = "*{value}*"
Original file line number Diff line number Diff line change @@ -484,6 +484,26 @@ def test_lucene_windash_contains(lucene_backend: LuceneBackend):
484484 ]
485485 )
486486
487+ def test_elasticsearch_exists (lucene_backend : LuceneBackend ):
488+ assert (
489+ lucene_backend .convert (
490+ SigmaCollection .from_yaml (
491+ """
492+ title: Test
493+ status: test
494+ logsource:
495+ category: test_category
496+ product: test_product
497+ detection:
498+ sel:
499+ fieldA|exists: yes
500+ fieldB|exists: no
501+ condition: sel
502+ """
503+ )
504+ )
505+ == ['_exists_:fieldA AND NOT _exists_:fieldB' ]
506+ )
487507
488508def test_lucene_reference_query (lucene_backend : LuceneBackend ):
489509 with pytest .raises (
You can’t perform that action at this time.
0 commit comments