codeant-ai-for-open-source[bot] commented on code in PR #45353:
URL: https://github.com/apache/superset/pull/45353#discussion_r4285711686
##########
superset/utils/log.py:
##########
@@ -125,6 +125,76 @@ def get_object_ids_from_view_args(
return {}
+# Request fields whose value is a secret, wherever they appear in the body: a
+# database password, an SSH tunnel credential, an OAuth2 client secret or
token,
+# an embedded fallback credential, a service-account key, or the import maps
and
+# Secure Extra blobs that carry them. The event log stores the request payload,
+# so without this the Action Log keeps every secret typed into the database
+# dialog, a connection test or an import in clear.
+SENSITIVE_PAYLOAD_KEYS = frozenset(
+ {
+ "access_token",
+ "client_secret",
+ "credentials_info",
+ "encrypted_extra",
+ "encrypted_extra_secrets",
+ "masked_encrypted_extra",
+ "password",
+ "passwords",
+ "private_key",
+ "private_key_password",
+ "privatekey_body",
+ "privatekey_pass",
+ "refresh_token",
+ "secret",
+ "service_account_info",
+ "ssh_tunnel_passwords",
+ "ssh_tunnel_private_key_passwords",
+ "ssh_tunnel_private_keys",
+ "token",
+ }
+)
+
+
+def _redact_uri(uri: Any) -> Any:
+ """Mask the password of a SQLAlchemy URI, keeping the rest readable."""
+ # Prevent circular import.
+ from superset.databases.utils import make_url_safe
+
+ if not isinstance(uri, str) or not uri:
+ return uri
+ try:
+ url = make_url_safe(uri)
+ except Exception: # pylint: disable=broad-except
+ return PASSWORD_MASK # unparseable: it may still hold a credential
+ if url.password is None:
+ return uri
Review Comment:
**Suggestion:** When a URI stores credentials in query parameters, such as
`azure_ad_client_secret` or `motherduck_token`, and has no userinfo password,
this returns it unchanged and logs those secrets.
**Assessment:** ๐ด `Critical` ยท ๐ `Occurrence: Sometimes` ยท ๐ท๏ธ `Security`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=1deedcf8822b41c3ab2fcd0308a4eee7&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=1deedcf8822b41c3ab2fcd0308a4eee7&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/utils/log.py
**Line:** 170:171
**Comment:**
*Security: When a URI stores credentials in query parameters, such as
`azure_ad_client_secret` or `motherduck_token`, and has no userinfo password,
this returns it unchanged and logs those secrets.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F45353&comment_hash=cf4c65a44f6d8ff71cb0f32566f591882ff0d534229ae76c639bcb64503f1489&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F45353&comment_hash=cf4c65a44f6d8ff71cb0f32566f591882ff0d534229ae76c639bcb64503f1489&reaction=dislike'>๐</a>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]