-
Notifications
You must be signed in to change notification settings - Fork 14.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(QueryContext): validation does not validate query_context metrics #19753
base: master
Are you sure you want to change the base?
Conversation
cf8be09
to
8fbce8e
Compare
8fbce8e
to
b2db382
Compare
b2db382
to
cf51459
Compare
f382cc8
to
913e4f1
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #19753 +/- ##
==========================================
+ Coverage 66.53% 66.58% +0.05%
==========================================
Files 1692 1696 +4
Lines 64777 64988 +211
Branches 6660 6656 -4
==========================================
+ Hits 43101 43275 +174
- Misses 19977 20014 +37
Partials 1699 1699
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
d34bcb5
to
f33a120
Compare
@AAfghahi told me to change back the excepted result of the failed test until he will figure it out. |
3e7fdbd
to
7be5bf2
Compare
7be5bf2
to
7ee4698
Compare
7613eb7
to
6ba9a35
Compare
return QueryContextValidatorWrapper() | ||
|
||
def _make_access_validator(self, is_sql_db: bool) -> QueryContextValidator: | ||
if is_sql_db: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you checking here that the db is sql and not no-sql Druid? If so, we've removed native Druid support in 2.0.
|
||
def _make(self, query_context: QueryContext) -> BaseCommand: | ||
validator = self._validator_factory.make(self._is_use_sql_db(query_context)) | ||
return ChartDataCommand(query_context, validator) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if this factory abstraction is necessary for the validation or if this is something we can just put into the command?
from superset.commands.base import BaseCommand | ||
from superset.common.query_context import QueryContext | ||
|
||
from ..query_context_validators.validaor_factory import QueryContextValidatorFactory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We avoid using relative imports
there's seems to be a typo also: validaor_factory
@classmethod | ||
def init(cls, validator_factory: QueryContextValidatorFactory) -> None: | ||
cls._instance = GetChartDataCommandFactory(validator_factory) | ||
|
||
def __init__(self, validator_factory: QueryContextValidatorFactory): | ||
self._validator_factory = validator_factory | ||
|
||
@classmethod | ||
def make(cls, query_context: QueryContext) -> BaseCommand: | ||
if cls._instance is None: | ||
raise RuntimeError("GetChartDataCommandFactory was not initialized") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need to make so many constructors?
Hi @ofekisr - just checking in to see if you're still able/willing to get this across the finish line. I'll convert it to draft while it awaits a rebase and responses to comments. Thanks! |
no I don't
Ofek
…On Tue, Aug 20, 2024 at 5:50 AM Evan Rusackas ***@***.***> wrote:
Hi @ofekisr <https://github.com/ofekisr> - just checking in to see if
you're still able/willing to get this across the finish line. I'll convert
it to draft while it awaits a rebase and responses to comments. Thanks!
—
Reply to this email directly, view it on GitHub
<#19753 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AIQMHESG3UAHMCVM23RQG7DZSKVI5AVCNFSM6AAAAABMY6ZXOSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJXHA3DGMBSGA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
There is an option to add custom SQL expression metrics inside some of the charts visualizations so the fetched data will be aggregated based on the SQL expression.
When the data is fetched the query context itself is validated if the user can access the data
but the additional sql query added from the metric was missed out and not validated so it can be manipulated so now not allowed data will be fetched too.
The PR adds logic for it. right now only to those visualizations their data fetched by Charts API
follow-up PR's would be:
apply also to custom SQL column expressions