MCPcopy Index your code
hub / github.com/Codeplain-ai/codeplain / test_nested_sensitive_keys_are_scrubbed

Function test_nested_sensitive_keys_are_scrubbed

tests/test_telemetry.py:173–192  ·  view source on GitHub ↗

Scrubbing is recursive: sensitive keys nested inside dict locals are filtered even when the variable name itself is innocuous.

(transport)

Source from the content-addressed store, hash-verified

171
172
173def 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
195def test_environment_defaults_to_production(transport):

Callers

nothing calls this directly

Calls 4

capture_crashFunction · 0.90
init_with_transportFunction · 0.85
crash_with_nested_secretFunction · 0.85
make_argsFunction · 0.85

Tested by

no test coverage detected