-
Notifications
You must be signed in to change notification settings - Fork 94
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
community.postgresql.postgresql_set incorrectly quotes strings containing commas #78
Comments
@nergdron hi, thanks for reporting this! |
and folks, now we have this step-by-step guide how to setup everything and submit a PR very quickly. Would be happy to review |
@nergdron it's not the module. And then checked postgresql.auto.conf: It's a bug of PostgreSQL https://www.postgresql.org/message-id/10860.1438980591%40sss.pgh.pa.us |
We can't fix it on the module's side. So i think the issue should be closed. |
I'll close the issue then because of my investigations above, we can open it later if needed. Thanks you! |
Hello
ang get accordingly:
So only if we send the list in quotes to the alter statement, it will get extra quotes, plugins/modules/postgresql_set.py does:
So it adds single quotes around the value parameter (which I assume is wanted and needed for most settings(?)) |
@hubiongithub hello, thanks for investigating! would you like to submit a PR? |
@Andersson007 Hello |
@hubiongithub good questions, thanks for raising them!
@hunleyd @jchancojr what do you think? I think in the following implementation the code anyway isn't safe in terms of SQL injections or i'm wrong?
Thoughts? |
Hello
search_path is dypically set at role/user level so this might fly under the radar of postgresql_set most of the time There are 74 (PG 14) parameters of type 'string', one good candidate would be local_preload_libraries Some extensions also have such parameters, e.g. pg_audit.log (Multiple classes can be provided using a comma-separated list) So definitely "more than one", but I'm not sure if these all get mangled up by quoting them. |
this seems reasonable as there is definitely >1 parameter that takes a comma-separated list |
@hunleyd @hubiongithub thanks! @hubiongithub would you like to submit a PR? If you haven't done it before, we have the Quick-start guide. Please let us know |
@Andersson007 for a PR I probably would need to write code for " try to split value by commas"? (which I doubt will end well) |
@hubiongithub i think you could use something like:
as
maybe it can be optimized or there's another better solution |
@hubiongithub what do you think? ^ If you have no time for that, please let us know |
@Andersson007 As I'm not that experienced in writing python it's probably faster is someone with that skills do it. Additionally the PR part isn't working great, I have one open in community.mysql which ends up in errors for tests I don't understand how to get along with. |
I created a PR #357, ready for review |
@nergdron thanks for reporting the issue! |
The PR #357 fix the multi-value parameters management (issue #78), but the new check assumes as multi-value each parameter with a comma in the value, that is incorrect as there are single-value parameters with comma in value. If a single-value parameter is treated as a multi-value, the 'param_set' function builds an ALTER SYSTEM SET command with multiple comma-separated values, that fails with the message:
Single-value parameters with possible comma in value are "_command" and "_prefix" that for exmple in v12 are:
The most critical (that I add in tests) is 'log_line_prefix' because often it contains comma and a space at the end. I simply fix the check to evaluate as single-value all parameters that ends with '_command' and '_prefix'. The change is contained in PR #400 . |
|
just tested the latest release (
1.2.0
) since it was only released 15h ago, devel doesn't have any notable changes i can see which would affect this bug.SUMMARY
when using
postgresql_set
with a string value that contains a comma, for some reason it puts extra doublequotes ("
) around the string, breaking it when it's included inpostgresql.auto.conf
:ISSUE TYPE
COMPONENT NAME
community.postgresql.postgresql_set
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
EndeavourOS (Arch variant) running Ansible from system
ansible
package, version 3.1.0.STEPS TO REPRODUCE
in role
defaults/main.yml
:and in role
tasks/main.yml
EXPECTED RESULTS
keys with values that contain commas get correctly rendered out to postgresql and entered into the
postgresql.auto.conf
without extraneous quotes.ACTUAL RESULTS
for some reason module renders values with commas with extra double quotes around them, breaking postgres config. I've verified that if I change the above config line to the following, it works correctly and doesn't inject extra quotes:
interestingly, ansible doesn't show the extra quotes in the command output, they only show up in the destination file itself:
The text was updated successfully, but these errors were encountered: