Scrubbing is recursive: sensitive keys nested inside dict locals are filtered even when the variable name itself is innocuous.
(transport)
| 171 | |
| 172 | |
| 173 | def test_nested_sensitive_keys_are_scrubbed(transport): |
| 174 | """Scrubbing is recursive: sensitive keys nested inside dict locals are |
| 175 | filtered even when the variable name itself is innocuous.""" |
| 176 | init_with_transport(transport) |
| 177 | |
| 178 | secret = "".join(["nested", "-secret-", "key"]) |
| 179 | |
| 180 | def crash_with_nested_secret(): |
| 181 | request_info = {"url": "https://api.codeplain.ai", "x-api-key": secret} # noqa: F841 |
| 182 | raise KeyError("boom") |
| 183 | |
| 184 | try: |
| 185 | crash_with_nested_secret() |
| 186 | except KeyError: |
| 187 | exc_info = sys.exc_info() |
| 188 | |
| 189 | assert capture_crash(exc_info, None, make_args()) |
| 190 | sentry_sdk.flush(timeout=2) |
| 191 | |
| 192 | assert secret not in json.dumps(transport.events[0], default=str) |
| 193 | |
| 194 | |
| 195 | def test_environment_defaults_to_production(transport): |
nothing calls this directly
no test coverage detected