bito-code-review[bot] commented on code in PR #40653:
URL: https://github.com/apache/superset/pull/40653#discussion_r3344874873
##########
superset/mcp_service/auth.py:
##########
@@ -77,6 +77,96 @@ class MCPNoAuthSourceError(ValueError):
"""
+def _sanitize_iss_for_log(value: Any) -> str:
+ """Escape control characters in an issuer claim before logging.
+
+ The ``iss`` claim is attacker-controlled and may contain newlines that
+ could forge or split log lines; collapse them to keep one log entry.
+ """
+ return (
+ str(value)
+ .replace("\\", "\\\\")
+ .replace("\n", "\\n")
+ .replace("\r", "\\r")
+ .replace("\t", "\\t")
+ )
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>CWE-755: Duplicate Sanitization</b></div>
<div id="fix">
Function `_sanitize_iss_for_log` (lines 80-92) is semantically identical to
`sanitize_for_log` in `superset/mcp_service/utils/error_sanitization.py`. The
`jwt_verifier.py` already imports and uses the shared utility. Duplicating it
in `auth.py` creates divergence risk and inconsistent behavior. Import the
existing utility instead. (See also:
[CWE-755](https://cwe.mitre.org/data/definitions/755.html))
</div>
</div>
<small><i>Code Review Run #5970fa</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
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]