Commit 2a499ec
authored
fix(scrubber): Scrub request bodies that are JSON arrays (#7561)
### Description
`scrub_request` only calls `scrub_dict` on `event["request"]["data"]`,
and `scrub_dict` returns immediately for anything that isn't a dict. So
a body that parses to a top level JSON array is skipped entirely and
every secret in it ships in the clear. It happens under the default
scrubber, no config needed.
`scrub_list` already handles this shape. Its docstring says it walks a
list and any nested lists and calls `scrub_dict` on every dictionary it
finds, and `scrub_dict` already hands nested lists to it when
`recursive` is on. It just was never called on the request body.
What changed:
* `scrub_request` now calls `scrub_dict` and then `scrub_list` on
`event["request"]["data"]`. Each one ignores the type it doesn't handle,
so dict bodies behave exactly as before.
* Two tests in `tests/test_scrubber.py`, one for a list body under the
default scrubber and one for a dict nested inside a list body with
`recursive=True`.
One thing worth your call: `scrub_list` recurses into nested lists no
matter what `recursive` is set to, so `[[{"password": "x"}]]` now gets
filtered where today it isn't. That only ever filters more, never less.
If you'd rather keep the shallow path exact I can gate the call on
`self.recursive` instead.
Fixes #75431 parent 7fd0934 commit 2a499ec
2 files changed
Lines changed: 56 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
132 | 134 | | |
133 | 135 | | |
134 | 136 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
65 | 118 | | |
66 | 119 | | |
67 | 120 | | |
| |||
0 commit comments