Commit 15c3821
committed
Merged PR 2668744: Regex backreference support
The regex backreference support works by parsing regexes at initialization to detect the presence of backreferences such as `\1`, `\2`, etc. These are then replaced with the content of the group that they were referencing. So for example `(abc+) \1` becomes `(abc+) (abc+)`. The `tryMatch` function then does the actual comparison to ensure that the two groups actually had the same content.
Only groups that are surrounded by `\b` word boundaries are supported, such as `\b(abc+)\b`. This is because otherwise it becomes really complicated with situations like `11=111111`.
The CRS also contains this construct that makes use of a negative lookahead to assert that a backreference is _not equal_ to a group (simplified): `\b(\w+)\b != (?!\b(\1)\b)(\w+)`. Support for these special construct is therefore also implemented.
The changes to CRS rule 942130 is currently pending checkin: RE2 compatibility for 920120
SpiderLabs/owasp-modsecurity-crs#1663
Because this gets us to 100% of the CRS tests passing, I have removed code that was preventing running the CRS tests by default in the CI pipeline. So the CRS tests now always run by default.
PR URL: https://msazure.visualstudio.com/DefaultCollection/One/_git/Networking-Azwaf/pullrequest/2668744
Related work items: #56978581 parent 45ea1f5 commit 15c3821
File tree
18 files changed
+1039
-87
lines changed- hyperscan
- integrationtesting
- secrule
- reqscanning
- ruleparsing
- rulesetfiles
- crs2.2.9/base_rules
- crs3.0
- rules
- util/regression-tests/tests/REQUEST-942-APPLICATION-ATTACK-SQLI
- crs3.1
- rules
- util
- regexp-assemble
- regression-tests/tests/REQUEST-942-APPLICATION-ATTACK-SQLI
- crs3.2
- rules
- util
- regexp-assemble
- regression-tests/tests/REQUEST-942-APPLICATION-ATTACK-SQLI
- waf
18 files changed
+1039
-87
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
63 | 70 | | |
64 | 71 | | |
65 | 72 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
23 | 26 | | |
24 | 27 | | |
25 | 28 | | |
| |||
38 | 41 | | |
39 | 42 | | |
40 | 43 | | |
| 44 | + | |
41 | 45 | | |
42 | 46 | | |
43 | 47 | | |
| |||
47 | 51 | | |
48 | 52 | | |
49 | 53 | | |
50 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
51 | 69 | | |
52 | 70 | | |
53 | 71 | | |
| |||
88 | 106 | | |
89 | 107 | | |
90 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
91 | 114 | | |
92 | 115 | | |
93 | 116 | | |
| |||
140 | 163 | | |
141 | 164 | | |
142 | 165 | | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
143 | 181 | | |
144 | 182 | | |
145 | 183 | | |
146 | 184 | | |
147 | 185 | | |
148 | | - | |
| 186 | + | |
149 | 187 | | |
150 | 188 | | |
151 | 189 | | |
| |||
161 | 199 | | |
162 | 200 | | |
163 | 201 | | |
164 | | - | |
165 | 202 | | |
166 | 203 | | |
167 | 204 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | 70 | | |
77 | 71 | | |
78 | 72 | | |
| |||
0 commit comments