Properly quote role name in default_privileges type - #1666
Conversation
|
Please rebase the branch |
70edc1b to
bdecf93
Compare
|
Rebase done |
|
Created a PR to execute CI tests for this change: #1678 |
|
@SugatD : Any update on progress for the acceptance testing here? |
bdecf93 to
bfcb8ab
Compare
There was a problem hiding this comment.
It looks like the CI tests are failing due these leftover expectations. Please try the suggested changes, and we can check the CI again. Thank you
| .with_unless("SELECT 1 WHERE EXISTS (SELECT * FROM pg_default_acl AS da LEFT JOIN pg_namespace AS n ON da.defaclnamespace = n.oid WHERE '\"test\"=arwdDxtm' = ANY (defaclacl) AND nspname = 'public' and defaclobjtype = 'r')") |
There was a problem hiding this comment.
It looks like the CI tests are failing due these leftover expectations. Please try the suggested changes, and we can check the CI again. Thank you
| .with_unless("SELECT 1 WHERE EXISTS (SELECT * FROM pg_default_acl AS da LEFT JOIN pg_namespace AS n ON da.defaclnamespace = n.oid WHERE '\"test\"=arwdDxt' = ANY (defaclacl) AND nspname = 'public' and defaclobjtype = 'r')") |
SugatD
left a comment
There was a problem hiding this comment.
Please update the code for the suggested changes, so we can run CI again to verify.
Like in many other places in this module we need to ensure that
user-supplied identifiers, such as role names, database names, etc. are
quoted in SQL queries, because they may contain characters such as the
hyphen that the SQL standard considers illegal unless the identifier is
surrounded by double quotes.
The `unless` clause in the default_privileges defined type constructs an
SQL query to check if the ALTER DEFAULT PRIVILEGES grant is already
applied, but this SQL query does not quote the role name. This leads to
server-side errors when trying to run the query if the role name
contains a character like the hyphen. In this example the role name is
`monitoring-user`:
Could not evaluate: Error evaluating 'unless' clause, returned pid 891642 exit 1: 'ERROR: unrecognized key word: "monitoring"
LINE 1: ...amespace AS n ON da.defaclnamespace = n.oid WHERE 'monitori...
^
HINT: ACL key word must be "group" or "user".
'
This change fixes the SQL query for the `unless` clause and contains
updated spec tests.
Fixes puppetlabs#1665
bfcb8ab to
d271d63
Compare
|
I updated the spec tests as requested, rebased and pushed. |
|
Acceptance tests are passing correctly -> https://github.com/puppetlabs/puppetlabs-postgresql/pull/1678/checks Approving PR. |
Summary
Like in many other places in this module we need to ensure that user-supplied identifiers, such as role names, database names, etc. are quoted in SQL queries, because they may contain characters such as the hyphen that the SQL standard considers illegal unless the identifier is surrounded by double quotes.
The
unlessclause in the default_privileges defined type constructs an SQL query to check if the ALTER DEFAULT PRIVILEGES grant is already applied, but this SQL query does not quote the role name. This leads to server-side errors when trying to run the query if the role name contains a character like the hyphen. In this example the role name ismonitoring-user:This change fixes the SQL query for the
unlessclause and contains updated spec tests.Fixes #1665
Additional Context
Related Issues (if any)
#1665
Checklist
puppet apply)