-
Notifications
You must be signed in to change notification settings - Fork 613
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
Fix incorrectly quoted GRANT cmd on functions #1150
Fix incorrectly quoted GRANT cmd on functions #1150
Conversation
The "arguments" in this case are the actual types, and they must not be quoted.
Function and type arguments must stay together: "pg_catalog.pg_ls_dir"(text,boolean,boolean) => "pg_catalog.pg_ls_dir(text,boolean,boolean)"
GRANT EXECUTE ON FUNCTION "func()" fails, we need to unquote in that case.
postgresql::server::grant is a typeThe enclosing module is declared in 50 of 578 indexed public Puppetfiles. Breaking changes to this file WILL impact these modules (exact match): These results were generated with Rangefinder, a tool that helps predict the downstream impact of breaking changes to elements used in Puppet modules. You can run this on the command line to get a full report. Exact matches are those that we can positively identify via namespace and the declaring modules' metadata. Non-namespaced items, such as Puppet 3.x functions, will always be reported as near matches only. |
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.
Thanks for the fix @olifre ! I noticed there's a typo causing syntax check failures. Also, after checking out and running tests, there are going to be some test failures due to the change in syntax of the sql command:
bundle exec rake spec
Failed examples:
rspec ./spec/unit/defines/server/grant_spec.rb:263 # postgresql::server::grant function is expected to contain Postgresql_psql[grant:test] with command =~ /GRANT EXECUTE ON FUNCTION "test"\("text","text"\) TO\s* "test"/m and unless =~ /SELECT 1 WHERE has_function_privilege\('test',\s* 'test\("text","text"\)', 'EXECUTE'\)/m
rspec ./spec/unit/defines/server/grant_spec.rb:288 # postgresql::server::grant function with schema is expected to contain Postgresql_psql[grant:test] with command =~ /GRANT EXECUTE ON FUNCTION "myschema"."test"\("text","text"\) TO\s* "test"/m and unless =~ /SELECT 1 WHERE has_function_privilege\('test',\s* 'myschema.test\("text","text"\)', 'EXECUTE'\)/m
Could you have a look at the tests within grant_spec.rb
? It would be good if we could add additional coverage to handle scenarios where we want to quote the command vs scenarios where we do not.
Please feel free to reach out if you need any help in that regard.
Thanks again for the PR!
Thanks for the friendly feedback!
(which succeeds fine and installs the dependencies), trying to Unless you have an idea what is wrong (or can RTFM me), I could only develop the tests "blindly" (using travis-feedback). I can certainly do that, but it may take a bit. |
47cd447
to
f691318
Compare
Co-Authored-By: sanfrancrisko <55992494+sanfrancrisko@users.noreply.github.com>
Types must not be quoted neither for granting not checking, and the overall expression must not be quoted for granting.
…ven. This was missed before and found by the test.
f691318
to
215b350
Compare
@sanfrancrisko That should have done the trick to get the Static and Spec parts green. I can also look at the acceptance tests, they should run through fine now, but they only ever worked since they never tested granting permissions to a function taking parameters, so it would be better to add something like this to accepteance tests (I can try tomorrow, hopefully won't take too many iterations). |
cc29d2b
to
681fba1
Compare
Codecov Report
@@ Coverage Diff @@
## master #1150 +/- ##
=========================================
Coverage ? 50.43%
=========================================
Files ? 15
Lines ? 458
Branches ? 0
=========================================
Hits ? 231
Misses ? 227
Partials ? 0 Continue to review full report at Codecov.
|
I did now also add an acceptance test for granting |
681fba1
to
ec600a7
Compare
Thanks for updating the current tests and adding the new coverage too @olifre. Appreciate you doing this as your first acceptance test! 😄 Change LGTM! Regarding the issues you were seeing with the PDK - I asked some of my more PDK-savvy colleagues what they thought might be the issue. A few suggestions:
Before running |
@sanfrancrisko Thanks for the friendly feedback and the PDK help! After cleaning up (removing {{Gemfile.lock}} and {{vendor}}) and then running:
it tries to run |
Fix incorrectly quoted GRANT cmd on functions
The existing code failed miserably to grant permissions on functions.
Using the following code:
The created queries were:
and for the "unless" case:
The patches in this series fix that to be:
since both the types and the complete function expression must not be quoted.