GitHub user dosubot[bot] added a comment to the discussion: How to Mask 
Passwords in Superset Action Log (DatabaseRestApi.import_)

<!-- Answer -->
Your recursive masking method is efficient and appropriate for Superset event 
logging. For typical log payloads (which are usually shallow), the performance 
impact is negligible—recursion is the standard approach for traversing nested 
dicts/lists in Python, and there are no documented alternatives in Superset or 
the community that avoid recursion for this use case.

Superset's event logger can generate multiple log entries from a single event 
if the payload includes a `records` list, but this is only used in rare bulk 
logging scenarios (not standard for endpoints like `/api/v1/database/import/`). 
For most API operations, a single event results in a single log entry 
[reference](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/utils/log.py).

You do not need to mask multiple places in your `log` method. Masking `kwargs` 
before passing them to `super().log()` is sufficient. The `else` part in your 
code (where you mask `kwargs.get("json", {})`) can be removed unless you have a 
specific use case for inspecting or printing masked payloads separately.

One caveat: if you have stringified JSON fields (like `"passwords": "{\"db\": 
\"secret\"}"`), you'll need to explicitly parse and mask those values, as 
neither your method nor Superset's built-in utilities handle masking inside 
string values automatically 
[reference](https://github.com/apache/superset/issues/35355).

In summary: your approach is good, recursion is not a performance concern for 
this context, and you can simplify your `log` method by masking `kwargs` once 
before logging.


<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*

---
<sup>How did I do? 
[Good](https://app.dosu.dev/response-feedback/5edb47bd-7e05-4f63-b8c7-a6a5675038d1?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/5edb47bd-7e05-4f63-b8c7-a6a5675038d1?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/5edb47bd-7e05-4f63-b8c7-a6a5675038d1?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/5edb47bd-7e05-4f63-b8c7-a6a5675038d1?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/5edb47bd-7e05-4f63-b8c7-a6a5675038d1?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/5edb47bd-7e05-4f63-b8c7-a6a5675038d1?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/5edb47bd-7e05-4f63-b8c7-a6a5675038d1?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat
 with 
Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)&
 nbsp;[![Join 
Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share
 on 
X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/35415)

GitHub link: 
https://github.com/apache/superset/discussions/35415#discussioncomment-14580578

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: 
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to