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


##########
superset/mcp_service/role/schemas.py:
##########
@@ -262,3 +262,88 @@ def serialize_role_object(
         if permissions is not None
         else None,
     )
+
+
+# ---------------------------------------------------------------------------
+# create_role / update_role schemas
+# ---------------------------------------------------------------------------
+
+
+_ROLE_NAME_MAX_LEN = 64
+
+
+class CreateRoleRequest(BaseModel):
+    model_config = ConfigDict(populate_by_name=True)
+
+    name: str = Field(
+        ...,
+        min_length=1,
+        max_length=_ROLE_NAME_MAX_LEN,
+        description="Name for the new role. Must be unique.",
+    )

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>CWE-79: Role Name XSS Risk</b></div>
   <div id="fix">
   
   The `name` field in CreateRoleRequest lacks XSS sanitization despite being 
user-supplied input stored and displayed in the Superset UI. Other schemas like 
UpdateChartRequest use sanitize_user_input() for chart_name. Apply the same 
pattern to prevent XSS when role names are rendered in dashboards or returned 
in API responses. ([CWE-79](https://cwe.mitre.org/data/definitions/79.html))
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #b9ab55</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