mirror of
https://github.com/shadow1ng/fscan.git
synced 2026-09-23 19:51:52 +08:00
fix: harden address parsing edge cases
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/shadow1ng/fscan/common"
|
||||
)
|
||||
|
||||
func TestPostgreSQLConnStringEscapesIPv6AndCredentials(t *testing.T) {
|
||||
info := &common.HostInfo{Host: "2001:db8::1", Port: 5432}
|
||||
got := postgreSQLConnString("user:name", "pa:ss word", info, 3)
|
||||
|
||||
for _, want := range []string{
|
||||
"postgres://user%3Aname:pa%3Ass%20word@[2001:db8::1]:5432/postgres",
|
||||
"connect_timeout=3",
|
||||
"sslmode=disable",
|
||||
} {
|
||||
if !strings.Contains(got, want) {
|
||||
t.Fatalf("postgreSQLConnString() = %q, missing %q", got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user