-
Notifications
You must be signed in to change notification settings - Fork 270
fix: restrict access to private queries in query search #875
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
Conversation
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.
great work! minor style comments
|
||
|
||
def _get_partial_dict(field_to_generator, fields=None): | ||
if fields is None: |
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.
fields = fields or field_to_generator.keys()
return {field: field_to_generator[field]() for field in fields if field in field_to_generator}
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.
Slightly changed to the following to check whether getter is a callable or value:
fields = fields or field_to_getter.keys()
return {
field: getter() if callable(getter) else getter
for field, getter in field_to_getter.items()
if field in fields
}
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.
super minor, but
for field, getter in field_to_getter.items()
if field in fields
is n^2, so its faster to check if field in field_to_getter
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.
ooh good point, fixed that!
fixes #865
public
andreadable_user_ids
fields to query_cell and query_execution elasticsearch indices to restrict access to queries on private datadocsquerybook/server/datasources/search.py
to use "must" query to ensure user has access to datadocs & queries that are returned