ModSecurity
ModSecurity copied to clipboard
WIP: Add RE2 regexp engine support
See #1996.
Every commit has detailed description.
I've implemented the fallback approach so far: if RE2 support is enabled, every regular expression is compiled with RE2, and if that fails, regular expression is compiled with libpcre instead. Please see #1996 for more detailed discussion why this approach is necessary.
There's also lots of refactoring of regexp related code.
Open questions:
- [ ] Perhaps, since RE2 support is considered experimental, configure script should not even attempt to build it unless explicit
--with-re
is supplied? - [ ] There's no easy way to know which regular expression uses which engine. It might feel like kind of implicit magic, which isn't really good.
- [x] There's no error handling when regular expression is invalid. This isn't a regression introduced by this PR, but now might be the time to do something about it.
- [ ] PR needs code review, obviously.
- [ ] Changelog entry
- [ ] Documentation
- [ ] Maybe something else I missed.
I've just force-pushed updated PR.
- New commit with fixed error handling for the rx operator.
-
get_pattern
was renamed togetPattern
to adhere to naming convention used elsewhere in ModSecurity. - verifyCC conversion to the new classes, which was done very sloppily earlier, has been re-done properly.
Since my changes have been essentially merged into v3/dev/re2
, I updated the PR to target v3/master
branch now.
Overall, the performance for the libpcre users was not impacted by this pull request:
The chart was generated using the code merged into v3/dev/re2.
Ping.
Just in case, even though it's marked WIP, it's more than ready for the first round of review.
Rebased on top of the current master.
Very interesting commit. We recently ran into performance issues with modsecurity. Any news on how much improvement we might see?
Very interesting commit. We recently ran into performance issues with modsecurity. Any news on how much improvement we might see?
Hi @eddie4,
That is not the single front that we have on the performance side. Check the branch v3/dev/3.1-experimental. We have had great progress there. This is still on the Queue, to be merged once other pieces of v3.1 are complete.
Very interesting commit. We recently ran into performance issues with modsecurity. Any news on how much improvement we might see?
@eddie4 in my experience, it doesn't really make it much faster in average, however, it eliminates ReDoS worst cases.
@zimmerle please ping me when it's time to rebase this on top v3/dev/3.1-experimental
.
@zimmerle please ping me when it's time to rebase this on top
v3/dev/3.1-experimental
.
That is definitively something that I want to see happening. Lets have 3.1-experimental stable first. Working on the new issues that you have reported on #2376