def redact_secrets(value):
    if isinstance(value, dict):
        return {
            k: "[REDACTED]" if _is_secret_key(k) else redact_secrets(v)
            for k, v in value.items()
        }
    if isinstance(value, list):
        return [redact_secrets(item) for item in value]
    return value


def _is_secret_key(key):
    lowered = key.lower()
    return "password" in lowered or "token" in lowered or "secret" in lowered
