Skip to content

Conversation

@Manno15
Copy link
Contributor

@Manno15 Manno15 commented Dec 9, 2020

In relation to #1830, I only added an audit check for flushing a table at the moment but I am working on adding additional ones for set/remove system property and any other that is requested.

Copy link
Member

@ctubbsii ctubbsii left a comment

Choose a reason for hiding this comment

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

This is a good start to check the flush command. However, checking the audit message doesn't guarantee the permission is denied (the auditing could be working, but we still allow the action). So, I think we will need checks to ensure the action is denied. The best place to do that is probably PermissionsIT. Can you make those changes in this PR, or would you prefer to open another PR for PermissionsIT?

@Manno15
Copy link
Contributor Author

Manno15 commented Dec 9, 2020

I'll take a look at permissionsIT, I can probably just add those to this PR

@Manno15
Copy link
Contributor Author

Manno15 commented Dec 10, 2020

@ctubbsii As it stands currently, you only need write permissions to flush a table. Do you think I should add separate permissions for Flush specifically (not fully sure how to do this and make it functional. I did add the permission option though), piggyback off the write permission check to also do a flush of the table, or leave as is and assume that permission is checked correctly since they share permissions?

I also noticed that in PermissionsIT that the test case for system permissions isn't actually there and is left as a to-do I assume. Not sure if there was a good reason why that was left undone.

@ctubbsii
Copy link
Member

@ctubbsii As it stands currently, you only need write permissions to flush a table. Do you think I should add separate permissions for Flush specifically (not fully sure how to do this and make it functional. I did add the permission option though), piggyback off the write permission check to also do a flush of the table, or leave as is and assume that permission is checked correctly since they share permissions?

There's no need to change any permissions. The test can simply add a user that lacks the appropriate permission, and can verify that the appropriate AccumuloSecurityException denial is thrown if a flush is attempted.

I also noticed that in PermissionsIT that the test case for system permissions isn't actually there and is left as a to-do I assume. Not sure if there was a good reason why that was left undone.

It probably just wasn't in scope of the original issue. Maybe there's another test that checks those? It can be added to this one, if not.

@Manno15
Copy link
Contributor Author

Manno15 commented Dec 10, 2020

There's no need to change any permissions. The test can simply add a user that lacks the appropriate permission and can verify that the appropriate AccumuloSecurityException denial is thrown if a flush is attempted.

That's what the test does overall, was more of a question on where to place it. In its own case, or in the Write case. I decided to go with the latter because the former would require adding its own permission.

@Manno15
Copy link
Contributor Author

Manno15 commented Dec 10, 2020

Whenever I try to grant a system permission on the shell I get: [shell.Shell] ERROR: org.apache.accumulo.core.util.BadArgumentException: Unrecognized permission near index 6 grant System.SYSTEM -u test_user
Am I doing something wrong or is that a bug? This is on 1.10. I am trying to test out the permission for changing system properties.

@ctubbsii
Copy link
Member

Whenever I try to grant a system permission on the shell I get: [shell.Shell] ERROR: org.apache.accumulo.core.util.BadArgumentException: Unrecognized permission near index 6 grant System.SYSTEM -u test_user
Am I doing something wrong or is that a bug? This is on 1.10. I am trying to test out the permission for changing system properties.

What command are you running? Compare what you are entering with the help information for the command you are running (<command> --help).

@Manno15
Copy link
Contributor Author

Manno15 commented Dec 10, 2020

Just the Grant command. grant <perm> -u <user>. Every other perm works as expected, none of the System ones do for me. It fails on the first S in System.

@ctubbsii
Copy link
Member

Just the Grant command. grant <perm> -u <user>. Every other perm works as expected, none of the System ones do for me. It fails on the first S in System.

The help documentation for the grant command says to use -s. So, grant -s <systemPerm> -u <user> should work.

@Manno15
Copy link
Contributor Author

Manno15 commented Dec 10, 2020

I'll try it tomorrow, but I don't recall seeing that. Maybe I am blind. Thanks for the help.

@Manno15
Copy link
Contributor Author

Manno15 commented Dec 11, 2020

@ctubbsii It appears I was blind. The -s makes the command work, can't believe is missed it. Any thoughts on my most recent commits and anything else I should add?

@ctubbsii
Copy link
Member

@ctubbsii It appears I was blind. The -s makes the command work, can't believe is missed it. Any thoughts on my most recent commits and anything else I should add?

The PermissionsIT test is hard to parse. I'm trying to take a look now.

@ctubbsii
Copy link
Member

