Skip to content

fix(views): enforce per-chart access check in legacy form_data endpoint#40497

Open
sha174n wants to merge 11 commits into
apache:masterfrom
sha174n:fix/views-api-form-data-authz
Open

fix(views): enforce per-chart access check in legacy form_data endpoint#40497
sha174n wants to merge 11 commits into
apache:masterfrom
sha174n:fix/views-api-form-data-authz

Conversation

@sha174n
Copy link
Copy Markdown
Contributor

@sha174n sha174n commented May 28, 2026

SUMMARY

The legacy Api.query_form_data (GET /api/v1/form_data/?slice_id=)
returned slc.form_data verbatim with only @has_access_api as the
gate, which is satisfied by any authenticated user (and by Public
role on deployments using PUBLIC_ROLE_LIKE). The sibling
Api.query() already validates via
query_context.raise_for_access(), and the modern ChartRestApi.get
returns 404 to callers without datasource_access. This brings
query_form_data to the same bar.

To avoid introducing a status-code-based existence oracle (where a
non-existent slice_id returns 200 + {} while a forbidden one
returns 403), the SupersetSecurityException is caught and
normalised to the same 404 ChartRestApi.get uses, so callers
cannot distinguish missing from forbidden.

BEFORE/AFTER SCREENSHOTS

N/A (server-side authorisation change).

TESTING INSTRUCTIONS

pytest tests/integration_tests/charts/api_tests.py -k query_form_data -v

The added test_query_form_data_no_data_access mirrors the canonical
test_get_chart_no_data_access pattern (Gamma user, "Girl Name Cloud"
chart, 404 assertion) and adds defence-in-depth body assertions so a
regression that returned a partial form_data dict inside an error
envelope is still caught.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration
  • Introduces new feature or API
  • Removes existing feature or API

The legacy /api/v1/form_data/?slice_id=N endpoint returned slc.form_data
verbatim with only the broad @has_access_api gate, while the modern
ChartRestApi.get returns 404 to callers without datasource_access on the
chart's underlying dataset. This brings query_form_data to the same bar
by invoking security_manager.raise_for_access(chart=slc) before reading
form_data.

To avoid introducing a status-code-based existence oracle (where a
non-existent slice_id returns 200 + {} while a forbidden one returns
403), the SupersetSecurityException is caught and normalised to the
same 404 ChartRestApi.get uses; callers cannot distinguish "missing"
from "forbidden".

The new test mirrors the canonical test_get_chart_no_data_access
pattern (Gamma user, "Girl Name Cloud" chart, 404 assertion) and adds
defence-in-depth body assertions so a future regression that returned
a partial form_data dict in an error envelope is still caught.
@github-actions github-actions Bot added the api Related to the REST API label May 28, 2026
@netlify
Copy link
Copy Markdown

netlify Bot commented May 28, 2026

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 897061c
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a1bf9e937cadc000886e00f
😎 Deploy Preview https://deploy-preview-40497--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.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.96%. Comparing base (acc8024) to head (417a161).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #40497      +/-   ##
==========================================
- Coverage   63.97%   63.96%   -0.02%     
==========================================
  Files        2654     2649       -5     
  Lines      142753   142416     -337     
  Branches    32833    32736      -97     
==========================================
- Hits        91325    91094     -231     
+ Misses      49870    49765     -105     
+ Partials     1558     1557       -1     
Flag Coverage Δ
hive 39.72% <28.57%> (-0.01%) ⬇️
mysql 58.42% <100.00%> (+<0.01%) ⬆️
postgres 58.50% <100.00%> (+<0.01%) ⬆️
presto 41.34% <28.57%> (-0.01%) ⬇️
python 59.99% <100.00%> (+<0.01%) ⬆️
sqlite 58.16% <100.00%> (+<0.01%) ⬆️
unit 100.00% <ø> (ø)

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

☔ View full report in Codecov by Sentry.
📢 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.

@sha174n sha174n marked this pull request as ready for review May 28, 2026 12:15
@dosubot dosubot Bot added api:charts Related to the REST endpoints of charts authentication:access-control Rlated to access control labels May 28, 2026
@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented May 28, 2026

Code Review Agent Run #b8d346

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 6fa17cd..6fa17cd
    • superset/views/api.py
    • tests/integration_tests/charts/api_tests.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

Bito Usage Guide

Commands

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

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

Comment thread superset/views/api.py Outdated
@bito-code-review
Copy link
Copy Markdown
Contributor

The pr_comments.csv file contains only 1 line of data (header) and no actual review comments. I cannot analyze or count any suggestions or comments without content to work with.

Comment thread superset/views/api.py Outdated
sha174n and others added 2 commits May 29, 2026 01:46
Reuse ChartDAO.get_by_id_or_uuid so the endpoint applies the same
ChartFilter (dataset-scoped) as the modern ChartRestApi.get, and
return 404 for both missing and unauthorised slice IDs so callers
cannot enumerate chart existence via status code.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented May 29, 2026

Code Review Agent Run #77ec94

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 6fa17cd..003fbd6
    • superset/views/api.py
    • tests/integration_tests/charts/api_tests.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

Bito Usage Guide

Commands

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

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api:charts Related to the REST endpoints of charts api Related to the REST API authentication:access-control Rlated to access control size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant