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/03/08 21:55:03 UTC
[PR] refactor(dao): centralize object access validation in BaseDAO [superset]
sha174n opened a new pull request, #38497:
URL: https://github.com/apache/superset/pull/38497
<!---
Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
Example:
fix(dashboard): load charts correctly
-->
### SUMMARY
<!--- Describe the change below, including rationale and design decisions -->
This PR improves the consistency and robustness of access control enforcement across Superset by centralizing object-level validation within the Data Access Object (DAO) layer. Previously, some API endpoints and commands relied on shallow object retrieval without enforcing context-aware ownership checks, leading to inconsistent authorization behaviors.
**Key Changes:**
- **Centralized Validation:** Introduced a new get_with_check() classmethod in BaseDAO. This ensures that entities retrieved by ID automatically undergo strict, context-aware authorization checks via security_manager.raise_for_access().
-**API Standardization:** Refactored legacy API endpoints across Databases, Datasources, Queries, and Users to utilize the new get_with_check() method, ensuring consistent 403/404 handling when users attempt to retrieve resources outside their provisioned roles.
-**MCP Tool Robustness:** Added missing command.validate() lifecycle calls to Model Context Protocol (MCP) commands (e.g., ChartDataCommand, UpdateChartCommand, CreateDashboardCommand) to guarantee that authorization rules are strictly evaluated prior to execution.
- **Test Suite Expansion:** Added comprehensive unit tests targeting DAO access validation logic to prevent future regressions.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
<!--- Skip this if not applicable -->
### TESTING INSTRUCTIONS
<!--- Required! What steps can be taken to manually verify the changes? -->
1. Log in with a restricted role (e.g., Gamma) that only has access to a specific subset of datasets/databases.
2. Manually construct an API request to fetch metadata for a database or datasource ID that belongs to a different role (e.g., /api/v1/database/{id}/schemas/).
3. Verify the API safely rejects the request with a 404 Not Found or 403 Forbidden rather than returning the object metadata.
4. Attempt to access a SavedQuery or cancel a query (stop_query) that was executed by a different user. Verify the action is gracefully blocked.
5. Execute the updated DAO test suite: pytest tests/unit_tests/daos/dao_access_control_test.py
### ADDITIONAL INFORMATION
<!--- Check any relevant boxes with "x" -->
<!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] 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] refactor: improve metadata access control and authorization [superset]
Posted by "sha174n (via GitHub)" <gi...@apache.org>.
sha174n closed pull request #38497: refactor: improve metadata access control and authorization
URL: https://github.com/apache/superset/pull/38497
--
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] refactor(dao): centralize object access validation in BaseDAO [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #38497:
URL: https://github.com/apache/superset/pull/38497#issuecomment-4020093929
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] refactor(dao): centralize object access validation in BaseDAO [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #38497:
URL: https://github.com/apache/superset/pull/38497#issuecomment-4020099014
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/38497?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 `15.74074%` with `91 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 54.75%. Comparing base ([`60577bc`](https://app.codecov.io/gh/apache/superset/commit/60577bcd979fa92c97aac57446050e866c49b22b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`ede6138`](https://app.codecov.io/gh/apache/superset/commit/ede6138da7a284f81ae7251b025330c1a12bc568?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/38497?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/databases/api.py](https://app.codecov.io/gh/apache/superset/pull/38497?src=pr&el=tree&filepath=superset%2Fdatabases%2Fapi.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvZGF0YWJhc2VzL2FwaS5weQ==) | 0.00% | [25 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/38497?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/daos/base.py](https://app.codecov.io/gh/apache/superset/pull/38497?src=pr&el=tree&filepath=superset%2Fdaos%2Fbase.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvZGFvcy9iYXNlLnB5) | 35.00% | [13 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/38497?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/connectors/sqla/models.py](https://app.codecov.io/gh/apache/superset/pull/38497?src=pr&el=tree&filepath=superset%2Fconnectors%2Fsqla%2Fmodels.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvY29ubmVjdG9ycy9zcWxhL21vZGVscy5weQ==) | 0.00% | [10 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/38497?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/commands/security/update.py](https://app.codecov.io/gh/apache/superset/pull/38497?src=pr&el=tree&filepath=superset%2Fcommands%2Fsecurity%2Fupdate.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvY29tbWFuZHMvc2VjdXJpdHkvdXBkYXRlLnB5) | 25.00% | [6 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/38497?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/row\_level\_security/api.py](https://app.codecov.io/gh/apache/superset/pull/38497?src=pr&el=tree&filepath=superset%2Frow_level_security%2Fapi.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvcm93X2xldmVsX3NlY3VyaXR5L2FwaS5weQ==) | 14.28% | [6 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/38497?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/commands/security/create.py](https://app.codecov.io/gh/apache/superset/pull/38497?src=pr&el=tree&filepath=superset%2Fcommands%2Fsecurity%2Fcreate.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvY29tbWFuZHMvc2VjdXJpdHkvY3JlYXRlLnB5) | 20.00% | [4 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/38497?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/databases/decorators.py](https://app.codecov.io/gh/apache/superset/pull/38497?src=pr&el=tree&filepath=superset%2Fdatabases%2Fdecorators.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvZGF0YWJhc2VzL2RlY29yYXRvcnMucHk=) | 0.00% | [4 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/38497?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/models/helpers.py](https://app.codecov.io/gh/apache/superset/pull/38497?src=pr&el=tree&filepath=superset%2Fmodels%2Fhelpers.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbW9kZWxzL2hlbHBlcnMucHk=) | 0.00% | [4 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/38497?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/views/users/api.py](https://app.codecov.io/gh/apache/superset/pull/38497?src=pr&el=tree&filepath=superset%2Fviews%2Fusers%2Fapi.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvdmlld3MvdXNlcnMvYXBpLnB5) | 33.33% | [4 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/38497?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...perset/mcp\_service/chart/tool/get\_chart\_preview.py](https://app.codecov.io/gh/apache/superset/pull/38497?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fchart%2Ftool%2Fget_chart_preview.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2UvY2hhcnQvdG9vbC9nZXRfY2hhcnRfcHJldmlldy5weQ==) | 0.00% | [3 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/38497?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| ... and [10 more](https://app.codecov.io/gh/apache/superset/pull/38497?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | |
:x: Your project check has failed because the head coverage (99.24%) is below the target coverage (100.00%). You can increase the head coverage or adjust the [target](https://docs.codecov.com/docs/commit-status#target) coverage.
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #38497 +/- ##
===========================================
- Coverage 64.82% 54.75% -10.08%
===========================================
Files 1817 2520 +703
Lines 72121 127502 +55381
Branches 22955 29340 +6385
===========================================
+ Hits 46754 69813 +23059
- Misses 25367 57347 +31980
- Partials 0 342 +342
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/38497/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [presto](https://app.codecov.io/gh/apache/superset/pull/38497/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `41.63% <15.74%> (?)` | |
| [python](https://app.codecov.io/gh/apache/superset/pull/38497/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `41.63% <15.74%> (?)` | |
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 Sentry](https://app.codecov.io/gh/apache/superset/pull/38497?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