Skip to content
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

[entrypoint] validate connection str and escape special chars #77

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ryan-mccaffrey
Copy link
Contributor

Checks that connection string begins with a valid postgres:// and contains at max one @ character.

Escapes * and . special chars when parsing the hostport from the connection string.

entrypoint.sh Outdated
@@ -11,6 +11,16 @@ PG_CONFIG_DIR=/etc/pgbouncer
if [ -n "$DATABASE_URL" ]; then
# Thanks to https://stackoverflow.com/a/17287984/146289

# Check that begins with valid postgres:// prefix and has at max one '@' char
charcount=$(echo $DATABASE_URL | grep -o "@" | wc -l)
if [[ ! "$DATABASE_URL" =~ ^postgres:// ]]; then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

postgresql is also valid and some python library stopped supporting postgres

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize it's also possible to have formats like:

DATABASE_URL=postgresql+asyncpg://username:password@host:port/dtabase_name

so i think it's easiest to remove the check for connection string formatting for now

@ryan-mccaffrey
Copy link
Contributor Author

This is now updated to remove the connection string format validation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants