Skip to content

Commit

Permalink
Merge pull request #303 from frack113:reverse_regex
Browse files Browse the repository at this point in the history
Return a SigmaString if the regex is empty
  • Loading branch information
thomaspatzke authored Nov 10, 2024
2 parents 6480171 + 01fcbeb commit 380ec89
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sigma/processing/transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ def apply_string_value(self, field: str, val: SigmaString) -> Optional[SigmaStri

# empty string can not be convert into a simple regex
if val == "":
return SigmaRegularExpression("")
return val

for sc in val.s: # iterate over all SigmaString components (strings and special chars)
if isinstance(sc, str): # if component is a string
Expand Down
2 changes: 1 addition & 1 deletion tests/test_processing_transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1548,7 +1548,7 @@ def test_regex_transformation_empty_string(dummy_pipeline):
detection_item = SigmaDetectionItem("field", [], [SigmaString("")])
transformation = RegexTransformation(method="plain")
transformation.apply_detection_item(detection_item)
assert detection_item.value[0] == SigmaRegularExpression("")
assert detection_item.value[0] == SigmaString("")


def test_regex_transformation_case_insensitive_bracket_method(dummy_pipeline):
Expand Down

0 comments on commit 380ec89

Please sign in to comment.