redact(data, secret_keys) walking a parsed JSON dict recursively (dicts nested in dicts) and replacing the value of any key in secret_keys with '***' — payloads must be loggable without leaking passwords or tokens. Return a new structure.redact({'user': 'ana', 'auth': {'password': 'x1'}}, {'password'}){'user': 'ana', 'auth': {'password': '***'}}The nested secret got masked.
Rebuild each dict in a comprehension or loop.
Replace when key in secret_keys, recurse when value is a dict.