Skip to content
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

Add query integrity check in AccessControlManager #13878

Merged
merged 1 commit into from
Dec 26, 2019

Conversation

mayankgarg1990
Copy link
Contributor

@mayankgarg1990 mayankgarg1990 commented Dec 18, 2019

Resubmitting #13632

== RELEASE NOTES ==

SPI Changes
* Add API to check if the query is unexpectedly modified using the credentials passed in the identity

Copy link
Contributor

@highker highker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM given it has already been reviewed #13632. Make sure the tests pass.

Copy link
Contributor

@ajaygeorge ajaygeorge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM . Minor comment

@Override
public void checkQueryIntegrity(Identity identity, String query)
{
requireNonNull(identity, "extraCredentials is null");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought requireNonNull was only for checking constructor args.
See #13705 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I am not completely sure about the context behind the comment that you linked to, I feel that it is reasonable to validate that the input that the class is getting from an external agent. So I can generalize it to when something out of the class creates an instance by calling the constructor or to validate arguments passed to a public method of a class.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mayankgarg1990 , definitely I see the need for null checking params in public methods.
However seems like in presto we usually do not null check method parameters using requireNonNull. We do that only for constructor arguments. cc @mbasmanova .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ajaygeorge - If you take a look AccessControlManager that has been doing this since 2015 - so there are examples already in the codebase. Also, it is better that we focus on what makes sense rather than how things are being done.

@mbasmanova
Copy link
Contributor

@mayankgarg1990

  • Add API to check the integrity of a query

Perhaps, clarify what "integrity" means here.

@mayankgarg1990
Copy link
Contributor Author

mayankgarg1990 commented Dec 23, 2019

@mayankgarg1990

  • Add API to check the integrity of a query

Perhaps, clarify what "integrity" means here.

I feel that integrity generally refers to ensuring that the query is what was expected. The exact details are up for the implementation and this PR just adds the API to implement to perform the check. I am unable to think of how I can clarify what "integrity" means. I will be glad if you can share what is the missing context that you will like or if you have some suggestion.

@mbasmanova
Copy link
Contributor

@mayankgarg1990 I'd like to come up with a one-liner for the release notes that would be meaningful to the reader. We can start with Check if the query is unexpectedly modified compared to token provided in Identity., but then I don't see "token" in "Identity" class. There is only user, principal, roles and extraCredentials. What is "token" here?

@mayankgarg1990
Copy link
Contributor Author

@mbasmanova - I didn't pay attention to this comment. The token is an implementation detail and in general the idea is to use the identity object (where extra information can be passed as extraCredentials). The way Facebook would do it is to have the token passed as a part of extraCredentials field of Identity. But everyone is free to have their implementation of how they want to assess the integrity of the query.

I have changed the comment - Check if the query is unexpectedly modified using the credentials passed in the identity. Let me know if this makes more sense. Then I can change the Release note to - Add API to check if the query is unexpectedly modified using the credentials passed in the identity

@mbasmanova
Copy link
Contributor

@mayankgarg1990 I like these proposals.

@mayankgarg1990
Copy link
Contributor Author

Thank you for the feedback @mbasmanova . I had already updated the code, I have updated the PR description as well

@mayankgarg1990
Copy link
Contributor Author

@highker , @mbasmanova - can one of you help with merging this PR?

@highker highker merged commit 25e1d79 into prestodb:master Dec 26, 2019
@aweisberg aweisberg mentioned this pull request Jan 17, 2020
7 tasks
@caithagoras caithagoras mentioned this pull request Jan 22, 2020
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants