-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Update StatementAnalyzer and extend AccessControl interface and to filter columns from table schema instead of throwing #7893
Conversation
Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Young Chen.
|
Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Young Chen.
|
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.
Please add tests.
core/trino-main/src/main/java/io/trino/security/AccessControl.java
Outdated
Show resolved
Hide resolved
plugin/trino-hive/src/main/java/io/trino/plugin/hive/security/SqlStandardAccessControl.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/sql/analyzer/StatementAnalyzer.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/sql/analyzer/StatementAnalyzer.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/sql/analyzer/StatementAnalyzer.java
Outdated
Show resolved
Hide resolved
core/trino-spi/src/main/java/io/trino/spi/connector/ConnectorAccessControl.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/security/AccessControl.java
Outdated
Show resolved
Hide resolved
core/trino-spi/src/main/java/io/trino/spi/security/SystemAccessControl.java
Outdated
Show resolved
Hide resolved
Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Young Chen.
|
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please submit the signed CLA to cla@trino.io. For more information, see https://github.com/trinodb/cla. |
Cleaned up the git commit history a bit to remove non github emails - just submitted the CLA as well. |
Added some unit tests similar to rowFilter and columnMask. However, one concern I have is the interaction with INSERT/UPDATE/DELETE. We would typically expect the AccessControl implementation to restrict access to INSERT/UPDATE/DELETE if a user doesn't have full access to the schema. However, it's possible for this to not be implemented so we would probably want a defensive check in the StatementAnalyzer. Perhaps this would be better implemented via Or could there be a use case for inserting partial data into a table and having the inaccessible columns set to default? It seems like this would be unexpected/error prone behavior for the most part in my opinion. What are your thoughts? |
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please submit the signed CLA to cla@trino.io. For more information, see https://github.com/trinodb/cla. |
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please submit the signed CLA to cla@trino.io. For more information, see https://github.com/trinodb/cla. |
1 similar comment
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please submit the signed CLA to cla@trino.io. For more information, see https://github.com/trinodb/cla. |
@cla-bot check |
The cla-bot has been summoned, and re-checked this pull request! |
@@ -222,10 +222,15 @@ | |||
void checkCanShowColumns(SecurityContext context, CatalogSchemaTableName table); | |||
|
|||
/** | |||
* Filter the list of columns to those visible to the identity. | |||
* Filter the list of columns to those visible to the identity when querying metadata. |
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.
This needs a better explanation. What's the difference between "when querying metadata" vs "when querying the table"?
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.
filterColumns hides table metadata when running DESCRIBE or SHOW TABLE, as well as when querying the INFORMATION_SCHEMA tables. However, when actually selecting data from the table it doesn't hide the corresponding columns. I'm not really sure how else to describe this so any suggestions are welcome!
I also can't really think of a practical reason why we would want to control these separately. @kokosing mentioned that it would be beneficial to be able to hide column metadata & throw errors on access denied, vs hiding columns completely so that's why I'm leaving it here.
(Slack link: https://trinodb.slack.com/archives/CP1MUNEUX/p1620418412085600?thread_ts=1618261084.236200&cid=CP1MUNEUX)
core/trino-main/src/main/java/io/trino/sql/analyzer/StatementAnalyzer.java
Outdated
Show resolved
Hide resolved
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.
core/trino-main/src/test/java/io/trino/sql/query/TestTableSchemaFilter.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/test/java/io/trino/sql/query/TestTableSchemaFilter.java
Show resolved
Hide resolved
if you ask about my opinion, I can only repeat that for me this shouldn't be in AccessControl at all. |
We usually do
That depends on history kind. We care a lot about the history, so this is why how change is structured between commits and what are the commit messages is also a part of code review. However we prefer not merge anything where change goes back and forth between commits in the same PR. This makes entire git history much cleaner. Notice that writing code is creative process and it is natural to got back and forth when writing the code, however when visiting history such small steps are not helpful. @youngchen7 Would you like to add the above to https://github.com/trinodb/trino/blob/master/DEVELOPMENT.md (in separate PR)? I see it is not clear to the community members sometimes and it is not the first time I explain this. That way it will be easier for others to contribute. |
Sounds good - I'll open a new PR for the DEVELOPMENT.md change. I'll squash the commits in this PR. |
be3a750
to
2e0e909
Compare
|
/** | ||
* Filter the list of columns to those visible to the identity when querying the table. | ||
*/ | ||
Set<String> filterTableSchema(SecurityContext context, QualifiedObjectName tableName, Set<String> columns); |
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.
how is this method different from filterColumns
above?
- Why do we need two methods?
- What's the occasion where
SELECT *
would want to give you different set of columns thanSHOW COLUMNS FROM ...
I think we should continue with #9991, the simple feature toogle is easier to reason than changing the access control I think. |
@kokosing to me, it's not about simplicity, but what's the right thing to do. |
👋 @youngchen7 - this PR is inactive and doesn't seem to be under development, and it might already be implemented in #7461. If you'd like to continue work on this at any point in the future, feel free to re-open. |
Initial PR for AccessControl interface changes, initial implementations, and StatementAnalyzer integration.
Will update specific AccessControl implementations (possibly FileBased) to support this feature.
Fixes #7461