loopdb: postgres password with URL-reserved characters breaks the connection
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
Hướng nghiên cứu
Bắt đầu từ PostgresConfig.DSN và kiểm tra cách DSN hiện tại được ghép và ghi log. Bổ sung phần kiểm thử dạng bảng được yêu cầu cho các mật khẩu chứa các ký tự dành riêng cho URL, bao gồm việc phân tích kết quả bằng net/url, và chạy các bài kiểm thử Go liên quan. Được xem là hoàn tất khi user, password, host và database sau khi phân tích vẫn không thay đổi, bao gồm cả việc xử lý host IPv6.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Go
- Star
- 593
- Fork
- 138
- Merge trung bình
- 4 ngày 18 giờ
- Pull request đã merge (30 ngày)
- 20
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của lightninglabs/loop
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 50/100
lightninglabs/loop#1208 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
lightninglabs/loop#1196 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 42/100
lightninglabs/loop#1172 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Track armed static address HTLCs after aborted swapsCó thể làm lại được @hieblmi đã nhận 107 ngày trước và không có pull request nào đang mở. Đang mở
lightninglabs/loop#1171 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
lightninglabs/loop#1170 ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của lightninglabs/loop
Issue tương tự
-
Project submission:Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
slavakurilyak/awesome-ai-agents#845 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
JakeChampion/lang#13132 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] deploy.restart_policy without condition drops the restart policyCó thể đã có người làm @akshat-lakhera đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
docker/compose#14383 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày