Skip to content

fix(dashboard): resolve chart datasources across types in access checks - #43781

Merged
aminghadersohi merged 6 commits into
apache:masterfrom
mikebridge:sc-111233-semantic-view-dashboard-authz
Sep 5, 2026
Merged

aminghadersohi merged 6 commits into
apache:masterfrom
mikebridge:sc-111233-semantic-view-dashboard-authz

Conversation

@mikebridge

Copy link
Copy Markdown
Member

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 empty Dashboard.datasources set as "nothing to check → allow". That set is built from Slice.datasource, whose relationship joins on datasource_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 no datasource_access grant. 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.id with 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_datasource property that resolves the chart's datasource across datasource types via DatasourceDAO (semantic views already carry perm strings and participate in data-access grants), used by both raise_for_access branches — 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 in DashboardAccessFilter so non-table charts survive into the perm-based access clauses (Slice.perm is already denormalized across types by set_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

  1. pytest tests/unit_tests/dashboards/semantic_view_access_test.py — new regression suite covering the resolver, both raise_for_access branches (deny without grant / allow with grant / dangling / empty dashboard), and the list filter (entitled visibility, no-grant emptiness, id-collision control). Reverting the superset/ changes makes 8 of the 15 fail (fail-open, fail-closed, collision, and resolver cases).
  2. pytest tests/unit_tests/subjects/test_raise_for_access.py — existing gate tests, updated to build dashboards with member slices.
  3. Manual: with SEMANTIC_LAYERS enabled, 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 user datasource_access on the semantic view → the dashboard opens and appears in the Dashboards list.

ADDITIONAL INFORMATION

  • Has associated issue: SC-111233 (Preset Shortcut)
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • 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

🤖 Generated with Claude Code

https://claude.ai/code/session_01JRLEJS4mUqKBoPjSjviKUW

@bito-code-review

bito-code-review Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #6c6a90

