You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "sha174n (via GitHub)" <gi...@apache.org> on 2026/06/25 14:48:52 UTC
[PR] fix(explore): apply per-datasource access check on the legacy explore view [superset]
sha174n opened a new pull request, #41425:
URL: https://github.com/apache/superset/pull/41425
### SUMMARY
Applies the same per-datasource access check the `/api/v1/explore` command uses (`security_manager.raise_for_access(datasource=...)`) to the deprecated `/superset/explore/` view, so both paths apply a consistent per-object datasource check before rendering datasource metadata. The check is guarded for the placeholder (missing-dataset) case the view already supports, and runs ahead of the save-as/overwrite action paths so they share the same check.
### TESTING INSTRUCTIONS
Adds a regression test asserting the view runs the per-datasource check on the loaded datasource:
`pytest tests/integration_tests/core_tests.py::TestCore::test_explore_view_checks_datasource_access`
### ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(explore): apply per-datasource access check on the legacy explore view [superset]
Posted by "sha174n (via GitHub)" <gi...@apache.org>.
sha174n commented on code in PR #41425:
URL: https://github.com/apache/superset/pull/41425#discussion_r3525792901
##########
tests/integration_tests/core_tests.py:
##########
@@ -899,6 +899,23 @@ def test_explore_redirect(self, mock_command: mock.Mock):
rv = self.client.get(f"/explore/?form_data={quote(json.dumps(form_data))}")
assert rv.headers["Location"] == f"/explore/?form_data_key={random_key}"
+ @pytest.mark.usefixtures("load_energy_table_with_slice")
+ @mock.patch("superset.security.SupersetSecurityManager.raise_for_access")
+ def test_explore_view_checks_datasource_access(
+ self, mock_raise_for_access: mock.Mock
+ ) -> None:
+ """The explore view runs the per-datasource access check on the loaded
+ datasource, consistent with the explore command, before rendering its
+ metadata."""
+ self.login(ADMIN_USERNAME)
+ tbl_id = self.table_ids.get("energy_usage")
Review Comment:
Annotated the local as `tbl_id: int | None` in 41f6fd22e3.
##########
tests/integration_tests/core_tests.py:
##########
@@ -899,6 +899,23 @@ def test_explore_redirect(self, mock_command: mock.Mock):
rv = self.client.get(f"/explore/?form_data={quote(json.dumps(form_data))}")
assert rv.headers["Location"] == f"/explore/?form_data_key={random_key}"
+ @pytest.mark.usefixtures("load_energy_table_with_slice")
+ @mock.patch("superset.security.SupersetSecurityManager.raise_for_access")
+ def test_explore_view_checks_datasource_access(
+ self, mock_raise_for_access: mock.Mock
+ ) -> None:
+ """The explore view runs the per-datasource access check on the loaded
+ datasource, consistent with the explore command, before rendering its
+ metadata."""
+ self.login(ADMIN_USERNAME)
+ tbl_id = self.table_ids.get("energy_usage")
+
+ self.client.post(f"/explore/table/{tbl_id}/")
+
+ mock_raise_for_access.assert_called_once()
+ _, kwargs = mock_raise_for_access.call_args
Review Comment:
Inlined the assertion in 41f6fd22e3 so there is no untyped local to annotate (dropped the `kwargs` variable).
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(explore): apply per-datasource access check on the legacy explore view [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #41425:
URL: https://github.com/apache/superset/pull/41425#issuecomment-4878514473
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**Commands**
Type the following command in the pull request comment and save the comment.
- `/review` - Manually triggers a full AI review.
- `/pause` - Pauses automatic reviews on this pull request.
- `/resume` - Resumes automatic reviews.
- `/resolve` - Marks all Bito-posted review comments as resolved.
- `/abort` - Cancels all in-progress reviews.
Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</details>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(explore): apply per-datasource access check on the legacy explore view [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas merged PR #41425:
URL: https://github.com/apache/superset/pull/41425
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(explore): apply per-datasource access check on the legacy explore view [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #41425:
URL: https://github.com/apache/superset/pull/41425#issuecomment-4804873453
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**Commands**
Type the following command in the pull request comment and save the comment.
- `/review` - Manually triggers a full AI review.
- `/pause` - Pauses automatic reviews on this pull request.
- `/resume` - Resumes automatic reviews.
- `/resolve` - Marks all Bito-posted review comments as resolved.
- `/abort` - Cancels all in-progress reviews.
Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</details>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(explore): apply per-datasource access check on the legacy explore view [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #41425:
URL: https://github.com/apache/superset/pull/41425#issuecomment-4805900965
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**Commands**
Type the following command in the pull request comment and save the comment.
- `/review` - Manually triggers a full AI review.
- `/pause` - Pauses automatic reviews on this pull request.
- `/resume` - Resumes automatic reviews.
- `/resolve` - Marks all Bito-posted review comments as resolved.
- `/abort` - Cancels all in-progress reviews.
Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</details>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(explore): apply per-datasource access check on the legacy explore view [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #41425:
URL: https://github.com/apache/superset/pull/41425#issuecomment-4887783562
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**Commands**
Type the following command in the pull request comment and save the comment.
- `/review` - Manually triggers a full AI review.
- `/pause` - Pauses automatic reviews on this pull request.
- `/resume` - Resumes automatic reviews.
- `/resolve` - Marks all Bito-posted review comments as resolved.
- `/abort` - Cancels all in-progress reviews.
Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</details>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(explore): apply per-datasource access check on the legacy explore view [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #41425:
URL: https://github.com/apache/superset/pull/41425#issuecomment-4803612895
<!-- Bito Reply -->
The flagged issue is correct. The test method `test_explore_view_checks_datasource_access` lacks type annotations for the `mock_raise_for_access` parameter and the return type. You can resolve this by updating the method signature as follows:
```python
@mock.patch("superset.security.SupersetSecurityManager.raise_for_access")
def test_explore_view_checks_datasource_access(self, mock_raise_for_access: mock.Mock) -> None:
```
There are no other comments on this pull request to address.
**tests/integration_tests/core_tests.py**
```
@mock.patch("superset.security.SupersetSecurityManager.raise_for_access")
def test_explore_view_checks_datasource_access(self, mock_raise_for_access: mock.Mock) -> None:
```
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(explore): apply per-datasource access check on the legacy explore view [superset]
Posted by "sha174n (via GitHub)" <gi...@apache.org>.
sha174n commented on code in PR #41425:
URL: https://github.com/apache/superset/pull/41425#discussion_r3477674810
##########
tests/integration_tests/core_tests.py:
##########
@@ -887,6 +887,22 @@ def test_explore_redirect(self, mock_command: mock.Mock):
)
assert rv.headers["Location"] == f"/explore/?form_data_key={random_key}"
+ @pytest.mark.usefixtures("load_energy_table_with_slice")
+ @mock.patch("superset.security.SupersetSecurityManager.raise_for_access")
+ def test_explore_view_checks_datasource_access(self, mock_raise_for_access):
Review Comment:
Added full type annotations (mock.Mock arg and -> None return) in 8dd1f7b018.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(explore): apply per-datasource access check on the legacy explore view [superset]
Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #41425:
URL: https://github.com/apache/superset/pull/41425#issuecomment-4877496270
### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
| Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">🔨</span> Latest commit | 74c8049e5df8827976e4abd34c45c57acda1760b |
|<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/6a47ce7bd24fa30008a5da73 |
|<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-41425--superset-docs-preview.netlify.app](https://deploy-preview-41425--superset-docs-preview.netlify.app) |
|<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br /><br /><br />_Use your smartphone camera to open QR code link._</details> |
|<span aria-hidden="true">🤖</span> Make changes | [Run an agent on this branch](https://app.netlify.com/projects/superset-docs-preview/agent-runs#DctJDoAgDEDRu3QtkThhvIHHKLRGEhVSHGO8u-z-4r8XooQ17jAAFGAFNzfnnvxd8h2XIKxOz5ci3DGFQxyryLL6lHzYsiDO0zNSNh02xrGxVDUT1lrrHltCU8P3Aw) |
---
<!-- [superset-docs-preview Preview](https://deploy-preview-41425--superset-docs-preview.netlify.app) -->
_To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(explore): apply per-datasource access check on the legacy explore view [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #41425:
URL: https://github.com/apache/superset/pull/41425#issuecomment-4888549816
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**Commands**
Type the following command in the pull request comment and save the comment.
- `/review` - Manually triggers a full AI review.
- `/pause` - Pauses automatic reviews on this pull request.
- `/resume` - Resumes automatic reviews.
- `/resolve` - Marks all Bito-posted review comments as resolved.
- `/abort` - Cancels all in-progress reviews.
Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</details>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(explore): apply per-datasource access check on the legacy explore view [superset]
Posted by "sha174n (via GitHub)" <gi...@apache.org>.
sha174n commented on PR #41425:
URL: https://github.com/apache/superset/pull/41425#issuecomment-4805049931
@bito-code-review The CWE-552 item is a false positive and I've resolved the inline thread. `SupersetSecurityException` subclasses `SupersetErrorException`, which has a global Flask error handler (`set_app_error_handlers` → `show_superset_error`); Flask dispatches by class MRO, so the exception is returned as a structured JSON 403, not a generic 500. No per-method decorator or try/except is needed.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(explore): apply per-datasource access check on the legacy explore view [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #41425:
URL: https://github.com/apache/superset/pull/41425#issuecomment-4800673825
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(explore): apply per-datasource access check on the legacy explore view [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on code in PR #41425:
URL: https://github.com/apache/superset/pull/41425#discussion_r3478169505
##########
superset/views/core.py:
##########
@@ -505,6 +505,11 @@ def explore( # noqa: C901
datasource_id,
)
+ # Apply the same per-datasource access check the explore command performs,
+ # so this view is consistent with it before rendering datasource metadata.
+ if datasource:
+ security_manager.raise_for_access(datasource=datasource)
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>CWE-552: Unhandled Security Exception</b></div>
<div id="fix">
The `raise_for_access(datasource=datasource)` call raises `SupersetSecurityException` (status 403) when access is denied, but the `explore` method has no `@handle_api_exception` decorator and no explicit try/except to catch it. All other methods in this class that call `raise_for_access` are either decorated with `@handle_api_exception` (e.g. `explore_json` at line 279, `dashboard_v2` at line 892) or use an explicit try/except block (e.g. `dashboard` at lines 825-830). Without this, the exception propagates as a generic 500 HTML page instead of a structured 403 JSON response, leaking internal details and breaking clients that expect JSON. (See also: [CWE-552](https://cwe.mitre.org/data/definitions/552.html))
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
```
--- superset/views/core.py (lines 508-512) ---
510:
511: + if datasource:
512: + try:
513: + security_manager.raise_for_access(datasource=datasource)
514: + except SupersetSecurityException:
515: + return json_error_response(_("Forbidden"), status=403)
516: +
(context around 508-517):
508:
509: + // Apply the same per-datasource access check the explore command performs,
510: + // so this view is consistent with it before rendering datasource metadata.
511: + if datasource:
512: + try:
513: + security_manager.raise_for_access(datasource=datasource)
514: + except SupersetSecurityException:
515: + return json_error_response(_("Forbidden"), status=403)
516: +
517: datasource_name = datasource.name if datasource else _("[Missing Dataset]")
```
</div>
</details>
</div>
<small><i>Code Review Run #1d61bf</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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(explore): apply per-datasource access check on the legacy explore view [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #41425:
URL: https://github.com/apache/superset/pull/41425#discussion_r3477243658
##########
tests/integration_tests/core_tests.py:
##########
@@ -887,6 +887,22 @@ def test_explore_redirect(self, mock_command: mock.Mock):
)
assert rv.headers["Location"] == f"/explore/?form_data_key={random_key}"
+ @pytest.mark.usefixtures("load_energy_table_with_slice")
+ @mock.patch("superset.security.SupersetSecurityManager.raise_for_access")
+ def test_explore_view_checks_datasource_access(self, mock_raise_for_access):
Review Comment:
**Suggestion:** Add full type annotations to this new test method signature, including the mocked argument type and an explicit `-> None` return type. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
This is a newly added Python test method, and its signature omits type hints for the mocked parameter and the return type. The custom rule requires newly added Python functions and methods to be fully typed, so this is a real violation.
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=16e3d845dfb149a5a866199d1cff2651&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=16e3d845dfb149a5a866199d1cff2651&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:** tests/integration_tests/core_tests.py
**Line:** 892:892
**Comment:**
*Custom Rule: Add full type annotations to this new test method signature, including the mocked argument type and an explicit `-> None` return type.
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%2F41425&comment_hash=5867f0af64bd01ca41d43a618338ef7861fc6b3f4c8930106c531c28ea549ade&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41425&comment_hash=5867f0af64bd01ca41d43a618338ef7861fc6b3f4c8930106c531c28ea549ade&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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(explore): apply per-datasource access check on the legacy explore view [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on code in PR #41425:
URL: https://github.com/apache/superset/pull/41425#discussion_r3478270688
##########
superset/views/core.py:
##########
@@ -505,6 +505,11 @@ def explore( # noqa: C901
datasource_id,
)
+ # Apply the same per-datasource access check the explore command performs,
+ # so this view is consistent with it before rendering datasource metadata.
+ if datasource:
+ security_manager.raise_for_access(datasource=datasource)
Review Comment:
<!-- Bito Reply -->
The user's assessment is correct. Since `SupersetSecurityException` is a subclass of `SupersetErrorException`, it is handled by the existing global Flask error handler (`show_superset_error`), which ensures a structured 403 JSON response is returned. Therefore, the explicit try/except block suggested in the review is not strictly required for this exception to be handled correctly.
**superset/views/core.py**
```
511: + if datasource:
512: + try:
513: + security_manager.raise_for_access(datasource=datasource)
514: + except SupersetSecurityException:
515: + return json_error_response(_("Forbidden"), status=403)
```
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(explore): apply per-datasource access check on the legacy explore view [superset]
Posted by "sha174n (via GitHub)" <gi...@apache.org>.
sha174n commented on code in PR #41425:
URL: https://github.com/apache/superset/pull/41425#discussion_r3478269629
##########
superset/views/core.py:
##########
@@ -505,6 +505,11 @@ def explore( # noqa: C901
datasource_id,
)
+ # Apply the same per-datasource access check the explore command performs,
+ # so this view is consistent with it before rendering datasource metadata.
+ if datasource:
+ security_manager.raise_for_access(datasource=datasource)
Review Comment:
Not applicable here. `SupersetSecurityException` subclasses `SupersetErrorException`, which has a global Flask error handler registered in `set_app_error_handlers` (`show_superset_error`). Flask dispatches exceptions by walking the class MRO, so the subclass is caught by that handler and returned as a structured JSON response carrying its own `status` (403), not a generic 500. No per-method decorator or try/except is required. Verified empirically that the response is 403.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(explore): apply per-datasource access check on the legacy explore view [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #41425:
URL: https://github.com/apache/superset/pull/41425#issuecomment-4800707387
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/41425?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `0%` with `2 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 55.72%. Comparing base ([`a90c8e0`](https://app.codecov.io/gh/apache/superset/commit/a90c8e034762c639ce7dbc38217f9ecf3406f38c?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`614848f`](https://app.codecov.io/gh/apache/superset/commit/614848f2ad7fa9a4422adf1a21c34e5046f6f156?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
| [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/41425?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [superset/views/core.py](https://app.codecov.io/gh/apache/superset/pull/41425?src=pr&el=tree&filepath=superset%2Fviews%2Fcore.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvdmlld3MvY29yZS5weQ==) | 0.00% | [2 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/41425?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
> :exclamation: There is a different number of reports uploaded between BASE (a90c8e0) and HEAD (614848f). Click for more details.
>
> <details><summary>HEAD has 56 uploads less than BASE</summary>
>
>| Flag | BASE (a90c8e0) | HEAD (614848f) |
>|------|------|------|
>|python|50|1|
>|presto|8|1|
></details>
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #41425 +/- ##
==========================================
- Coverage 64.48% 55.72% -8.76%
==========================================
Files 2661 2661
Lines 145642 145644 +2
Branches 33613 33614 +1
==========================================
- Hits 93912 81162 -12750
- Misses 50029 63741 +13712
+ Partials 1701 741 -960
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/41425/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [hive](https://app.codecov.io/gh/apache/superset/pull/41425/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [mysql](https://app.codecov.io/gh/apache/superset/pull/41425/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [postgres](https://app.codecov.io/gh/apache/superset/pull/41425/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [presto](https://app.codecov.io/gh/apache/superset/pull/41425/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `40.82% <0.00%> (-0.01%)` | :arrow_down: |
| [python](https://app.codecov.io/gh/apache/superset/pull/41425/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `40.82% <0.00%> (-18.69%)` | :arrow_down: |
| [sqlite](https://app.codecov.io/gh/apache/superset/pull/41425/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [unit](https://app.codecov.io/gh/apache/superset/pull/41425/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/superset/pull/41425?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(explore): apply per-datasource access check on the legacy explore view [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #41425:
URL: https://github.com/apache/superset/pull/41425#discussion_r3525486090
##########
tests/integration_tests/core_tests.py:
##########
@@ -899,6 +899,23 @@ def test_explore_redirect(self, mock_command: mock.Mock):
rv = self.client.get(f"/explore/?form_data={quote(json.dumps(form_data))}")
assert rv.headers["Location"] == f"/explore/?form_data_key={random_key}"
+ @pytest.mark.usefixtures("load_energy_table_with_slice")
+ @mock.patch("superset.security.SupersetSecurityManager.raise_for_access")
+ def test_explore_view_checks_datasource_access(
+ self, mock_raise_for_access: mock.Mock
+ ) -> None:
+ """The explore view runs the per-datasource access check on the loaded
+ datasource, consistent with the explore command, before rendering its
+ metadata."""
+ self.login(ADMIN_USERNAME)
+ tbl_id = self.table_ids.get("energy_usage")
Review Comment:
**Suggestion:** Add an explicit type annotation for this local variable so its optional integer type is clear and consistent with the type-hinting rule. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
This is newly added Python code, and `tbl_id` is a variable whose type can be annotated (it is an optional integer from `dict.get`). The rule requires type hints on relevant variables that can be annotated, so the omission is a real violation.
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=6070193d36f44e07af089267a16c1e66&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=6070193d36f44e07af089267a16c1e66&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:** tests/integration_tests/core_tests.py
**Line:** 911:911
**Comment:**
*Custom Rule: Add an explicit type annotation for this local variable so its optional integer type is clear and consistent with the type-hinting rule.
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%2F41425&comment_hash=393dfa9be149fa95c209e591721b94b72abac5a671cff3ad780c2b6ce5bfd8e4&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41425&comment_hash=393dfa9be149fa95c209e591721b94b72abac5a671cff3ad780c2b6ce5bfd8e4&reaction=dislike'>👎</a>
##########
tests/integration_tests/core_tests.py:
##########
@@ -899,6 +899,23 @@ def test_explore_redirect(self, mock_command: mock.Mock):
rv = self.client.get(f"/explore/?form_data={quote(json.dumps(form_data))}")
assert rv.headers["Location"] == f"/explore/?form_data_key={random_key}"
+ @pytest.mark.usefixtures("load_energy_table_with_slice")
+ @mock.patch("superset.security.SupersetSecurityManager.raise_for_access")
+ def test_explore_view_checks_datasource_access(
+ self, mock_raise_for_access: mock.Mock
+ ) -> None:
+ """The explore view runs the per-datasource access check on the loaded
+ datasource, consistent with the explore command, before rendering its
+ metadata."""
+ self.login(ADMIN_USERNAME)
+ tbl_id = self.table_ids.get("energy_usage")
+
+ self.client.post(f"/explore/table/{tbl_id}/")
+
+ mock_raise_for_access.assert_called_once()
+ _, kwargs = mock_raise_for_access.call_args
Review Comment:
**Suggestion:** Add a concrete type annotation for the extracted call arguments mapping to satisfy required typing for relevant newly added variables. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
This unpacking introduces a new local variable `kwargs` in Python code without a type hint. Since the rule covers relevant variables that can be annotated, this omission matches the stated violation.
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=516db0829ae34720be209eb1f8a63c4e&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=516db0829ae34720be209eb1f8a63c4e&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:** tests/integration_tests/core_tests.py
**Line:** 916:916
**Comment:**
*Custom Rule: Add a concrete type annotation for the extracted call arguments mapping to satisfy required typing for relevant newly added variables.
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%2F41425&comment_hash=d1acbed18247de249511b5bae3aba67e920781130e8ba62531cfbb9c35e5a728&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41425&comment_hash=d1acbed18247de249511b5bae3aba67e920781130e8ba62531cfbb9c35e5a728&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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org