Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

loopdb: postgres password with URL-reserved characters breaks the connection

オープン 初心者向け
#1,246 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 7 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
go, postgres
領域
databases

調査の方向性

PostgresConfig.DSN から始めて、現在の DSN がどのように組み立てられ、ログに記録されているかを確認します。URL で予約されている文字を含むパスワードについて、要求されたテーブル駆動のテストカバレッジを追加し、net/url で結果をパースする処理も含めて、関連する Go テストを実行します。パースされたユーザー、パスワード、ホスト、データベースが、IPv6 ホストの処理を含めて変更されないことが完了の条件です。

索引モデルが issue の本文から書いたものです。

説明

Title: loopdb: postgres password with URL-reserved characters breaks the connection

Background

PostgresConfig.DSN builds the connection string with fmt.Sprintf, putting the user and password into the URL without escaping them:

dsnTemplate = "postgres://%v:%v@%v:%d/%v?sslmode=%v"

pgx parses this string with net/url, so any URL-reserved character in the password changes how the URL is parsed. For example, / ends the authority section early, so with --postgres.password=ab/cd the string becomes:

postgres://loop:ab/cd@localhost:5432/loop?sslmode=disable

This parses as host loop:ab and path /cd@localhost:5432/loop, so loopd fails to connect. #, ? and % cause similar failures.

Passwords made with common tools such as openssl rand -base64 often contain /. #1088 adds a way to read the password from a file, which encourages exactly this kind of generated password, so this is likely to come up more often.

Proposed fix

Build the DSN with net/url so each part is escaped correctly:

dsn := url.URL{
	Scheme:   "postgres",
	User:     url.UserPassword(s.User, password),
	Host:     net.JoinHostPort(s.Host, strconv.Itoa(s.Port)),
	Path:     s.DBName,
	RawQuery: url.Values{"sslmode": {sslMode}}.Encode(),
}

net.JoinHostPort also brackets IPv6 host literals correctly, which the current template doesn't do. The hidePassword placeholder used when logging stays as it is.

Add a table-driven test for DSN that runs passwords containing /, @, :, #, ?, % and spaces through url.Parse and checks that the user, password, host and database come back unchanged.

主要言語
Go
スター
593
フォーク
138
平均マージ
4日 9時間
マージ済み PR(30日)
14

環境構築

  • Dockerfile または Docker Compose ファイルあり
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

lightninglabs/loop のほかの issue

lightninglabs/loop の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。