This repository has been archived by the owner on May 14, 2020. It is now read-only.
Avoid embedded anchors in CRS rule 942330 #1668
Merged
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.
Rule 942330 has an embedded start anchor. Specifically this part:
has a
^
inside a+
-group. The Hyperscan regex engine does not support this, so I'm sharing this fix for others also experimenting with Hyperscan.It looks like the purpose of the group is to find lines that begin with quotes or digits. The
+
makes it consume multiple of such lines if there are multiple. But even without the+
, we would always find one if one is present.To get rid of the embedded start anchor, I suggest removing the
+
from behind the group. It's only effect was to allow multiple matches of the group, but in this case it's enough to just match the last instance of the group for this rule to trigger. We can then also remove the(?:)
as there is no longer any purpose of having this expression be a group. The part in question then becomes:The rule will trigger on the same input, but the matched data is now a little bit less.
%{TX.0}
will now only contain the last instance of the group above. I think this is not a problem. Especially since the logdata action also contains%{MATCHED_VAR}
, which contains the entire variable that triggered this matched (not just the matched portion).All the above also applies to the other similar part