mirror of
https://github.com/goharbor/harbor.git
synced 2025-02-28 01:32:15 +01:00
Fix semgrep sprintf-host-port (#15782)
Signed-off-by: Soumik Majumder <soumikm@vmware.com>
This commit is contained in:
parent
b4c2ff7768
commit
eb7329a471
@ -16,12 +16,14 @@ package dao
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
"net"
|
||||
"net/url"
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/goharbor/harbor/src/common/models"
|
||||
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/goharbor/harbor/src/common/utils"
|
||||
"github.com/goharbor/harbor/src/lib/log"
|
||||
@ -74,7 +76,7 @@ func NewPGSQL(host string, port string, usr string, pwd string, database string,
|
||||
|
||||
// Register registers pgSQL to orm with the info wrapped by the instance.
|
||||
func (p *pgsql) Register(alias ...string) error {
|
||||
if err := utils.TestTCPConn(fmt.Sprintf("%s:%s", p.host, p.port), 60, 2); err != nil {
|
||||
if err := utils.TestTCPConn(net.JoinHostPort(p.host, p.port), 60, 2); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -142,7 +144,7 @@ func NewMigrator(database *models.PostGreSQL) (*migrate.Migrate, error) {
|
||||
dbURL := url.URL{
|
||||
Scheme: "postgres",
|
||||
User: url.UserPassword(database.Username, database.Password),
|
||||
Host: fmt.Sprintf("%s:%d", database.Host, database.Port),
|
||||
Host: net.JoinHostPort(database.Host, strconv.Itoa(database.Port)),
|
||||
Path: database.Database,
|
||||
RawQuery: fmt.Sprintf("sslmode=%s", database.SSLMode),
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
package exporter
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
var hbrCli *HarborClient
|
||||
@ -19,7 +20,7 @@ type HarborClient struct {
|
||||
func (hc HarborClient) harborURL(p string) url.URL {
|
||||
return url.URL{
|
||||
Scheme: hc.HarborScheme,
|
||||
Host: fmt.Sprintf("%s:%d", hc.HarborHost, hc.HarborPort),
|
||||
Host: net.JoinHostPort(hc.HarborHost, strconv.Itoa(hc.HarborPort)),
|
||||
Path: p,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user