Actionable Suggestions - 0
Additional Suggestions - 4
  • superset/security/manager.py - 1
    • Text-only dashboard denied · Line 4782-4790
      The new `resolved_datasources` dict includes entries whose value is `None` for charts with no `datasource_id` (e.g. text/iframe charts). `not resolved_datasources` is then False and `any(...)` is False, so a dashboard whose charts all lack a datasource is now denied. Previously `dashboard.datasources` filtered out `None` (`if slc.datasource`), granting access. Add `if slc.datasource_id` to the comprehension to preserve that behavior while still denying dangling datasources.
  • superset/dashboards/filters.py - 1
    • NULL datasource_type excluded · Line 184-184
      The join condition `Slice.datasource_type == DatasourceType.TABLE` drops legacy charts whose `datasource_type` is NULL/empty. `slices.datasource_type` is nullable and the CHECK constraint allows NULL, and `Slice.resolved_datasource` (slice.py:205) treats NULL/empty as table-backed. Such charts no longer bind to `SqlaTable`/`Database`, so the `Database.id.in_(database_ids)` path in `get_dataset_access_filters` is lost and dashboards can be hidden from database-only users. Consider matching NULL/empty as table.
  • superset/models/slice.py - 1
    • N+1 datasource queries · Line 215-215
      `resolved_datasource` issues a DB query per call for non-table datasources. In `security/manager.py` (dashboard access check, ~line 4782) it runs once per slice in `dashboard.slices`, so a dashboard with N semantic-view/query charts triggers N queries on every access check. Consider batch-resolving datasources (single `DatasourceDAO` query keyed by type/id) rather than per-slice lookups.
  • tests/unit_tests/dashboards/semantic_view_access_test.py - 1
    • Uninitialized SM via __new__ · Line 207-207
      `_gate_sm()` builds the manager via `SupersetSecurityManager.__new__`, skipping `__init__`, so `self.session` is unset. The dashboard tests reach the real `can_access_datasource` -> `raise_for_access(datasource=...)` path; any future branch touching `self.session` (e.g. `has_promiscuous_chart_access`'s `self.session.query(Slice)`) would raise `AttributeError` instead of the asserted `SupersetSecurityException`. Consider a real fixture.
Review Details
  • Files reviewed - 5 · Commit Range: 85ff05f..85ff05f
    • superset/dashboards/filters.py
    • superset/models/slice.py
    • superset/security/manager.py
    • tests/unit_tests/dashboards/semantic_view_access_test.py
    • tests/unit_tests/subjects/test_raise_for_access.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - 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 documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@codecov

codecov Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.47368% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.42%. Comparing base (a6cbd7c) to head (e0dd7eb).
⚠️ Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
superset/security/manager.py 80.00% 2 Missing and 2 partials ⚠️
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     
Flag Coverage Δ
hive 37.77% <13.15%> (-0.02%) ⬇️
mysql 57.50% <50.00%> (-0.01%) ⬇️
postgres 57.54% <50.00%> (-0.01%) ⬇️
presto 39.66% <13.15%> (-0.02%) ⬇️
python 83.87% <89.47%> (+0.01%) ⬆️
sqlite 57.23% <50.00%> (-0.01%) ⬇️
unit 74.36% <81.57%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mikebridge
mikebridge force-pushed the sc-111233-semantic-view-dashboard-authz branch from 48f05c5 to 74fbe78 Compare September 1, 2026 20:37
@bito-code-review

bito-code-review Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #ef6df2

Actionable Suggestions - 0
Review Details
  • Files reviewed - 4 · Commit Range: 85ff05f..74fbe78
    • superset/dashboards/filters.py
    • superset/models/slice.py
    • superset/security/manager.py
    • tests/unit_tests/dashboards/semantic_view_access_test.py
  • Files skipped - 1
    • UPDATING.md - Reason: Filter setting
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - 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 documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@aminghadersohi
aminghadersohi self-requested a review September 2, 2026 20:34

@aminghadersohi aminghadersohi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.datasources is {slc.datasource for slc in self.slices if slc.datasource} (superset/models/dashboard.py:271)
  • Slice.datasource returns self.table (superset/models/slice.py:187-188)
  • Slice.table's primaryjoin is pinned to Slice.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(...) is False → 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:

  1. test_list_filter_shows_semantic_dashboard_to_entitled_user (:452) passes on the reverted production code too. The fixture creates a SqlaTable sharing numeric id 1 with the SemanticView, 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.
  2. 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.

@github-actions github-actions Bot added the requires:rebase Requires rebasing on top of current master label Sep 3, 2026
mikebridge and others added 3 commits September 3, 2026 13:37
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
@mikebridge
mikebridge force-pushed the sc-111233-semantic-view-dashboard-authz branch from 74fbe78 to f6af4bb Compare September 3, 2026 19:42
@mikebridge

Copy link
Copy Markdown
Member Author

Thanks for the review — all four items addressed at head f6af4bb54c:

  1. Rebased onto current master. The conflict was with fix(charts): resolve semantic-view datasource name and link in chart list #43649's semantic-view display work in slice.py; the two resolvers are complementary and now coexist — and resolved_datasource uses fix(charts): resolve semantic-view datasource name and link in chart list #43649's type-guarded semantic_view relationship as its fast path instead of a DAO query (identity-map cached, join predicate enforces the type).
  2. UPDATING.md now records the all_datasource_access widening: holders see every published no-viewer dashboard in the list — including chart-less ones previously hidden by the inner joins — matching what the object gate already allowed them to open.
  3. Branch-C comment scoped: the never-yielded claim now applies to ordinary users only, with the spliced literal True called out for all_datasource_access holders.
  4. Tests: the entitled-visibility list test now uses a non-colliding view (id 2, no table shares it) so it fails on the reverted join — the colliding view keeps its own entitled-visibility test so the type constraint provably doesn't cost entitled users; and a gate-level denial is pinned for an unsupported datasource_type (transient fixture, so the unknown type never hits insert-time perm denormalization).

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

@github-actions github-actions Bot removed the requires:rebase Requires rebasing on top of current master label Sep 3, 2026

@aminghadersohi aminghadersohi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.py alone reverted to the merge base, test_list_filter_shows_semantic_dashboard_to_entitled_user now fails (it passed on base before). It discriminates.
  • Gate-level unsupported-type pin — fixed. With superset/security/manager.py alone reverted, test_gate_denies_dashboard_of_unsupported_datasource_type fails.
  • Branch-C comment — fixed. The scoped claim is accurate: for ordinary users the chart-less row is or_(NULL, NULL, NULL, NULL, false), and for all_datasource_access holders the spliced literal is True.
  • UPDATING.md — partially addressed. The all_datasource_access list 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.

Comment thread superset/security/manager.py Resolved
Comment thread superset/dashboards/filters.py Resolved
Comment thread UPDATING.md Resolved
@bito-code-review

bito-code-review Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #3ef59c

Actionable Suggestions - 0
Additional Suggestions - 3
  • superset/security/manager.py - 1
    • Datasource-less dashboard denied · Line 4817-4817
      Regression: the old `elif not dashboard.datasources or any(...)` granted access when `dashboard.datasources` was empty. `Dashboard.datasources` is `{slc.datasource for slc in self.slices if slc.datasource}`, so a dashboard of only datasource-less charts (text/markdown, `datasource_id=None`) was accessible. Now `member_slices` is non-empty and `member_datasource_accessible()` returns False, so such dashboards are denied. Consider `not any(slc.datasource_id for slc in member_slices)` to preserve the grant.
  • superset/dashboards/filters.py - 1
    • List-gate divergence on deleted datasource · Line 185-193
      Switching the SqlaTable join to `isouter=True` lets a chart whose table datasource was deleted survive the join with NULL SqlaTable/Database, so the dashboard can now match `get_dataset_access_filters` via the stale `Slice.perm.in_(perms)`. The object gate (`member_datasource_accessible` → `resolved_datasource`) returns None for a deleted table and denies it, so the list now yields a dashboard the gate refuses to open. Consider gating table-backed charts on a non-NULL `SqlaTable.id`.
  • superset/models/slice.py - 1
    • hasattr triggers lazy DB load · Line 285-285
      `hasattr(resolved, "perm")` evaluates `Query.perm` (sql_lab.py:370), which lazy-loads `self.database` on every call — a hidden DB query on the fallback path. It only works because `hasattr` swallows the `AttributeError` when `database` is None. Consider an explicit `isinstance(resolved, SavedQuery)` check instead of probing the property.
Review Details
  • Files reviewed - 5 · Commit Range: 78b9f88..f6af4bb
    • superset/dashboards/filters.py
    • superset/models/slice.py
    • superset/security/manager.py
    • tests/unit_tests/dashboards/semantic_view_access_test.py
    • tests/unit_tests/subjects/test_raise_for_access.py
  • Files skipped - 1
    • UPDATING.md - Reason: Filter setting
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - 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 documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

…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
@mikebridge

Copy link
Copy Markdown
Member Author

@aminghadersohi — the semantic-layer-grant finding is now resolved in this PR (Mike's call: fold in rather than fast-follow), at head faea7d9866:

  • The generic datasource branch of raise_for_access gains a parent-layer perm clause via _parent_semantic_layer_perm — the same fallback SemanticView.raise_for_access already enforces on the data path, so can_access_datasource (and with it the dashboard gate and the standalone chart gate) now honors a datasource_access grant on the view's parent layer. The resolver is inert for non-semantic datasources.
  • DashboardAccessFilter joins SemanticView → SemanticLayer through the same type-guarded outer-join shape as its SqlaTable join and matches the layer perm in the access clauses, so layer-grant holders see those dashboards listed.
  • Tests pin layer-grant ALLOW on all three surfaces (gate, chart, list — the list case asserts both dashboards of the shared test layer) and every no-grant DENY stays green; 984 unit tests across dashboards/subjects/semantic_layers/security pass, pre-commit green.

(Posting here as the re-review request — the formal request API 404s on the fork head.)

🤖 Comment by Claude Code on behalf of @mikebridge

@netlify

netlify Bot commented Sep 4, 2026

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit faea7d9
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a9a28b6e7188900073e25a4
😎 Deploy Preview https://deploy-preview-43781--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Comment thread superset/dashboards/filters.py Resolved
Comment thread superset/models/slice.py Resolved
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 aminghadersohi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 on dashboards/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 an any() 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_delete drop the PVM, so it only fires with an orphaned PVM. Worth a follow-up, not this PR.

Comment thread superset/security/manager.py Resolved
Comment thread superset/dashboards/filters.py Resolved
@bito-code-review

bito-code-review Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #41e559

Actionable Suggestions - 0
Review Details
  • Files reviewed - 3 · Commit Range: f6af4bb..27a1958
    • superset/dashboards/filters.py
    • superset/security/manager.py
    • tests/unit_tests/dashboards/semantic_view_access_test.py
  • Files skipped - 1
    • UPDATING.md - Reason: Filter setting
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - 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 documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

…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
@mikebridge

Copy link
Copy Markdown
Member Author

@aminghadersohi — both items addressed at head e0dd7eb200:

CI regression (test_all_database_access): your diagnosis was exact — get_datasource_mock()'s reassigned __class__ doesn't stop MagicMock.__getattr__, so the duck-typed fallback bound mock.semantic_layer.perm as a SQL parameter. Took your suggestion nearly verbatim: _semantic_layer_grant_allows now isinstance-checks for SemanticView before any lookup (keeping the getattr only for the nullable semantic_layer relationship's perm), and the unit test you asked for pins that a non-SemanticView datasource — built exactly like the integration mock, MagicMock with __class__ = SqlaTable — returns False with can_access never called (test_layer_fallback_never_consults_grants_for_non_semantic_datasource). Verified locally on sqlite: at 27a1958d14 the standalone run reproduces your exact Error binding parameter … MagicMock failure; at this head no Mock-bind error remains (the residual standalone failures are a local g.user-None artifact shared by three tests CI passes). CI on this head is the final arbiter for the postgres lane — same driver-level root cause.

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 Slice.perm rename desync is SC-119502 (your semantic_view_before_update propagation fix + A/B evidence are now linked there as the root cause), and the orphaned-PVM edge stays a later nit.

mikebridge added a commit to mikebridge/superset that referenced this pull request Sep 4, 2026
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
@bito-code-review

bito-code-review Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #e55257

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 27a1958..e0dd7eb
    • superset/security/manager.py
    • tests/unit_tests/dashboards/semantic_view_access_test.py
  • Files skipped - 1
    • UPDATING.md - Reason: Filter setting
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - 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 documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

1 similar comment
@bito-code-review

bito-code-review Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #e55257

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 27a1958..e0dd7eb
    • superset/security/manager.py
    • tests/unit_tests/dashboards/semantic_view_access_test.py
  • Files skipped - 1
    • UPDATING.md - Reason: Filter setting
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - 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 documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@aminghadersohi aminghadersohi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@aminghadersohi
aminghadersohi merged commit 630982e into apache:master Sep 5, 2026
73 checks passed
mikebridge added a commit to mikebridge/superset that referenced this pull request Sep 8, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants