Bugfix/incorrect evaluation of deferred regular expressions#31
Merged
suryamajhi merged 9 commits intologpoint:mainfrom Feb 26, 2026
Conversation
…. Need to see if automatic conversion to snake_case makes sense for azure and m365. In future, if there happens to be it's need we shall add them. Also this section is for unusal hack for json_values.
There was a problem hiding this comment.
Pull request overview
This pull request fixes incorrect evaluation of deferred regular expressions in the Logpoint backend, addressing an issue where regex modifiers were incorrectly combined using AND operations instead of OR operations, and adding proper support for NOT operations.
Changes:
- Redesigned regex handling to use intermediate condition fields that are evaluated separately and then combined correctly in the final search query
- Updated the regex expression generation to use named capture groups and eval-based condition checking
- Removed redundant field mapping logic from Azure and M365 pipelines (lowercasing now handled in backend)
- Updated pysigma dependency from ^1.0.0 to ^1.1.1 to support new features
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| sigma/backends/logpoint/logpoint.py | Core implementation of deferred regex expressions using intermediate condition fields, removed convert_value_str override, added finish_query override to handle regex expressions |
| sigma/pipelines/logpoint/m365.py | Removed snake_case conversion logic (now handled in backend) |
| sigma/pipelines/logpoint/azure.py | Removed snake_case conversion logic (now handled in backend) |
| tests/test_backend_logpoint.py | Added comprehensive tests for single regex, OR, AND, and NOT operations with regex patterns |
| pyproject.toml | Updated pysigma dependency to ^1.1.1 |
| poetry.lock | Updated lock file with new pysigma version and transitive dependency updates |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes the incorrect evalution of deferred regular expression.
Problem Statement
In presence of any regex modifier, it always does AND operation among them.
Example sigma:
Current output:
The result of this query is AND operation as both of them are filtering on truth case. But actually, it has to be an OR operation. Also, there is no regards for NOT operation.
Solution
Instead of directly adding the filter=true in regex process command, let the regex process command execute with group capturing and eval for checking if the group capturing was successful or not. Later use that eval generated field to correctly substitute in the sigma expression.
Sigma Example 1:
Output:
This output correctly express sigma rule as fieldA_condition and fieldA_condition2 will be populated accordingly with correct sigma expression.
Sigma Example 2 (Negation on regex modifier):
Output: