Skip to content

Commit

Permalink
Fixed MatchValueCondition: incopmpatible types result in false result
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaspatzke committed Jan 2, 2025
1 parent ca147ec commit 8d58a74
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sigma/processing/conditions/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ class MatchValueCondition(ValueProcessingCondition):
value: Union[str, int, float, bool]

def match_value(self, value: SigmaType) -> bool:
return value == self.value
try:
return value == self.value
except NotImplementedError:
return False


class ContainsWildcardCondition(ValueProcessingCondition):
Expand Down
6 changes: 6 additions & 0 deletions tests/test_processing_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,12 @@ def test_match_value_condition_bool_nomatch():
)


def test_match_value_condition_incompatible_type():
assert not MatchValueCondition(value=123, cond="any").match(
SigmaDetectionItem("field", [], [SigmaString("123")])
)


def test_contains_wildcard_condition_match():
assert ContainsWildcardCondition(cond="any").match(
SigmaDetectionItem("field", [], [SigmaString("*")])
Expand Down

0 comments on commit 8d58a74

Please sign in to comment.