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


##########
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:
   <!-- Bito Reply -->
   The suggestion from the reviewer is valid and should be applied. It 
addresses a security vulnerability (CWE-79) by ensuring that the `name` field 
in `CreateRoleRequest` is properly sanitized to prevent XSS attacks. The 
implementation now includes the `sanitize_user_input()` function, which removes 
HTML tags, blocks dangerous URL schemes, and enforces a 64-character limit. 
This aligns with best practices for handling user-supplied input in web 
applications.
   
   **superset/mcp_service/role/schemas.py**
   ```
   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.",
       )
   ```



-- 
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