Repository navigation
fix(dashboard): resolve chart datasources across types in access checks - #43781
aminghadersohi merged 6 commits into
Conversation
Code Review Agent Run #6c6a90Actionable Suggestions - 0Additional Suggestions - 4
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 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #43781 +/- ##
=======================================
Coverage 79.41% 79.42%
=======================================
Files 2895 2895
Lines 167939 167986 +47
Branches 38894 38902 +8
=======================================
+ Hits 133375 133424 +49
Misses 32064 32064
+ Partials 2500 2498 -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:
|
48f05c5 to
74fbe78
Compare
Code Review Agent Run #ef6df2Actionable Suggestions - 0Review 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 |
aminghadersohi
left a comment
There was a problem hiding this comment.
Reviewed at 74fbe7866c933d9bf6b32c3d27b35a4d68741bec. I verified the underlying bug independently rather than taking the description on faith, and ran the test suite.
This fixes a real privilege escalation, and that deserves to be said plainly
The bypass is exactly as described, and I confirmed the chain at head:
Dashboard.datasourcesis{slc.datasource for slc in self.slices if slc.datasource}(superset/models/dashboard.py:271)Slice.datasourcereturnsself.table(superset/models/slice.py:187-188)Slice.table'sprimaryjoinis pinned toSlice.datasource_type == 'table'(superset/models/slice.py:156-164)
So a dashboard composed solely of semantic-view charts produces an empty datasources set, the old not dashboard.datasources short-circuits to True, and every authenticated user is granted access. That is a genuine authorization bypass, and this PR closes it. Nice find — it is the kind of bug that hides precisely because the permissive branch looks like a harmless "nothing to check" guard.
Rule-26 mutation check (RAN): reverting only the three production files to the merge base and keeping the tests yields 12 failures / 22 passes. Critically, test_gate_denies_semantic_dashboard_without_grant (semantic_view_access_test.py:283) fails on base and passes here — the bypass is genuinely covered, not just asserted. Unreverted, the suite is 34 passed (semantic_view_access_test.py + subjects/test_raise_for_access.py).
Fail-closed: I checked every resolution path, and they all hold
Slice.resolved_datasource (superset/models/slice.py:191-235) returns None — never something permissive — for:
- missing
datasource_id(slice.py:208) - unknown/unsupported
datasource_type→DatasourceTypeNotSupportedError→ caught - deleted datasource row →
DatasourceNotFound→ caught - a resolved model with no
perm, e.g.SavedQuery(slice.py:235)
And every consumer treats None as inaccessible, not absent: the dashboard gate (manager.py:4794), the chart branch (manager.py:4814-4819), and the guest branch, which is deliberately left table-pinned (manager.py:4835-4842) because the token datasets allowlist is dataset-id space. That last decision is correct and the comment explaining it is the right call — resolving other types there really would reintroduce id-collision ambiguity.
I agree with keeping the chart-less dashboard accessible: that matches pre-existing behavior, and tightening it would be an unrelated (and much more disruptive) change.
One path is genuinely more permissive than before — please confirm it is intended
Consider a mixed dashboard: one table-backed chart the user cannot access, plus one semantic-view chart the user can.
- Before:
datasources == {table}→any(...)isFalse→ denied. - After: the table fails, the semantic view succeeds → granted.
I do not think this is a regression — it is the pre-existing ANY semantic applied consistently to a datasource type that was previously invisible to the check, and the user does hold datasource_access on a real member datasource. It is also covered by test_gate_allows_semantic_dashboard_for_entitled_user.
But it is a user-visible widening, and UPDATING.md:27 documents only the restrictive direction. Someone reading that note would not learn that users holding only semantic-view grants will now gain access to mixed dashboards that previously 403'd. Worth one clause in the note.
filters.py: consistent with the object gate, but one comment is inaccurate
The type-aware join is right, and the claim that non-table charts still match via the denormalized Slice.perm columns checks out — set_related_perm (superset/models/slice.py:455-465) resolves through DatasourceDAO.sources[...], so semantic-view charts do carry the view's perm. Making the Database join outer is what actually closes the id-collision leak. Good.
However, this comment is not quite true:
superset/dashboards/filters.py:170-172— "a dashboard with no charts is never yielded here (every access predicate is NULL-false after the outer joins)"
get_dataset_access_filters(Slice, security_manager.can_access_all_datasources()) splices a Python bool into the or_(...) (superset/utils/filters.py:37-43). For a user with all_datasource_access (or all-database access) that term is a literal TRUE, so the predicate is or_(NULL, NULL, NULL, NULL, TRUE) → TRUE, and the chart-less row — which now survives the joins because they became outer — is yielded. Previously the inner SqlaTable/Database joins eliminated it.
So the asymmetry the comment describes as universal is actually only true for ordinary users, and the behavior did change for all-datasource users. That change looks correct to me (it brings the list into line with the object gate, which grants chart-less dashboards), so I would keep it and just fix the comment to scope the claim.
Query cost: real, but far more bounded than it first appears
I measured the loader strategies rather than guessing (RAN, via sqlalchemy.inspect):
Dashboard.slices→lazy="select"(one query)Slice.table→lazy="subquery"(one batched query for all member slices)
That means for the overwhelmingly common all-table dashboard, this check issues the same number of queries as before — zero delta, at any chart count. The old code walked dashboard.slices and touched slc.datasource too.
The extra cost is confined to non-table datasources: one DatasourceDAO.get_datasource query per unique (type, id). Worst case is a dashboard of N distinct semantic views where the user can access none → +N queries on every load; best case is +1 via the short-circuit.
You already dedupe per (type, id), short-circuit on first success, and document the cost in the docstring — that is the right set of mitigations, and I would not block on this. If you want to close it out, a single batched fetch grouped by type would flatten the worst case to one query per distinct type. Optional.
Test coverage — two small gaps
The bypass and the fail-closed paths are well covered (test_gate_denies_dashboard_of_unresolvable_datasources:323, test_gate_denies_dashboard_with_datasource_less_chart:348). Two things I would tighten:
test_list_filter_shows_semantic_dashboard_to_entitled_user(:452) passes on the reverted production code too. The fixture creates aSqlaTablesharing numeric id1with theSemanticView, so base's unconstrained join still matches and the row survives. The same collision that makes the leak test (:478) meaningful neuters this one. Giving the entitled-user case a non-colliding id would make it actually discriminate.- There is no gate-level DENIED assertion for an unsupported
datasource_type; it is only covered at the resolver level (test_resolved_datasource_unknown_type_is_none:202). Cheap to add given the fixtures already exist.
Merge state
This PR is currently conflicting — the API reports mergeable: false, mergeable_state: dirty against master. It will need a rebase before it can land. CI at this head is otherwise clean: 60 success / 9 skipped / 3 neutral, zero failures.
Net: the security reasoning is sound, the fail-closed discipline is consistent, and the inline comments explaining why each decision was made (especially the deliberately table-pinned guest branch) are unusually good. My only substantive asks are the UPDATING.md clause for the mixed-dashboard widening and the scoped-down filters.py comment; the rest is optional polish.
Reviewed by an automated agent. Findings above were verified against 74fbe7866c933d9bf6b32c3d27b35a4d68741bec; test results and loader strategies were executed, not inferred. Per project policy I am not casting an approval.
A dashboard composed solely of semantic-view charts was open to any authenticated user: the dashboard branch of raise_for_access falls back to datasource-based access when no explicit viewers exist, and it treated an empty Dashboard.datasources set as 'nothing to check'. That set is built from Slice.datasource, whose relationship is pinned to datasource_type == 'table', so semantic-view charts never populate it and the check passed vacuously — exposing the dashboard shell (title, layout, chart names, native-filter defaults) to scoped users holding no datasource_access grant, while an equivalent regular-dataset dashboard was correctly denied. The same table-only assumption also failed closed: the list filter's inner SqlaTable join hid semantic-view dashboards from users who DO hold the grant (and could bind a semantic-view chart to an unrelated table sharing its numeric id), and the standalone chart branch denied entitled semantic-view users. Fix: a Slice.resolved_datasource property that resolves the datasource across types via DatasourceDAO, used by the dashboard and chart branches of raise_for_access (a chart whose datasource cannot be resolved now counts as inaccessible, never as absent; chart-less dashboards stay accessible), and a type-constrained outer join in DashboardAccessFilter so non-table charts survive into the perm-based access clauses. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JRLEJS4mUqKBoPjSjviKUW
… resolution Applied from the six-lens launch-reviews round on the SC-111233 fix: - resolve member-chart datasources lazily with per-(type,id) dedup so the first accessible datasource short-circuits the remaining lookups - guard the resolver against models that carry no perm (SavedQuery) and against DatasourceValueIsIncorrect; drop the dead None/'' fast-path - pin the NULL-datasource_id deny decision with a test; document the behaviour tightening in UPDATING.md - record the deliberately table-pinned embedded-guest allowlist decision and the list/gate empty-dashboard asymmetry in comments Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JRLEJS4mUqKBoPjSjviKUW
…pported-type gate pin, list-widening docs Review follow-ups on apache#43781 plus the rebase onto master: - rebased over apache#43649's semantic-view display work; the resolver now uses the new type-guarded semantic_view relationship as its fast path instead of a DAO query - entitled-visibility list test repointed at a non-colliding view id so it discriminates the type-aware join (the colliding view keeps its own entitled-visibility test); gate-level denial pinned for an unsupported datasource_type - UPDATING.md records the all_datasource_access list widening (chart-less no-viewer dashboards now listed, matching the object gate) and the branch-C comment scopes its never-yielded claim to ordinary users Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JRLEJS4mUqKBoPjSjviKUW
74fbe78 to
f6af4bb
Compare
|
Thanks for the review — all four items addressed at head
Suite is 36 passing in the regression file (981 across dashboards/subjects/semantic_layers/security), pre-commit green. 🤖 Comment by Claude Code on behalf of @mikebridge |
aminghadersohi
left a comment
There was a problem hiding this comment.
Re-reviewed at f6af4bb54c (rebased head). Three of the four round-1 items are confirmed fixed by reverting production files and re-running the tests; one is partially addressed. One new finding.
Round-1 items
- Non-colliding entitled fixture — fixed. With
superset/dashboards/filters.pyalone reverted to the merge base,test_list_filter_shows_semantic_dashboard_to_entitled_usernow fails (it passed on base before). It discriminates. - Gate-level unsupported-type pin — fixed. With
superset/security/manager.pyalone reverted,test_gate_denies_dashboard_of_unsupported_datasource_typefails. - Branch-C comment — fixed. The scoped claim is accurate: for ordinary users the chart-less row is
or_(NULL, NULL, NULL, NULL, false), and forall_datasource_accessholders the spliced literal isTrue. UPDATING.md— partially addressed. Theall_datasource_accesslist widening is now documented; the object-gate widening round 1 asked about is not. See inline.
The same manager.py revert also fails test_gate_denies_semantic_dashboard_without_grant, test_gate_denies_dashboard_of_unresolvable_datasources, test_gate_denies_dashboard_with_datasource_less_chart and test_gate_allows_semantic_chart_for_entitled_user — the bypass is genuinely covered, not just asserted. 36 pass at head.
New finding
The resolution of which datasource a chart uses is correct across types, but the predicate used to authorize it is narrower than this codebase's own definition of semantic-view entitlement: a parent semantic-layer datasource_access grant is dropped, so a legitimately entitled user is denied the dashboard and the standalone chart. Reproduced against this head; details inline on superset/security/manager.py.
It fails closed, so it is not a security hole — but for the dashboard gate it is a behaviour regression relative to pre-PR, where that user got in through the not dashboard.datasources fail-open.
Nit
set_related_perm (superset/models/slice.py:499, pre-existing, off-diff) does DatasourceDAO.sources[target.datasource_type] — an unguarded dict subscript that raises KeyError for any unsupported or NULL datasource_type. That is why the new gate test has to build its slice transiently. A .get() with an early return would let such rows round-trip and would let that test use a persisted fixture.
CI at this head: 47 success / 9 skipped / 3 neutral, zero failures, taking the newest run per leg name.
Code Review Agent Run #3ef59cActionable Suggestions - 0Additional Suggestions - 3
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 |
…tion A datasource_access grant on a semantic view's PARENT LAYER already covers the view on the data path (SemanticView.raise_for_access's layer-perm fallback), but object authorization checked only the view perm: the dashboard/chart gates denied layer-grant holders and the dashboard list filter never surfaced their dashboards (SC-119501, raised in review of this PR and folded in rather than fast-followed). Mirror the same fallback, reusing the existing perm: the generic datasource branch of raise_for_access gains a parent-layer perm clause (via a small resolver that is inert for non-semantic datasources), and DashboardAccessFilter joins the layer through the same type-guarded outer-join shape as the SqlaTable join to match the layer perm in its access clauses. Layer-grant tests cover the dashboard gate, the standalone chart gate, and list visibility (both dashboards of the shared test layer); all deny paths stay pinned. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JRLEJS4mUqKBoPjSjviKUW
|
@aminghadersohi — the semantic-layer-grant finding is now resolved in this PR (Mike's call: fold in rather than fast-follow), at head
(Posting here as the re-review request — the formal request API 404s on the fork head.) 🤖 Comment by Claude Code on behalf of @mikebridge |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
From the 3-lens round on the sc-119501 commit: the layer fallback is now a guarded predicate (_semantic_layer_grant_allows) that skips the permission lookup when no parent layer exists, matching the data path's guard; the list filter's layer clause gets an explaining variable with the accepted double perm fetch documented against sc-119500; UPDATING.md records that a parent-layer grant also satisfies the dashboard fallback; and two deny pins land — a layer grant is inert for table-backed dashboards, and another layer's perm does not admit this layer's views. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JRLEJS4mUqKBoPjSjviKUW
aminghadersohi
left a comment
There was a problem hiding this comment.
Re-reviewed at 27a1958d14.
The layer-grant finding is fixed, and it did not over-correct
Verified by execution rather than by reading the diff. Granting only the persisted layer perm [alpha](id:013406d0…), with the view holding its own separate perm [alpha].[va](id:201):
| grant held | dashboard gate | expected |
|---|---|---|
parent layer alpha |
allowed | allowed |
view va |
allowed | allowed |
other layer beta |
denied | denied |
other view vb |
denied | denied |
| unrelated table perm | denied | denied |
| none | denied | denied |
| empty-string perm | denied | denied |
A table-backed dashboard stays denied under {alpha}, {beta} and {alpha, beta} — the fallback does not leak outside semantic views. The list filter matches the gate exactly: layer-alpha grant → ['dash alpha'], layer-beta → ['dash beta'], view-va → ['dash alpha'], no grants → []. The new SemanticView/SemanticLayer outer joins do not multiply rows into a cross-layer match. No fail-open.
Reverting security/manager.py + dashboards/filters.py to f6af4bb5 fails exactly the three new ALLOW tests (test_gate_allows_semantic_dashboard_for_layer_grant, test_gate_allows_semantic_chart_for_layer_grant, test_list_filter_layer_grant_lists_all_layer_dashboards), so they discriminate. The two guard tests pass on both sides by design — that is correct for a non-widening assertion, not a gap. 41 pass at head.
CI is red, and it is this PR's own
test-sqlite and test-postgres (current) both fail on one test — tests/integration_tests/security_tests.py::TestSecurityManager::test_all_database_access — with mock.semantic_layer.perm bound as a SQL parameter (test-postgres-required is just the aggregator). Single run per workflow at this commit, nothing cancelled or superseded; Python-Unit is green. Cause and fix inline on security/manager.py.
Also outstanding
- Semantic-view renames desync
Slice.perm, so the list hides a dashboard the gate admits. Root cause and an A/B control against the dataset path are inline ondashboards/filters.py. Credit to codeant for spotting the stale-reference direction. UPDATING.md— the layer-grant clause landed, but my round-2 thread there is still open for a different reason: the object-gate widening on mixed dashboards is still undocumented (a user holding only a semantic-view grant can now open a mixed dashboard that previously 403'd, because the fallback is anany()over all member charts rather than table-backed ones only). One clause.- Nit — bito's deleted-datasource point is real: I reproduced a chart whose table row is gone surviving the now-outer join and matching a stale
Slice.perm, so the list yields['dash deleted table']while the gate denies. It is narrower than it reads, though:dataset_after_delete/semantic_view_after_deletedrop the PVM, so it only fires with an orphaned PVM. Worth a follow-up, not this PR.
Code Review Agent Run #41e559Actionable Suggestions - 0Review 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 |
…ashboard widening The layer-perm fallback duck-typed its way to the parent layer (getattr on semantic_layer/perm), so a MagicMock datasource with __class__ reassigned to SqlaTable — the integration suite's get_datasource_mock() — auto-created a truthy semantic_layer.perm child mock that reached the DB driver as a bind parameter (test_all_database_access, sqlite + postgres lanes). The fallback now isinstance-checks for SemanticView before any lookup, which is also the durable posture: a future model growing a semantic_layer attribute can no longer silently start consulting layer grants. Unit pin asserts a non-SemanticView datasource never reaches can_access. UPDATING.md documents the intended object-gate widening on mixed dashboards: the fallback considers every member chart, so a grant on any single member datasource (including a semantic view or its parent layer) opens a dashboard that previously denied its holder. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JRLEJS4mUqKBoPjSjviKUW
|
@aminghadersohi — both items addressed at head CI regression ( UPDATING.md mixed-dashboard widening: confirmed intended — it's the pre-existing at-least-one-member semantics applied uniformly across datasource types rather than only to table-backed members (and the chart-list follow-up #43848 keeps the surfaces aligned). Added your suggested clause to the entry, covering the semantic-view-or-parent-layer grant case. Left for follow-ups as you suggested: the |
The chart list's dataset-access fallback inner-joined Slice.datasource_id == SqlaTable.id with no datasource_type predicate, failing in both directions for charts on non-table datasource types: semantic-view charts were dropped from the list for users holding the view's (or its parent layer's) datasource_access grant, and the type-less join could bind a semantic-view chart to an unrelated table sharing its numeric id, leaking it to holders of the colliding table's database grant (SC-119500; the dashboard-side siblings were fixed in apache#43781). - table_backed_slice_join in utils/filters.py is the single authoritative type-guarded ON-clause (FR-004); DashboardAccessFilter and ChartFilter both consume it - ChartFilter branch C: outer type-guarded joins + the semantic-layer grant clause, mirroring DashboardAccessFilter (FR-002); access matches through the perm columns denormalized by set_related_perm, uniformly across perm-carrying types - the dead _apply_legacy path (zero callers) is deleted, not fixed - get_dataset_access_filters grows named extra_access_clauses and an explicit include_all (deferred-in from the apache#43781 review round) - new contract-matrix regression file pins every grant x type cell, including the id-collision control Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JRLEJS4mUqKBoPjSjviKUW
Code Review Agent Run #e55257Actionable Suggestions - 0Review 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 |
1 similar comment
Code Review Agent Run #e55257Actionable Suggestions - 0Review 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 |
aminghadersohi
left a comment
There was a problem hiding this comment.
Verified at e0dd7eb200. Both round-3 items are closed and nothing new came up.
The CI regression is fixed — confirmed at the test level, not the aggregate. test-sqlite is 2677 passed, 175 skipped; test-postgres (current) is 2685 passed, 167 skipped. Each is exactly one more pass than round 3's 1 failed, 2676 passed, 175 skipped / 1 failed, 2684 passed, 167 skipped, with identical skip counts — so security_tests.py::TestSecurityManager::test_all_database_access ran and passed rather than being skipped over. Zero MagicMock occurrences in either log.
The isinstance guard does not over-narrow. This was the one thing worth checking hard, because a guard that is too tight would silently re-open the empty-Dashboard.datasources bypass this PR exists to close. isinstance(resolved, SemanticView) is True on every path the gate can reach a view through:
| resolution path | type | isinstance |
|---|---|---|
Slice.semantic_view relationship (lazy="selectin") |
SemanticView |
True |
Slice.resolved_datasource — what the gate actually calls |
SemanticView |
True |
DatasourceDAO.get_datasource |
SemanticView |
True |
fresh load after expire_all() |
SemanticView |
True |
| direct session query | SemanticView |
True |
No subclasses exist — SemanticViewDAO is a generic parameter, and SemanticViewABC is a different class that none of these paths return — so the guard is production-equivalent to the old getattr and differs only for mock-shaped objects, which is exactly the intent.
The round-3 truth table still holds, ALLOW baselines checked before the DENYs: parent layer / view / both → allowed; other layer, other view, unrelated table perm, no grants, empty-string perm → denied. Table-backed dashboards stay inert under {alpha}, {beta} and {alpha, beta}, and the list filter matches the gate.
test_layer_fallback_never_consults_grants_for_non_semantic_datasource goes red when security/manager.py alone is reverted to 27a1958d, so it pins the guard and not the mock; assert_not_called() pins the ordering as well.
The function-local import is genuinely required, which I checked rather than assumed since it would be worth removing otherwise. A module-level from superset.semantic_layers.models import SemanticView fails with cannot import name 'feature_flag_manager' from partially initialized module 'superset' — the cycle is security.manager → semantic_layers.models → superset.extensions → security.manager. It is also not on a hot path: one call site, as the fourth disjunct of a short-circuiting or, and the list filter is pure SQL and never calls it. Cached cost measures ~500 ns.
The UPDATING.md clause reads accurately.
Still open and correctly deferred, not a blocker here: the Slice.perm rename desync (SC-119502). semantic_view_before_update is untouched by this commit, which matches the plan.
The chart list's dataset-access fallback inner-joined Slice.datasource_id == SqlaTable.id with no datasource_type predicate, failing in both directions for charts on non-table datasource types: semantic-view charts were dropped from the list for users holding the view's (or its parent layer's) datasource_access grant, and the type-less join could bind a semantic-view chart to an unrelated table sharing its numeric id, leaking it to holders of the colliding table's database grant (SC-119500; the dashboard-side siblings were fixed in apache#43781). - table_backed_slice_join in utils/filters.py is the single authoritative type-guarded ON-clause (FR-004); DashboardAccessFilter and ChartFilter both consume it - ChartFilter branch C: outer type-guarded joins + the semantic-layer grant clause, mirroring DashboardAccessFilter (FR-002); access matches through the perm columns denormalized by set_related_perm, uniformly across perm-carrying types - the dead _apply_legacy path (zero callers) is deleted, not fixed - get_dataset_access_filters grows named extra_access_clauses and an explicit include_all (deferred-in from the apache#43781 review round) - new contract-matrix regression file pins every grant x type cell, including the id-collision control Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JRLEJS4mUqKBoPjSjviKUW
SUMMARY
Authorization for dashboards and charts resolved member-chart datasources through table-pinned relationships, with two opposite failures for charts on non-table datasources (semantic views):
Fail open (the reported bug):
raise_for_access's dashboard branch falls back to datasource-based access when a dashboard has no explicit viewers, and treated an emptyDashboard.datasourcesset as "nothing to check → allow". That set is built fromSlice.datasource, whose relationship joins ondatasource_type == 'table', so a dashboard composed solely of semantic-view charts presented an empty set and opened for any authenticated user — exposing the dashboard shell (title, layout/tabs, chart names, native-filter defaults) to scoped users with nodatasource_accessgrant. An equivalent regular-dataset dashboard was correctly denied (403/404). Chart data was never exposed (the query-context branch still denied per chart), which is how QA noticed the inconsistency: the semantic dashboard rendered read-only with per-chart access-error cards while the regular one 404'd.Fail closed (two siblings, same root cause): the dashboard list filter's dataset fallback inner-joins
Slice.datasource_id == SqlaTable.idwith no type predicate, so semantic-view charts were dropped and users with the grant never saw those dashboards listed (they could still open them by URL) — and the type-less join could bind a semantic-view chart to an unrelated table sharing its numeric id. The standalone chart branch (chart.datasource and can_access_datasource(...)) likewise denied entitled semantic-view users.The fix is one mechanism: a
Slice.resolved_datasourceproperty that resolves the chart's datasource across datasource types viaDatasourceDAO(semantic views already carrypermstrings and participate in data-access grants), used by bothraise_for_accessbranches — a chart whose datasource cannot be resolved counts as inaccessible, never as absent, while dashboards with no charts remain accessible (existing pinned behaviour) — plus a type-constrained outer join inDashboardAccessFilterso non-table charts survive into the perm-based access clauses (Slice.permis already denormalized across types byset_related_perm).Behaviour changes beyond the semantic-view cases: a dashboard whose charts' datasource rows have all been hard-deleted is now denied by the dataset fallback instead of allowed (fail-closed on dangling references).
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — authorization behaviour; see TESTING INSTRUCTIONS.
TESTING INSTRUCTIONS
pytest tests/unit_tests/dashboards/semantic_view_access_test.py— new regression suite covering the resolver, bothraise_for_accessbranches (deny without grant / allow with grant / dangling / empty dashboard), and the list filter (entitled visibility, no-grant emptiness, id-collision control). Reverting thesuperset/changes makes 8 of the 15 fail (fail-open, fail-closed, collision, and resolver cases).pytest tests/unit_tests/subjects/test_raise_for_access.py— existing gate tests, updated to build dashboards with member slices.SEMANTIC_LAYERSenabled, give a user a Gamma-like role with no data grants, share a dashboard containing only semantic-view charts, and open its URL as that user → access is now denied, matching a regular-dataset dashboard. Grant the userdatasource_accesson the semantic view → the dashboard opens and appears in the Dashboards list.ADDITIONAL INFORMATION
🤖 Generated with Claude Code
https://claude.ai/code/session_01JRLEJS4mUqKBoPjSjviKUW