Properly quote role name in default_privileges type#1666
Open
antaflos wants to merge 1 commit intopuppetlabs:mainfrom
Open
Properly quote role name in default_privileges type#1666antaflos wants to merge 1 commit intopuppetlabs:mainfrom
antaflos wants to merge 1 commit intopuppetlabs:mainfrom
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)