Commit 7fbb160
[ENG-4059] Decode request values the way apps read them (#298)
* Decode request values the way apps read them
Percent-decoding keeps decoding the escapes around a % that starts no
escape, and decodes each run as UTF-8. The urldecode mutation reads + as
a space, as form decoding does, and REQUEST_URI and all read + in the
query as a space while keeping a + in the path literal.
HTML character references decode the same way in normalization and in
the htmlentitydecode mutation: named references such as : and
numeric references without a closing semicolon.
Text mutations (urldecode, htmlentitydecode, base64_decode) applied to a
structured value decode each string inside it and keep the structure,
within the same bounds as the leaf walk.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Normalize nested request values to the leaf walk's depth, and report the bound
Request normalization walks nested values iteratively, to the same depth
bound as the engine's leaf walk, so every value that walk reaches is
normalized first. A value past the bound is still matched in its raw
form, and reaching the bound is reported as a `container-cap` skip
through `onSkip` and `coverage()`, once per request.
An evaluation result carries the inspection limits it reached as
`skips`, and the resolver records them with `noteSkip`.
Adds coverage for `+` in a request target given only as `url`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>1 parent 65a7b66 commit 7fbb160
6 files changed
Lines changed: 475 additions & 79 deletions
File tree
- src/protect
- engine
- tests/protect
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
536 | 536 | | |
537 | 537 | | |
538 | 538 | | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
539 | 546 | | |
540 | 547 | | |
541 | 548 | | |
| |||
1202 | 1209 | | |
1203 | 1210 | | |
1204 | 1211 | | |
1205 | | - | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
1206 | 1215 | | |
| 1216 | + | |
1207 | 1217 | | |
1208 | 1218 | | |
1209 | 1219 | | |
| |||
1236 | 1246 | | |
1237 | 1247 | | |
1238 | 1248 | | |
1239 | | - | |
| 1249 | + | |
| 1250 | + | |
1240 | 1251 | | |
1241 | 1252 | | |
1242 | 1253 | | |
| |||
1246 | 1257 | | |
1247 | 1258 | | |
1248 | 1259 | | |
1249 | | - | |
| 1260 | + | |
1250 | 1261 | | |
1251 | 1262 | | |
1252 | 1263 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
| |||
56 | 58 | | |
57 | 59 | | |
58 | 60 | | |
| 61 | + | |
| 62 | + | |
59 | 63 | | |
60 | 64 | | |
61 | 65 | | |
| |||
111 | 115 | | |
112 | 116 | | |
113 | 117 | | |
| 118 | + | |
| 119 | + | |
114 | 120 | | |
115 | 121 | | |
116 | 122 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
| 83 | + | |
90 | 84 | | |
91 | 85 | | |
92 | 86 | | |
93 | 87 | | |
94 | 88 | | |
95 | | - | |
96 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
97 | 99 | | |
98 | | - | |
| 100 | + | |
99 | 101 | | |
100 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
101 | 105 | | |
102 | 106 | | |
103 | 107 | | |
104 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
105 | 122 | | |
106 | 123 | | |
107 | 124 | | |
| |||
113 | 130 | | |
114 | 131 | | |
115 | 132 | | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
| 133 | + | |
| 134 | + | |
120 | 135 | | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
125 | 145 | | |
126 | | - | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
127 | 167 | | |
128 | 168 | | |
129 | 169 | | |
| |||
352 | 392 | | |
353 | 393 | | |
354 | 394 | | |
355 | | - | |
356 | | - | |
| 395 | + | |
| 396 | + | |
357 | 397 | | |
358 | 398 | | |
359 | 399 | | |
360 | 400 | | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
365 | 404 | | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
366 | 411 | | |
367 | 412 | | |
368 | 413 | | |
369 | 414 | | |
370 | 415 | | |
371 | | - | |
| 416 | + | |
372 | 417 | | |
373 | 418 | | |
374 | 419 | | |
375 | | - | |
376 | | - | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
377 | 423 | | |
378 | 424 | | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
384 | 454 | | |
385 | | - | |
386 | | - | |
387 | 455 | | |
388 | 456 | | |
389 | | - | |
| 457 | + | |
390 | 458 | | |
391 | 459 | | |
392 | 460 | | |
| |||
0 commit comments