Skip to content

Commit c7718b3

Browse files
ngayeriepedrosousa
andauthored
[Rules] Update operators.mdx (#18557)
--------- Co-authored-by: Pedro Sousa <[email protected]>
1 parent 7fe83c9 commit c7718b3

File tree

1 file changed

+42
-9
lines changed

1 file changed

+42
-9
lines changed

src/content/docs/ruleset-engine/rules-language/operators.mdx

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ The Rules language supports these comparison operators:
118118
</td>
119119
</tr>
120120
<tr>
121-
<td>Exactly<br />contains</td>
121+
<td>Contains</td>
122122
<td><code>contains</code></td>
123123
<td></td>
124124
<td>✅</td>
@@ -129,7 +129,29 @@ The Rules language supports these comparison operators:
129129
</td>
130130
</tr>
131131
<tr>
132-
<td>Matches<br />regex*</td>
132+
<td>Wildcard<sup>1</sup><br/>(case-insensitive)</td>
133+
<td><code>wildcard</code></td>
134+
<td></td>
135+
<td>✅</td>
136+
<td>❌</td>
137+
<td>❌</td>
138+
<td>
139+
<code>http.request.uri.path <strong>wildcard</strong> "/articles/*"</code>
140+
</td>
141+
</tr>
142+
<tr>
143+
<td>Strict wildcard<sup>1</sup><br/>(case-sensitive)</td>
144+
<td><code>strict wildcard</code></td>
145+
<td></td>
146+
<td>✅</td>
147+
<td>❌</td>
148+
<td>❌</td>
149+
<td>
150+
<code>http.request.uri.path <strong>strict wildcard</strong> "/AdminTeam/*"</code>
151+
</td>
152+
</tr>
153+
<tr>
154+
<td>Matches<br />regex<sup>2</sup></td>
133155
<td><code>matches</code></td>
134156
<td><code>~</code></td>
135157
<td>✅</td>
@@ -140,34 +162,45 @@ The Rules language supports these comparison operators:
140162
</td>
141163
</tr>
142164
<tr>
143-
<td>Value is in <br />a set of values</td>
165+
<td>Is in set of values / list<sup>3</sup></td>
144166
<td><code>in</code></td>
145167
<td></td>
146168
<td>✅</td>
147169
<td>✅</td>
148170
<td>✅</td>
149171
<td>
150-
<code>ip.src <strong>in</strong> {"{ 203.0.113.0 203.0.113.1 }"}</code>
172+
<code>ip.src <strong>in</strong> {"{ 203.0.113.0 203.0.113.1 }"}</code><br/>
173+
<code>ip.src.asnum <strong>in</strong> $&lt;LIST&gt;</code>
151174
</td>
152175
</tr>
153176
</tbody>
154177
</table>
155178
</div>
156179

157-
\* _Access to the `matches` operator requires a Cloudflare Business or Enterprise plan._
180+
{/* prettier-ignore */}
181+
<sup>1</sup> For more information, refer to [Wildcard matching](#wildcard-matching).<br/>
182+
<sup>2</sup> Access to the `matches` operator requires a Cloudflare Business or Enterprise plan. For more information, refer to [Regular expression matching](#regular-expression-matching).<br/>
183+
<sup>3</sup> Currently, not all Cloudflare products support lists in their expressions. For more information on lists, refer to [Inline lists](/ruleset-engine/rules-language/values/#inline-lists) and [Lists](/waf/tools/lists/).
158184

159185
:::caution
160186
Comparison operators entered using English notation (such as `eq`, `lt`, and `gt`) must be written in lowercase.
161187
:::
162188

163189
### Additional operators in the Cloudflare dashboard
164190

165-
The Cloudflare dashboard shows the following functions as operators:
191+
The Cloudflare dashboard may show the following additional operators, depending on the exact field and the type of rule:
166192

167193
- _starts with_ (corresponding to the [`starts_with()`](/ruleset-engine/rules-language/functions/#starts_with) function): Returns `true` when a string starts with a given substring, and `false` otherwise.
194+
168195
- _ends with_ (corresponding to the [`ends_with()`](/ruleset-engine/rules-language/functions/#ends_with) function): Returns `true` when a string ends with a given substring, and `false` otherwise.
169196

170-
However, when writing your own custom expressions, you must use these functions in function calls, not as operators. For example:
197+
- _is in list_ (corresponding to `<FIELD> in $<LIST_NAME>`): Returns `true` when the field value is present in the specified [list](/waf/tools/lists/), and `false` otherwise. For more information, refer to [Use lists in expressions](/waf/tools/lists/use-in-expressions/).
198+
199+
- _is not in list_ (corresponding to `not <FIELD> in $<LIST_NAME>`): Returns `true` when the field value is not present in the specified [list](/waf/tools/lists/), and `false` otherwise. For more information, refer to [Use lists in expressions](/waf/tools/lists/use-in-expressions/).
200+
201+
:::note
202+
203+
When writing your own custom expressions, you must use the `starts_with()` and `ends_with()` functions in function calls, not as operators. For example:
171204

172205
```txt
173206
# Valid function call
@@ -177,6 +210,8 @@ ends_with(http.request.uri.path, ".html")
177210
http.request.uri.path ends_with ".html"
178211
```
179212

213+
:::
214+
180215
### Comparing string values
181216

182217
String comparison in rule expressions is case-sensitive. To account for possible variations of string capitalization in an expression, you can use the [`lower()`](/ruleset-engine/rules-language/functions/#lower) function and compare the result with a lowercased string, like in the following example:
@@ -185,9 +220,7 @@ String comparison in rule expressions is case-sensitive. To account for possible
185220
lower(http.request.uri.path) contains "/wp-login.php"
186221
```
187222

188-
:::caution
189223
Wildcard matching is only supported with the `wildcard` and `strict wildcard` operators, and regular expression matching is only supported with the `matches` operator.
190-
:::
191224

192225
### Wildcard matching
193226

0 commit comments

Comments
 (0)