-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Honor table and view schema on query #14351
Honor table and view schema on query #14351
Conversation
f => table.schema[f].visible !== false | ||
) | ||
|
||
if (options.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.
I think this may be too high level for this - I think the SQL layers may ignore/override this in terms of query generation. If you look at server/src/api/controllers/row/ExternalRequest.ts
on line 692 there is a function called buildSqlFieldList
- this comes up with a list of fields which are going to be defined as part of the SELECT <fields>
in the query. SQS does something similar with its function buildInternalFieldList
- these today are independent of each other as how they generate their list of fields is quite different.
We could merge these into one path through the SDK which fetches a list of fields (and relationships) to add to the QueryJson
which would take into account if it was performed through a view - we'd need to pass the list of visibleTableFields
down to the search implementations via the RowSearchParams
.
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 would also need to handle the list of relationships, found top level on the QueryJson
structure under the relationships
key - this would need to have relationships removed from it if the relationship column is disabled through the view (this removes the JOIN
). There are again two functions which do this today, for external DBs buildExternalRelationships
and for SQS buildInternalRelationships
.
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.
NOTE: none of this can be applicable to Lucene as it always returns the full row JSON, it cannot strip fields out at the database level - I wouldn't worry about this too much.
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.
After a reanalising the logic, I moved the trim to the outputProcessing. We still need to fetch all the columns for things like formulas.
This PR was meant to cover only the security around queries, so I will stick to it and I will tackle the actual SQL statement generation in a separated PR as talked on the meeting this morning
if (handledTables.has(`${table._id}_${subSchema.tableId}`)) { | ||
// avoid circular loops | ||
continue | ||
} | ||
handledTables.add(`${subSchema.tableId}_${table._id}`) |
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.
It's not obvious to me why the order is flipped here, a_b
vs b_a
. Is this intentional?
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.
It's to avoid circular loops. It's not so obvious, I am refactoring it and writing some tests for it
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.
LGTM - very nice work!
febb92d
to
07fe8c6
Compare
Description
Add the following security checks:
Launchcontrol
Improve search row security resilience
Feature branch env
Feature Branch Link