bito-code-review[bot] commented on code in PR #40343:
URL: https://github.com/apache/superset/pull/40343#discussion_r3321378468


##########
superset/mcp_service/system/tool/get_schema.py:
##########
@@ -182,13 +244,33 @@ async def get_schema(
     Column metadata is extracted dynamically from SQLAlchemy models.
 
     Args:
-        model_type: One of "chart", "dataset", "dashboard", or "database"
+        model_type: One of "chart", "dataset", "dashboard", "database",
+            "css_template", or "theme"
 
     Returns:
         Comprehensive schema information for the requested model type
     """
     await ctx.info(f"Getting schema for model_type={request.model_type}")
 
+    # Per-model-type RBAC check (replaces the static class_permission_name on 
@tool,
+    # which wrongly gated all schema types behind Dataset permission).
+    class_permission = _MODEL_TYPE_CLASS_PERMISSION.get(request.model_type)
+    if class_permission:
+        from flask import current_app, g
+
+        from superset import security_manager
+
+        if current_app.config.get("MCP_RBAC_ENABLED", True) and not (
+            security_manager.can_access("can_read", class_permission)
+        ):
+            user_str = getattr(getattr(g, "user", None), "username", None)
+            raise MCPPermissionDeniedError(
+                permission_name="can_read",
+                view_name=class_permission,
+                user=user_str,
+                tool_name="get_schema",
+            )

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Missing RBAC audit logging</b></div>
   <div id="fix">
   
   Add a warning log (using the imported `event_logger` or by importing the 
standard `logger`) before raising `MCPPermissionDeniedError` to record 
permission denial events for auditing.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #859b8d</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]

Reply via email to