Repository navigation
fix(dataset): improve dataset, report, and expression validation - #42929
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #42929 +/- ##
==========================================
- Coverage 66.75% 66.62% -0.13%
==========================================
Files 2862 2863 +1
Lines 161749 162237 +488
Branches 37313 37400 +87
==========================================
+ Hits 107969 108087 +118
- Misses 51724 52082 +358
- Partials 2056 2068 +12
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:
|
|
The security concern is valid. The current implementation of To implement this, you can update the authorization logic in superset/commands/report/alert.py |
There was a problem hiding this comment.
Code Review Agent Run #2ce454
Actionable Suggestions - 3
-
superset/models/helpers.py - 1
- Broad exception clause detected · Line 3101-3101
-
superset/commands/report/exceptions.py - 1
- Missing test coverage for exceptions · Line 43-73
-
tests/unit_tests/connectors/sqla/models_test.py - 1
- Wrong mock target in security test · Line 1501-1501
Additional Suggestions - 2
-
superset/commands/dataset/update.py - 1
-
Missing SQL revalidation test · Line 135-195The `_validate_sql_access` method correctly re-runs SQL security validation when the database binding changes, but no test exercises this path for virtual datasets. A test for `{"database_id": N, "sql": "SELECT ..."}` on a virtual dataset would close this gap and satisfy [6262].
-
-
superset/commands/report/create.py - 1
-
Missing test for SQL validation path · Line 132-133The new SQL validation branch at lines 132–133 has no test coverage in `tests/unit_tests/commands/report/create_test.py`. The existing alert tests (`test_validate_alert_missing_database_key`, `test_validate_alert_nonexistent_database`) stub out `_populate_recipients` via `_stub_validate_deps` but never reach `validate_alert_query` because they omit a `sql` key. A test exercising the SQL-validation path is needed to prevent regression.
-
Review Details
-
Files reviewed - 14 · Commit Range:
0b60db8..23d9bf8- superset/commands/dataset/update.py
- superset/commands/report/alert.py
- superset/commands/report/base.py
- superset/commands/report/create.py
- superset/commands/report/exceptions.py
- superset/commands/report/update.py
- superset/connectors/sqla/models.py
- superset/models/helpers.py
- superset/utils/rls.py
- tests/unit_tests/commands/dataset/update_test.py
- tests/unit_tests/commands/report/base_test.py
- tests/unit_tests/commands/report/update_test.py
- tests/unit_tests/connectors/sqla/models_test.py
- tests/unit_tests/models/test_virtual_dataset_format.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 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
Code Review Agent Run #0f4ad2Actionable 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 |
sha174n
left a comment
There was a problem hiding this comment.
Reviewed the validation changes across the dataset-update, report/alert, and expression paths. The approach is consistent: each new check routes through the same parser-based validators the sibling paths already use, and runs both at save time and again at the point of use on the fully rendered SQL.
Confirmed: fetch_values_predicate uses the identical validator as stored column and metric expressions; rendered Jinja expressions are re-checked after templating and before being embedded, guarded so the check only runs when the template actually changed the string; the virtual-dataset RLS path aborts the query when row-level predicates apply but cannot be added, and only proceeds when it has positively confirmed none apply; alert queries enforce single-statement plus read-only-unless-DML plus dataset-scoped table checks at both save and execution, with templated SQL correctly deferring the static checks to execution.
Two non-blocking notes: (1) validate_rendered_expression fails closed on any unparseable rendered result, whereas the existing query-time helper falls back to the raw expression for dialect-specific syntax sqlglot cannot model. Since it only runs on templated expressions the exposure is limited, but it is worth confirming the stricter behavior is intended there so legitimate templated dialect-specific expressions are not rejected at query time. (2) This touches the same _validate_dataset_source region as #42936, so a rebase or merge-order decision will be needed. LGTM.
ff9c362 to
a510862
Compare
|
@sha174n thanks for the read-through. Rebased over #42936 and dropped the duplicate database-access check it added in On the fail-closed question: yes, intentional. |
Code Review Agent Run #2b5726Actionable Suggestions - 0Additional Suggestions - 3
Filtered 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 |
…lert queries Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
…uth; strengthen alert query validation Require exactly one alert statement and use strict dataset matching for alert authorization. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Split _validate_dataset_source into focused helpers to satisfy ruff's C901 complexity check, and stop re-running raise_for_access when a database repoint already covers the same (db, table) check -- both the new physical-repoint check and the SQL-access re-check on database_changed were firing redundant/duplicate calls against the same target. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…st RLS cache key - validate_rendered_expression now converts every failure mode (parse, set operation, disallowed sub-query, sanitization) to QueryObjectValidationError, matching validate_stored_expression_at_query_time, instead of letting SupersetSecurityException escape uncaught from its call sites in connectors/sqla/models.py and models/helpers.py. - The unresolved-RLS-predicates cache-key fallback now keys guest users by a hash of their token's RLS rules/resources instead of get_user_id(), which returns None for every guest token and was collapsing distinct guest RLS contexts onto the same cache entry. Co-Authored-By: Claude Opus 4.8 <[email protected]>
5b34f2e to
4c1e7d2
Compare
There was a problem hiding this comment.
Code Review Agent Run #5a1d2b
Actionable Suggestions - 2
-
superset/models/helpers.py - 2
- Avoid catching generic Exception · Line 3160-3160
- Missing test coverage · Line 332-332
Additional Suggestions - 2
-
superset/models/helpers.py - 1
-
Docstring-implementation mismatch · Line 332-386`validate_rendered_expression` documents (line 346) that it may rewrite the expression with RLS predicates, but the implementation performs only validation checks (parse, set-operation, subquery, sanitization). No `apply_rls` call exists in the function body. This mismatch could cause maintainers to assume RLS protection is in place when it is not.
-
-
superset/commands/report/alert.py - 1
-
Typo in log message · Line 272-272Minor typo: 'reveal to much information' should be 'reveal too much information'. While minor, clear messaging helps security-focused warning logs.
-
Filtered by Review Rules
Bito filtered these suggestions based on rules created automatically for your feedback. Manage rules.
-
superset/commands/report/update.py - 1
- Missing unit test for alert re-validation · Line 155-163
Review Details
-
Files reviewed - 15 · Commit Range:
2c5b655..4c1e7d2- superset/commands/dataset/update.py
- superset/commands/report/alert.py
- superset/commands/report/base.py
- superset/commands/report/create.py
- superset/commands/report/exceptions.py
- superset/commands/report/update.py
- superset/connectors/sqla/models.py
- superset/models/helpers.py
- tests/integration_tests/reports/alert_tests.py
- tests/unit_tests/commands/dataset/update_test.py
- tests/unit_tests/commands/report/alert_test.py
- tests/unit_tests/commands/report/base_test.py
- tests/unit_tests/commands/report/update_test.py
- tests/unit_tests/connectors/sqla/models_test.py
- tests/unit_tests/models/test_virtual_dataset_format.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 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
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Code Review Agent Run #573a61Actionable 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 |
SUMMARY
Improves validation in the dataset-update and report/alert command paths and in stored/rendered SQL expression handling.
fetch_values_predicateis routed through the same parser-based validator as stored column and metric expressions, at save time and again when it is embedded at query time.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Not applicable (backend behavior).
TESTING INSTRUCTIONS
pytest tests/unit_tests/commands/dataset/ tests/unit_tests/commands/report/ tests/unit_tests/connectors/sqla/models_test.py tests/unit_tests/models/test_virtual_dataset_format.pyADDITIONAL INFORMATION