fix(dashboard): validate native-filter data requests against filter targets#40979
Conversation
…argets A dashboard native-filter data request has no associated chart, so the query_context check previously accepted any payload for it. It now resolves the requesting dashboard's native filter (by native_filter_id) and constrains the request to that filter's targets on the targeted dataset: - columns and group-by must reference a target column; - metrics and order-by terms must be a target column, the filter's configured sort metric (controlValues.sortMetric), or a simple aggregate over a target column; - free-form SQL terms and other saved metrics are rejected, and a request that cannot be tied to a native filter fails closed. Legitimate value, range (MIN/MAX over target) and sort-by-metric lookups are unaffected. Row-restricting clauses (filter/extras) are intentionally not constrained here (cross-filters legitimately reference other columns and return no column values; that blind-inference surface is shared with the chart path and tracked separately). Adds unit coverage for target column, arbitrary column, simple aggregate over target, configured sort metric, arbitrary saved metric, adhoc column/metric, order-by column/adhoc, and missing filter context. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #40979 +/- ##
==========================================
- Coverage 64.30% 64.28% -0.03%
==========================================
Files 2657 2657
Lines 144060 144120 +60
Branches 33216 33235 +19
==========================================
+ Hits 92641 92642 +1
- Misses 49797 49852 +55
- Partials 1622 1626 +4
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:
|
…-request-validation
Only constrain chartless data requests identified as native-filter lookups (by the NATIVE_FILTER type marker or a native_filter_id). Other chartless paths (drill-to-detail, drill-by, samples) carry neither marker and keep their prior behavior, validated by the datasource-access checks in raise_for_access. Extract per-query validation into a helper to keep query_context_modified within complexity limits. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Code Review Agent Run #1b3552Actionable 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
A dashboard native-filter data request has no associated chart, so the query_context check that keeps embedded requests aligned with the dashboard was not validating the request's columns/metrics for that path. It now resolves the requesting dashboard's native filter (by
native_filter_id) and constrains the request to that filter's targets on the targeted dataset:controlValues.sortMetric), or a simple aggregate over a target column;Legitimate value, range (MIN/MAX over the target) and sort-by-metric lookups are unaffected. Row-restricting clauses (
filter/extras) are intentionally not constrained here: cross-filters legitimately reference other columns and they return no column values; that surface is shared with the chart path.TESTING INSTRUCTIONS
New unit tests cover: target column allowed, arbitrary column blocked, simple aggregate over target allowed, configured sort metric allowed, arbitrary saved metric blocked, adhoc column/metric blocked, order-by column/adhoc, and a request with no filter context failing closed.
ADDITIONAL INFORMATION
🤖 Generated with Claude Code