-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Excluding matches with regex #1452
Comments
I'd create a private rule and negate it in the main rule this way: private rule default_field_names {
strings:
$field_names = /([\w+]{1,24})(:\/\/)(username|user|test):(password|pass|test)@[-a-zA-Z0-9@:%._\+~#=]{1,256}[a-zA-Z0-9()]{1,24}([^\s"]+)/ fullword
condition:
$field_names
}
rule username_password_uri : authentication {
strings:
$match = /([\w+]{1,24})(:\/\/)([^$][^\s";\/\/]{1,}):([^$][^\s";]{1,})@[-a-zA-Z0-9@:%._\+~#=]{1,256}[a-zA-Z0-9()]{1,24}([^\s"]+)/ fullword
condition:
$match and not default_field_names
} Since it's a private rule, it can only be referenced by other rules. This way maybe you could also reduce the complexity of |
Thanks @merces. I couldn't get that to work either. Turns out my example rule was sort-of correct but it's matching on the whole file, not on each match instance. So I want to do:
but that doesn't look possible. Any ideas? |
I used a |
I know you closed this but |
I'm trying to NOT match a rule if it contains a particular string. I know the regexp engine doesn't support negative lookaheads so we have to get creative. I came across #584 but I can't see to get it to work.
Given
https://shouldmatch:[email protected]
https://username:[email protected]
I would expect $match to match both of those lines, which it does. But $not does NOT match the 2nd line so the rule shouldn't include it. Any ideas?
The text was updated successfully, but these errors were encountered: