Support for PCRE regular expressions#6480
Merged
Conversation
…uring libpcre2 compilation
… string in w_expression_match function
[X] extra_data [X] hostname [X] location [X] program_name [x] protocol [X] user [X] url [X] srcport [X] dstport [x] status [X] system_name [x] data [x] srcgeoip [x] dstgeoip
ea2d012 to
d0b44cc
Compare
vikman90
approved these changes
Nov 6, 2020
12 tasks
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.
Description
Hello team!
This PR add support for Perl Compatible Regular Expressions(PCRE) and allow to select
osregex,osmatchorpcre2using newtypeattribute for several options/fieldsDecoders:
Rules:
libpcre2specsossec-analysisdgetconfig endpointexample[ { "sigid": 100001, "level": 5, "regex": { "pattern": "^Hello World.$", "negate": false, "type": "pcre2" } }, { "sigid": 100002, "level": 7, "dstport": { "pattern": "^Hello from Wazuh.$", "negate": true, "type": "osregex" } } ][{ "id": 519, "name": "test_pcre2_prematch", "children": [{ "id": 519, "name": "test_pcre2_prematch", "parent": "test_pcre2_prematch", "order": [ "id", "otro" ], "use_own_name": "false", "accumulate": "no", "prematch": { "pattern": "MAGICWORD", "type": "osregex" }, "regex": { "pattern": " testing after_parent id:(\\S+) (\\w+)", "type": "pcre2" }, "type": "syslog" }], "use_own_name": "false", "accumulate": "no", "prematch": { "pattern": "test_pcre(\\d)_prematch", "type": "osregex" }, "type": "syslog" }, { "id": 517, "name": "test_lcre2_program_name", "children": [], "use_own_name": "false", "accumulate": "no", "program_name": { "pattern": "^pcre2_house(cat((?i)s|)|)$", "type": "pcre2" }, "type": "syslog" }]Examples
Decoders
Rules
NOTE:
(?i)in PCRE syntax means to be case insensitive.Logs/Alerts example
Lower case log
Upper case log