The following RPC calls were affected: initiateFlush, waitForFlush, shutdown, shutdownTabletServer, setMasterGoalState, setSystemProperty, and removeSystemProperty. Ideally, we should have test coverage for all of these cases.

@EdColeman
Copy link
Contributor

@Manno15 - are you working adding tests for the other calls? Or would it help if someone also took a look?

@Manno15
Copy link
Contributor Author

Manno15 commented Dec 14, 2020

@Manno15 - are you working adding tests for the other calls? Or would it help if someone also took a look?

I am splitting time between this and #1824. I am willing to work on adding these other tests but I welcome help if you are offering it.

The following RPC calls were affected: initiateFlush, waitForFlush, shutdown, shutdownTabletServer, setMasterGoalState, setSystemProperty, and removeSystemProperty. Ideally, we should have test coverage for all of these cases.

Should they be added to this IT? Similar to how I did flush or do you think there is a better location for all of these? I am unsure if permissionsIT is there to test that the permissions work or there to test the underlying function that uses the permission.

@dlmarion
Copy link
Contributor

I'm wondering if a more complete solution here is to create a test for the MasterClientServiceHander (the Master's API) as that is where the SecurityOperation.canFlush method is called.

@ctubbsii
Copy link
Member

Should they be added to this IT?

They should be in this PR, but I'm not sure which IT is best suited. I'm sure if you use your best judgment, it will be fine. People can provide help via code reviews if they know of a better place.

@ctubbsii
Copy link
Member

I'm wondering if a more complete solution here is to create a test for the MasterClientServiceHander (the Master's API) as that is where the SecurityOperation.canFlush method is called.

Many of those operations already have their own specific end-to-end ITs, as this class represents RPC endpoints. I thought the PermissionsIT was intended to specifically check the permissions of each of these endpoints, so that other tests can focus on testing the end-to-end behavior, but I could be wrong about the scope of the PermissionsIT.

@dlmarion
Copy link
Contributor

From what I can tell, the driver in PermissionsIT are the different Permissions enum values. I was thinking of a test that hits the API directly, like https://github.com/dlmarion/accumulo/blob/manager-api-it/test/src/main/java/org/apache/accumulo/test/functional/ManagerApiIT.java

@Manno15
Copy link
Contributor Author

Manno15 commented Dec 15, 2020

I was able to test the flush RPC calls and the set/remove system property call within PermissionsIT but I don't see a way to test shutdown, shutdownTabletServer, and setMasterGoalState. I think implementing something akin to what @dlmarion suggested is best suited to handle that so I will implement it into a new IT

@Manno15
Copy link
Contributor Author

Manno15 commented Dec 15, 2020

I was able to handle each RPC call using @dlmarion's suggestion and using his IT as the basis for the one I pushed. Credit goes to him for that, thanks. The only part I am unsure on is if I should keep it in one test or separate each RPC call to their own test within the IT.

Overall, I think this is ready for review and we can discuss which approach we want to go with and I can remove what we don't need/want and add anything that is missing.

@dlmarion
Copy link
Contributor

LGTM

@Manno15
Copy link
Contributor Author

Manno15 commented Dec 15, 2020

@dlmarion Do you want me to add you as a co-author if my last commit gets merged? Since it was your idea and you provided the basis for it?

@dlmarion
Copy link
Contributor

I'm not really worried about it, up to you.

@ctubbsii
Copy link
Member

I'm in progress for another review of this. I have some cleanup of the tests to shorten it up a bit.

@ctubbsii
Copy link
Member

In order to make some improvements to these tests, I backported a JUnit upgrade from #1562 into the 1.10 development branch in d4fd27f

* Make tests independent with consistent naming scheme
* Make use of assertThrows to simplify checks
* Rename variables and inline the test operations to make it easier to
  follow the test intentions
@Manno15
Copy link
Contributor Author

Manno15 commented Dec 16, 2020

I like your changes to the test. I know you already merged but it looks good!

asfgit pushed a commit that referenced this pull request Dec 21, 2020
(cherry-picked for 2.0.1)

* Update AuditMessageIT to test auditing of flush commands
* Add new ManagerApiIT to test permissions checks of
  MasterClientServiceHandler RPC endpoints
* Fill in missing checks for SYSTEM permissions in PermissionsIT
  (and add flush tests for WRITE and ALTER_TABLE permissions)

Co-authored-by: Dave Marion <dlmarion@apache.org>
Co-authored-by: Christopher Tubbs <ctubbsii@apache.org>
@ctubbsii ctubbsii added this to the 1.10.1 milestone Jul 12, 2024
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.

4 participants