mirror of
https://github.com/goharbor/harbor.git
synced 2025-02-28 09:42:05 +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 (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/goharbor/harbor/src/common/models"
|
"net"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/goharbor/harbor/src/common/models"
|
||||||
|
|
||||||
"github.com/astaxie/beego/orm"
|
"github.com/astaxie/beego/orm"
|
||||||
"github.com/goharbor/harbor/src/common/utils"
|
"github.com/goharbor/harbor/src/common/utils"
|
||||||
"github.com/goharbor/harbor/src/lib/log"
|
"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.
|
// Register registers pgSQL to orm with the info wrapped by the instance.
|
||||||
func (p *pgsql) Register(alias ...string) error {
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,7 +144,7 @@ func NewMigrator(database *models.PostGreSQL) (*migrate.Migrate, error) {
|
|||||||
dbURL := url.URL{
|
dbURL := url.URL{
|
||||||
Scheme: "postgres",
|
Scheme: "postgres",
|
||||||
User: url.UserPassword(database.Username, database.Password),
|
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,
|
Path: database.Database,
|
||||||
RawQuery: fmt.Sprintf("sslmode=%s", database.SSLMode),
|
RawQuery: fmt.Sprintf("sslmode=%s", database.SSLMode),
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package exporter
|
package exporter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
var hbrCli *HarborClient
|
var hbrCli *HarborClient
|
||||||
@ -19,7 +20,7 @@ type HarborClient struct {
|
|||||||
func (hc HarborClient) harborURL(p string) url.URL {
|
func (hc HarborClient) harborURL(p string) url.URL {
|
||||||
return url.URL{
|
return url.URL{
|
||||||
Scheme: hc.HarborScheme,
|
Scheme: hc.HarborScheme,
|
||||||
Host: fmt.Sprintf("%s:%d", hc.HarborHost, hc.HarborPort),
|
Host: net.JoinHostPort(hc.HarborHost, strconv.Itoa(hc.HarborPort)),
|
||||||
Path: p,
|
Path: p,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user