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

Fix cidr expansion for backends that use custom wildcard char #139

Merged
merged 1 commit into from
Jul 30, 2023

Conversation

DenizenB
Copy link
Contributor

@DenizenB DenizenB commented Jul 30, 2023

Hello, I ran into a bug while testing the |cidr modifier in a backend that uses the cidr wildcard logic from TextQueryBackend and a wildcard character that isn't *.

The condition c-ip|cidr: "10.0.0.0/8" was converted into the following query:

`c-ip` LIKE '10.\%' ESCAPE '\'

The wildcard (%) should not have been escaped here.

It turns out that when SigmaCIDRExpression.expand() is called with a wildcard that isn't *, then it won't parsed as a wildcard by SigmaString and will therefore be escaped when the SigmaString is later converted back into a regular string.

If a backend defines `wildcard_multi` as something other than `*`,
then it won't be parsed as a wildcard by `SigmaString` and will
therefore be escaped when the `SigmaString` is converted to a regular
string.
@thomaspatzke
Copy link
Member

Thanks for the fix! First I've wondered why it works, now I know it and made some further enhancements and tests based on your PR.

@thomaspatzke thomaspatzke merged commit cb875a9 into SigmaHQ:main Jul 30, 2023
@DenizenB DenizenB deleted the cidr-expansion-fix branch August 6, 2023 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants