Skip to content

Commit e35c58d

Browse files
authored
[Ruleset Engine] Review examples for request body fields (#19118)
1 parent 8846e4d commit e35c58d

File tree

6 files changed

+181
-150
lines changed

6 files changed

+181
-150
lines changed

src/content/docs/ruleset-engine/rules-language/fields/dynamic-fields.mdx

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Indicates whether the visitor has previously passed a JS Detection. For more det
9494

9595
List of IDs that correlate to the Bot Management heuristic detections made on a request (you can have multiple heuristic detections on the same request). Use this field to explicitly match a specific heuristic or to exclude a heuristic in a rule.
9696

97-
Example:
97+
Example usage:
9898

9999
```txt
100100
any(cf.bot_management.detection_ids[*] eq 33554817)
@@ -148,7 +148,7 @@ Represents a Cloudflare threat score from 0–100, where 0 indicates low risk. V
148148

149149
The cipher for the connection to Cloudflare.
150150

151-
Example:
151+
Example value:
152152

153153
```txt
154154
"AES128-SHA256"
@@ -178,7 +178,7 @@ Returns `true` when a request presents a certificate (valid or not).
178178

179179
The Distinguished Name (DN) of the Certificate Authority (CA) that issued the certificate included in the request.
180180

181-
Example:
181+
Example value:
182182

183183
```txt
184184
"CN=Access Testing CA,OU=TX,O=Access Testing,L=Austin,ST=Texas,C=US"
@@ -190,7 +190,7 @@ Example:
190190

191191
The Distinguished Name (DN) of the owner (or requester) of the certificate included in the request.
192192

193-
Example:
193+
Example value:
194194

195195
```txt
196196
"CN=James Royal,OU=Access Admins,O=Access,L=Austin,ST=Texas,C=US"
@@ -202,9 +202,9 @@ Example:
202202

203203
The Distinguished Name (DN) of the Certificate Authority (CA) that issued the certificate in the request in [RFC 2253](https://datatracker.ietf.org/doc/html/rfc2253) format.
204204

205-
Example:
205+
Example value:
206206

207-
```
207+
```txt
208208
"CN=Access Testing CA,OU=TX,O=Access Testing,L=Austin,ST=Texas,C=US"
209209
```
210210

@@ -214,9 +214,9 @@ Example:
214214

215215
The Distinguished Name (DN) of the owner (or requester) of the certificate in the request in [RFC 2253](https://datatracker.ietf.org/doc/html/rfc2253) format.
216216

217-
Example:
217+
Example value:
218218

219-
```
219+
```txt
220220
"CN=James Royal,OU=Access Admins,O=Access,L=Austin,ST=Texas,C=US"
221221
```
222222

@@ -226,9 +226,9 @@ Example:
226226

227227
The Distinguished Name (DN) of the Certificate Authority (CA) that issued the certificate in the request in a legacy format.
228228

229-
Example:
229+
Example value:
230230

231-
```
231+
```txt
232232
"/C=US/ST=Texas/L=Austin/O=Access Testing/OU=TX/CN=Access Testing CA"
233233
```
234234

@@ -238,9 +238,9 @@ Example:
238238

239239
The Distinguished Name (DN) of the owner (or requester) of the certificate in the request in a legacy format.
240240

241-
Example:
241+
Example value:
242242

243-
```
243+
```txt
244244
"/C=US/ST=Texas/L=Austin/O=Access/OU=Access Admins/CN=James Royal"
245245
```
246246

@@ -250,9 +250,9 @@ Example:
250250

251251
Serial number of the certificate in the request.
252252

253-
Example:
253+
Example value:
254254

255-
```
255+
```txt
256256
"527E0F20A20EA2A4146C78390F34CE7AF0878CA4"
257257
```
258258

@@ -262,9 +262,9 @@ Example:
262262

263263
Serial number of the direct issuer of the certificate in the request.
264264

265-
Example:
265+
Example value:
266266

267-
```
267+
```txt
268268
"2688201DBA77402EA87118876F2E1B24CF8B0395"
269269
```
270270

@@ -274,9 +274,9 @@ Example:
274274

275275
The SHA-256 fingerprint of the certificate in the request.
276276

277-
Example:
277+
Example value:
278278

279-
```
279+
```txt
280280
"af363dc85bc942a892d3cee9796190fdb36d89cd588a4f1cb17c74a943439714"
281281
```
282282

@@ -286,9 +286,9 @@ Example:
286286

287287
The SHA-1 fingerprint of the certificate in the request.
288288

289-
Example:
289+
Example value:
290290

291-
```
291+
```txt
292292
"933ad5282c560ae3f482a43ecd73bc9de878a190"
293293
```
294294

@@ -298,9 +298,9 @@ Example:
298298

299299
The certificate in the request is not valid before this date.
300300

301-
Example:
301+
Example value:
302302

303-
```
303+
```txt
304304
"Mar 21 13:35:00 2022 GMT"
305305
```
306306

@@ -310,9 +310,9 @@ Example:
310310

311311
The certificate in the request is not valid after this date.
312312

313-
Example:
313+
Example value:
314314

315-
```
315+
```txt
316316
"Mar 21 13:35:00 2023 GMT"
317317
```
318318

@@ -322,9 +322,9 @@ Example:
322322

323323
The Subject Key Identifier (SKI) of the certificate in the request.
324324

325-
Example:
325+
Example value:
326326

327-
```
327+
```txt
328328
"27846FAE6EAC4A8DAD9101B519CF1EB460242831"
329329
```
330330

@@ -334,9 +334,9 @@ Example:
334334

335335
The Subject Key Identifier (SKI) of the direct issuer of the certificate in the request.
336336

337-
Example:
337+
Example value:
338338

339-
```
339+
```txt
340340
"8204924CF49D471E855862706D889F58F6B784D3"
341341
```
342342

@@ -346,9 +346,9 @@ Example:
346346

347347
The SHA-1 fingerprint of TLS client extensions, encoded in Base64.
348348

349-
Example:
349+
Example value:
350350

351-
```
351+
```txt
352352
"OWFiM2I5ZDc0YWI0YWYzZmFkMGU0ZjhlYjhiYmVkMjgxNTU5YTU2Mg=="
353353
```
354354

@@ -358,9 +358,9 @@ Example:
358358

359359
The length of the client hello message sent in a [TLS handshake](https://www.cloudflare.com/learning/ssl/what-happens-in-a-tls-handshake). Specifically, the length of the bytestring of the client hello.
360360

361-
Example:
361+
Example value:
362362

363-
```
363+
```txt
364364
508
365365
```
366366

@@ -370,9 +370,9 @@ Example:
370370

371371
The value of the 32-byte random value provided by the client in a [TLS handshake](https://www.cloudflare.com/learning/ssl/what-happens-in-a-tls-handshake), encoded in Base64. Refer to [RFC 8446](https://datatracker.ietf.org/doc/html/rfc8446#section-4.1.2) for more details.
372372

373-
Example:
373+
Example value:
374374

375-
```
375+
```txt
376376
"YWJjZA=="
377377
```
378378

@@ -382,9 +382,9 @@ Example:
382382

383383
The TLS version of the connection to Cloudflare.
384384

385-
Example:
385+
Example value:
386386

387-
```
387+
```txt
388388
"TLSv1.2"
389389
```
390390

src/content/docs/ruleset-engine/rules-language/fields/http-request-body.mdx

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,13 @@ The return value may be truncated if [`http.request.body.truncated`](#httpreques
7272
- **Whitespace:** preserved
7373
- **Non-ASCII:** preserved
7474

75-
Example:
75+
Example value:
7676

77-
```txt
78-
any(http.request.body.form["username"][*] == "admin")
79-
```
77+
`{"username": ["admin"]}`
8078

81-
Example value:
82-
`{username": ["admin"]}`
79+
Example usage:
80+
81+
`any(http.request.body.form["username"][*] == "admin")`
8382

8483
## `http.request.body.form.names`
8584

@@ -97,16 +96,14 @@ The return value may be truncated if [`http.request.body.truncated`](#httpreques
9796
- **Whitespace:** preserved
9897
- **Non-ASCII:** preserved
9998

100-
Example:
101-
102-
```txt
103-
any(http.request.body.form.names[*] == "username")
104-
```
105-
10699
Example value:
107100

108101
`["username"]`
109102

103+
Example usage:
104+
105+
`any(http.request.body.form.names[*] == "username")`
106+
110107
## `http.request.body.form.values`
111108

112109
`http.request.body.form.values` <Type text='Array<String>' />
@@ -123,16 +120,14 @@ The return value may be truncated if [`http.request.body.truncated`](#httpreques
123120
- **Whitespace:** preserved
124121
- **Non-ASCII:** preserved
125122

126-
Example:
127-
128-
```txt
129-
any(http.request.body.form.values[*] == "admin")
130-
```
131-
132123
Example value:
133124

134125
`["admin"]`
135126

127+
Example usage:
128+
129+
`any(http.request.body.form.values[*] == "admin")`
130+
136131
## `http.request.body.mime`
137132

138133
`http.request.body.mime` <Type text='String' />
@@ -141,9 +136,13 @@ The MIME type of the request detected from the request body.
141136

142137
Supports the most common MIME types of the following general categories: video, audio, image, application, text.
143138

144-
Example:
139+
Example value:
140+
141+
`"image/jpeg"`
142+
143+
Example usage:
145144

146-
`image/jpeg`
145+
`http.request.body.mime in {"image/bmp" "image/gif" "image/jpeg" "image/png" "image/tiff"}`
147146

148147
This field is available on all Cloudflare plans.
149148

@@ -155,7 +154,11 @@ A Map (or associative array) representation of multipart names to multipart valu
155154

156155
Example value:
157156

158-
`{"username": ["alice_doe"], "picture": [<binary_content_of_file>]}`
157+
`{"username": ["alice_doe"], "role": ["editor"], "picture": [<binary_content_of_file>]}`
158+
159+
Example usage:
160+
161+
`any(http.request.body.multipart["role"][*] == "admin")`
159162

160163
## `http.request.body.multipart.names`
161164

@@ -167,7 +170,7 @@ Example value:
167170

168171
`[["username"], ["picture"]]`
169172

170-
Example:
173+
Example usage:
171174

172175
`any(http.request.body.multipart.names[*][0] == "picture")`
173176

@@ -181,6 +184,10 @@ Example value:
181184

182185
`["alice_doe", <binary_content_of_file>]`
183186

187+
Example usage:
188+
189+
`any(http.request.body.multipart.values[*] == "alice_doe")`
190+
184191
## `http.request.body.multipart.content_types`
185192

186193
`http.request.body.multipart.content_types` <Type text='Array<Array<String>>' />
@@ -191,7 +198,7 @@ Example value:
191198

192199
`[["text/plain"], ["image/jpeg"]]`
193200

194-
Example:
201+
Example usage:
195202

196203
`any(http.request.body.multipart.content_types[*][0] == "application/octet-stream")`
197204

@@ -203,7 +210,11 @@ List of `Content-Disposition` headers for each part in the multipart body.
203210

204211
Example value:
205212

206-
`[["form-data; name=\"username\"], ["form-data;name=\"picture\"]]`
213+
`[["form-data; name=\"username\""], ["form-data; name=\"picture\""]]`
214+
215+
Example usage:
216+
217+
`any(http.request.body.multipart.content_dispositions[*][0] in {"form-data; name=\"username\"" "form-data; name=\"picture\""})`
207218

208219
## `http.request.body.multipart.content_transfer_encodings`
209220

@@ -213,7 +224,11 @@ List of `Content-Transfer-Encoding` headers for each part in the multipart body.
213224

214225
Example value:
215226

216-
`[["quoted-printable"], ["quoted-printable"]]`
227+
`[["quoted-printable"], ["base64"]]`
228+
229+
Example usage:
230+
231+
`any(http.request.body.multipart.content_transfer_encodings[*][0] == "binary")`
217232

218233
## `http.request.body.multipart.filenames`
219234

@@ -224,3 +239,7 @@ List of filenames for each part in the multipart body.
224239
Example value:
225240

226241
`[["file1.txt"], ["photo.jpg"]]`
242+
243+
Example usage:
244+
245+
`any(http.request.body.multipart.filenames[*][0] in {"token.txt" "password.txt"})`

0 commit comments

Comments
 (0)