codeant-ai-for-open-source[bot] commented on code in PR #42534:
URL: https://github.com/apache/superset/pull/42534#discussion_r3730090204


##########
superset/views/datasource/views.py:
##########
@@ -258,6 +242,20 @@ def samples(self) -> FlaskResponse:
             else:
                 dataset = None
 
+        # Refuse datasource types that don't model raw rows only after access
+        # validation. Running this gate first would disclose datasource
+        # capabilities to guest requests that should receive a 403 or 404.
+        # ``supports_samples`` defaults to True for datasource classes that
+        # don't explicitly opt out.
+        ds_class: type[DatasourceUnion] | None = DatasourceDAO.sources.get(
+            DatasourceType(params["datasource_type"]),
+        )
+        if ds_class is not None and not getattr(ds_class, "supports_samples", 
True):
+            return json_error_response(
+                _("Samples are not available for this datasource type."),
+                status=400,
+            )

Review Comment:
   **Suggestion:** For authenticated non-guest requests whose `datasource_type` 
is `semantic_view`, the preceding branch sets `dataset = None` and never calls 
`security_manager.raise_for_access`; this new gate then returns the 
capability-specific 400 response before `get_samples()` can perform its 
existing datasource access check. As a result, users without access to a 
semantic view receive a different response and can learn that the requested 
datasource type does not support samples instead of receiving the expected 
403/404. Resolve and authorize the semantic-view datasource before applying the 
capability gate, or preserve the access check in this path. [security]
   
   <details>
   <summary><b>Severity Level:</b> Minor ๐Ÿงน</summary>
   
   ```mdx
   - โš ๏ธ Unauthorized users receive capability errors instead of access denial.
   - โš ๏ธ Semantic-view capability information is disclosed before authorization.
   - โš ๏ธ `/datasource/samples` response semantics differ by authorization state.
   ```
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=93117472ee5f438b92cc89aeb6abac7d&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=93117472ee5f438b92cc89aeb6abac7d&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/views/datasource/views.py
   **Line:** 243:257
   **Comment:**
        *Security: For authenticated non-guest requests whose `datasource_type` 
is `semantic_view`, the preceding branch sets `dataset = None` and never calls 
`security_manager.raise_for_access`; this new gate then returns the 
capability-specific 400 response before `get_samples()` can perform its 
existing datasource access check. As a result, users without access to a 
semantic view receive a different response and can learn that the requested 
datasource type does not support samples instead of receiving the expected 
403/404. Resolve and authorize the semantic-view datasource before applying the 
capability gate, or preserve the access check in this path.
   
   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%2F42534&comment_hash=deea5b74d4a8abef5318070fc7939df31e7a3a138bd17eebc640ec8c612a7abe&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42534&comment_hash=deea5b74d4a8abef5318070fc7939df31e7a3a138bd17eebc640ec8c612a7abe&reaction=dislike'>๐Ÿ‘Ž</a>



##########
superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.tsx:
##########
@@ -372,7 +372,11 @@ export default function DrillDetailPane({
           type="error"
           showIcon
           message={t('Failed to load drill-to-detail rows')}
-          description={responseError}
+          description={
+            <pre style={{ margin: 0, whiteSpace: 'pre-wrap' }}>
+              {responseError}
+            </pre>
+          }

Review Comment:
   **Suggestion:** Displaying `responseError` verbatim exposes backend query 
and database error details to anyone who can open drill-to-detail, including 
guest dashboard viewers. The datasource samples endpoint propagates engine 
errors into the client error message, so this can disclose SQL, schema, 
connection, or other sensitive infrastructure information. Render a safe 
user-facing message and keep detailed errors in server-side logs instead. 
[security]
   
   <details>
   <summary><b>Severity Level:</b> Major โš ๏ธ</summary>
   
   ```mdx
   - โŒ Guest dashboard viewers can receive raw database errors.
   - โš ๏ธ Failed drill queries may disclose schema and infrastructure details.
   - โš ๏ธ Error contents are exposed through the user-facing dashboard UI.
   ```
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=4d27b6e8ae714456be1f96dfcb1172b8&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=4d27b6e8ae714456be1f96dfcb1172b8&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** 
superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.tsx
   **Line:** 375:379
   **Comment:**
        *Security: Displaying `responseError` verbatim exposes backend query 
and database error details to anyone who can open drill-to-detail, including 
guest dashboard viewers. The datasource samples endpoint propagates engine 
errors into the client error message, so this can disclose SQL, schema, 
connection, or other sensitive infrastructure information. Render a safe 
user-facing message and keep detailed errors in server-side logs instead.
   
   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%2F42534&comment_hash=06cea700af2e721225291b6f2f815c37b4ad949c85af77d5eea995367737bc61&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42534&comment_hash=06cea700af2e721225291b6f2f815c37b4ad949c85af77d5eea995367737bc61&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]

Reply via email to