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

Return a SigmaString if the regex is empty #303

Merged
merged 1 commit into from
Nov 10, 2024
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: 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