Redact sensitive nested values
Your task
Redact sensitive values from a nested structure before logging. Given a JSON-like structure (dicts, lists, and scalars) and a list of sensitive key names (case-insensitive), return a deep copy where any dict value whose key matches a sensitive name (compared lowercased) is replaced with the string '[REDACTED]', recursing into nested dicts and lists. Non-matching scalars are left as-is. Do not mutate the input.
Examples
redact(data: any, sensitive: list[str]) -> anyExample 1
Input
redact({"user": "alice", "password": "p@ss"}, ["password"])Output
{"user": "alice", "password": "[REDACTED]"}