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.
This PR introduces two small tools:
simplify_regex
: takes a regex as an input and returns the "simplified" regex generated by re2.simplify_ruleset
: currently takes a ruleset in json format as an input and replaces all regexes by their "simplified" version"Simplified regexes aren't necessarily simpler, in fact they tend to be longer. However, since these regexes more closely mirror the internal representation of RE2, they should reduce regex compilation time, although in my tests this represented only represented a 1.5% improvement on the whole ruleset.
More interestingly, the simplified regex can be used to better understand what a regex is doing, as the simplified version tends to be more readable.
This PR also renames the benchmark cmake target from
benchmark
towaf_benchmark
as it causes a conflict with the google benchmark library. As a consequence, the benchmark job is expected to fail, it'll work fine after the merge.