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.
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.
I can be even more creative 😈 :
The spaces will break the command, and according to https://www.postgresql.org/docs/current/libpq-pgpass.html:
So I think we should also escape the
database_name
,database_user
anddatabase_password
accordingly (I do not think these chars are valid for a hostname), and then shell-escape the whole pattern:I only tested the pattern substitution (which required much escaping than i though), so we probably need to test this for real with users with annoying chars in their name to be sure it is fine.
But all this is probably overkill, maybe we can just detect "forbidden" chars and raise an error because nobody wants to do this kind of things?
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.
In my opinion postgresql admins should know that they must avoid special characters in databases names and usernames. This is a bit different for passwords than can be sometimes randomly generated or have strong complexity requirements. In my case I used
pwgen
to get a strong password.They should also know that escape characters in passwords will break everything and must be avoided. So I think this is reasonable to keep the fix as simple as possible.