加固PostgreSQL连接参数与凭据脱敏并完成重复回归

This commit is contained in:
xuans committed 2026-09-16 21:09:21 +08:00
1 parent 16428f05b3
commit 781da9f32c
7 files changed
+278 -42

No files matched your search

+5
View File
@@ -479,6 +479,11 @@ func (c Config) Validate() error {
if databaseDSNContainsPassword(c.Database.Driver, c.Database.DSN) {
return fmt.Errorf("数据库连接信息不能包含密码,请使用加密凭据引用")
}
if c.Database.Driver == "postgres" {
if err := ValidatePostgresDSN(c.Database.DSN); err != nil {
return err
}
}
}
if c.Database.MaxOpenConns < 1 || c.Database.MaxIdleConns < 0 || c.Database.MaxIdleConns > c.Database.MaxOpenConns {
return fmt.Errorf("数据库连接池配置无效")