fix: apply per-layer datasource access checks in deck_multi charts - #42049
fix: apply per-layer datasource access checks in deck_multi charts#42049sha174n wants to merge 6 commits into
Conversation
The deck_multi visualization renders a list of child layers, each bound to its own datasource referenced by id in the request. Apply the standard datasource access check to every child layer before querying it, and skip any layer the current user cannot access, so a multi-layer chart only returns data from datasources the caller is authorized for. Adds a regression test asserting a child layer whose datasource the user cannot access is skipped rather than queried. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: sha174n <shaitan@zx48.net>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #42049 +/- ##
==========================================
- Coverage 65.19% 65.18% -0.01%
==========================================
Files 2767 2767
Lines 156062 156059 -3
Branches 35717 35715 -2
==========================================
- Hits 101741 101732 -9
- Misses 52361 52365 +4
- Partials 1960 1962 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Two unpersisted tables share a null-id uid, so identity-style membership on the constructed list was unreliable; compare by table_name instead. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Use security_manager.can_access_datasource for the per-layer check and track accessible slices so denied layers are omitted from the returned slice list, not just skipped during querying. Patch the access check in the affected integration tests so they run without a request user. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Code Review Agent Run #a852a7Actionable Suggestions - 0Filtered by Review RulesBito filtered these suggestions based on rules created automatically for your feedback. Manage rules.
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
|
Thanks for digging into this, the deck_multi per-layer check makes sense since each child layer really does bind to its own datasource. Appreciate the test for the denied-layer case too. CI's green, so let's get this merged. |
rusackas
left a comment
There was a problem hiding this comment.
Approving. can_access_datasource() wraps raise_for_access() and catches SupersetSecurityException, so the mock target on the new test is right. GitHub shows conflicts with master now though, so it'll need a rebase before it can merge.
rusackas
left a comment
There was a problem hiding this comment.
Nice fix, the per-layer check makes sense since each deck_multi layer really does bind to its own datasource, and the denied-layer test actually locks it in. LGTM, just needs a rebase off master before it's mergeable.
rusackas
left a comment
There was a problem hiding this comment.
Traced can_access_datasource down to raise_for_access, it's the real gate, not just a post-hoc filter. The continue skips querying entirely for a denied layer, not just the output. New test builds an allowed/denied layer pair and confirms only the allowed one's child viz gets constructed. LGTM, just needs a rebase.
rusackas
left a comment
There was a problem hiding this comment.
One thing before I can sign off here: this patches superset/viz.py, which #41714 removed from master recently, so the diff doesn't apply anymore and GitHub's showing conflicts. The per-layer datasource check is the right instinct, but it needs to be reworked against wherever deck_multi's layer resolution lives now. Happy to take another look once it's rebased.
Dismissing: this diff targets superset/viz.py, which was deleted from master 4 days ago by #41714 (also mine) — the PR can't apply as-is, and the per-layer access-control gap it addresses looks already closed by that refactor (each deck_multi layer now goes through its own datasource authorization via check_resource_permissions on independent explore_json requests). Left a comment on the PR with details.
|
@rusackas You're right, and it goes further than a rebase: #41714 deleted There is also nothing left to port it onto. So this is obsolete rather than rebaseable, and I think closing it is the right call. Happy to open a follow-up if you want test coverage pinning the per-layer behaviour on the new path. |
|
Agreed, this is obsolete now that #41714 pulled the legacy viz.py pipeline out from under it — deck_multi's per-layer access check already happens through QueryContext on the new client-side path. Closing this out, thanks for tracking that down. |
SUMMARY
The
deck_multivisualization renders a list of child layers, each bound to its own datasource referenced by id in the request (deck_slices). This applies the standard datasource access check (security_manager.raise_for_access) to every child layer before it is queried, and skips any layer the current user cannot access — so a multi-layer chart only returns data from datasources the caller is authorized for, consistent with how every other query path is gated.TESTING INSTRUCTIONS
pytest tests/unit_tests/test_viz_get_df_payload.pyAdds
test_deck_multi_skips_child_layers_without_datasource_access: a child layer whose datasource the current user cannot access is skipped rather than queried.ADDITIONAL INFORMATION