Skip to content

fix(sec): percent-encode or quote the database password in remaining DSN builders - #588

Merged
cristim merged 2 commits into
mainfrom
fix/percent-encode-db-password-sites
Oct 6, 2026
Merged

cristim merged 2 commits into
mainfrom
fix/percent-encode-db-password-sites

Conversation

@cristim

@cristim cristim commented Oct 6, 2026

Copy link
Copy Markdown
Member

Refs #557

Follows #555 and #556. Applies the same encoding to the remaining builders:

  • ci.yml migrate step and the two DEPLOYMENT.md migrate commands: password encoded with jq -sRr @uri.
  • internal/testutil/postgres.go: ConnectionString uses url.URL with url.UserPassword.
  • internal/database/config.go: keyword DSN single-quotes (and escapes) passwords with whitespace, quotes or backslashes; other passwords are unchanged.

Tests parse the DSN back with pgconn.ParseConfig using a password with @ : / % # ? space and both quote kinds; both fail on main and pass here.

Not changed: scripts/entrypoint.sh keeps its awk encoder (the container may not ship jq); unifying it is left open. Refs rather than Closes for that reason.

…DSN builders

Encode the password with jq -sRr @uri in the CI migrate step and the DEPLOYMENT.md migrate commands, build the testutil connection string with url.UserPassword, and single-quote keyword DSN passwords that contain whitespace, quotes or backslashes. Round-trip tests parse the result back with pgx.
@cristim cristim added priority/p2 Backlog-worthy severity/medium Moderate harm triaged Item has been triaged urgency/this-quarter Within the quarter impact/few Limited audience effort/s Hours type/security Security finding labels Oct 6, 2026
@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

  • Run on-demand review

This review includes 6 billable files and costs up to $1.50.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 43 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 64 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: LeanerCloud/cloud-commitments-platform/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 2340bdca-3327-4d9f-ae09-8d3ba1fe2055
📥 Commits

Reviewing files that changed from the base of the PR and between ba824a3 and e884801.

📒 Files selected for processing (6)
  • .github/workflows/ci.yml
  • docs/DEPLOYMENT.md
  • internal/database/config.go
  • internal/database/config_test.go
  • internal/testutil/postgres.go
  • internal/testutil/postgres_test.go
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

…ords

Make the second DEPLOYMENT.md migrate block extract .password like the first.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/s Hours impact/few Limited audience priority/p2 Backlog-worthy severity/medium Moderate harm triaged Item has been triaged type/security Security finding urgency/this-quarter Within the quarter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant