-
Notifications
You must be signed in to change notification settings - Fork 89
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
mysql_user, mysql_role: add argument subtract_privs to revoke privileges explicitly #333
mysql_user, mysql_role: add argument subtract_privs to revoke privileges explicitly #333
Conversation
Codecov Report
@@ Coverage Diff @@
## main #333 +/- ##
==========================================
- Coverage 78.24% 78.20% -0.04%
==========================================
Files 27 27
Lines 2248 2267 +19
Branches 527 550 +23
==========================================
+ Hits 1759 1773 +14
- Misses 333 335 +2
- Partials 156 159 +3
Continue to review full report at Codecov.
|
…d privileges and don't revoke USAGE implicitly
Hi @Andersson007, @rsicart, @Jorge-Rodriguez, @bmalynovytch, When granting a privilege, the The integration tests are currently red because they assume an error but the invalid privilege is ignored. |
Good job, thanks! I think ignoring and documenting this behavior would be enough. What does the rest of the team think about that? |
…privs is true -> document that and fix integration tests
Hi all, sorry for the later reply - was on PTO, +1 to ignoring and documenting |
@betanummeric if you're OK with our opinion, feel free to proceed as i don't think we'll get more feedback. So please go on:) |
make the PEP8 check happy
@Andersson007 I'm ok with documenting and ignoring. As I thought this would be your opinion, I already implemented that, see commit ea48464 and the two after. The integration tests only fail for mysql 8 at Apart from that, I am done with my changes. |
@betanummeric i've taken a look at the changes and have realized that i need to start my day with it:) Before that:
I ran the tests locally without the changes and against MySQL 8 - it works and this test (that fails) had been there before this PR, so the failings are probably related to the changes. |
…T OPTION needs to be added
…ration test blind spot
The error described in my comment above is fixed with commit 29885d1. The issue was that the difference between requested and existing privileges only was the |
If only the grant option needs to be granted, at least one privilege needs to be granted to get valid syntax. USAGE is better for that than the existing privileges, because unwanted privileges would be re-added after revokation.
I have to correct myself: The placeholder privileges for only adding the grant option make a difference indeed, because privileges are first revoked, then granted. I changed the placeholder to Finding this bug was tricky because the module is not very verbose about what it does. I added some more output in commit 37fa66a, because I first couldn't reproduce the bug. The added output will only show the added/revoked privileges of the last db/table, it is by far not comprehensive. |
@betanummeric sorry for the delay, busy days.., i'll try to review it tomorrow morning, thanks for your work! |
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.
@betanummeric solid refactoring, thanks:)
Also thanks for adding the comments (they make things much clearer) and good test coverage
LGTM, one formatting thing from me
I believe one day we should split all of those ancient long core functions into several smaller ones doing one thing, etc. and cover them with unit tests in future.
Let's wait for @rsicart 's review
changelogs/fragments/333-mysql_user-mysql_role-add-subtract_privileges-argument.yml
Outdated
Show resolved
Hide resolved
…ivileges-argument.yml Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>
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.
@betanummeric , completely forgot about version_added
, could you please add it to the options so that users will see since what version it is available.
Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>
Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>
Thanks for contributing @betanummeric ! And thanks for reviewing @Andersson007 , indeed that's a good thing to have a double review when a PR is related to critical parts of code, like this one :) All changes seem coherent and logical to me, thanks for commenting the code, that helped a lot. Integration tests are also clear and easy to read. I needed some time to understand why, when creating a user/role with privs and substract_privs, we set privs to None. Do you confirm that that's because:
Good job! |
Thanks for the feedback! @rsicart |
@betanummeric thank you for the contribution! I think we can release the collection soon. As it's a time consuming process, would be great to have that blocker #341 merged as well. I'd be grateful for reviews. UPDATE: there's another bugfix which is ready for review #322 |
SUMMARY
fixes #331
Add an argument
subtract_privs
(boolean, default false, mutual conflict withappend_privs
) to mysql_user and mysql_role. If true, the privileges specified by thepriv
argument get revoked and unspecified privileges remain unchanged.ISSUE TYPE
COMPONENT NAME
mysql_user and mysql_role