From d10a4936fb79524a1325cde1e06afd44a7c0fefb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=99=93=E4=BC=9F?= Date: Tue, 11 Jul 2023 16:38:15 +0800 Subject: [PATCH] :bug: Do not upload username and password. https://gitee.com/murphysecurity/murphysec/issues/I7KB5R --- gitinfo/gitinfo.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/gitinfo/gitinfo.go b/gitinfo/gitinfo.go index 93c4af9..57147d5 100644 --- a/gitinfo/gitinfo.go +++ b/gitinfo/gitinfo.go @@ -3,9 +3,11 @@ package gitinfo import ( "context" "errors" + "fmt" "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/plumbing" "github.com/murphysecurity/murphysec/infra/logctx" + "net/url" "time" ) @@ -74,7 +76,16 @@ func getRemoteURL(ctx context.Context, repo *git.Repository) (string, error) { return "", _ErrNoRemoteURLFound } - return candidateURLs[0], nil + var candidateURL = candidateURLs[0] + + u, err := url.Parse(candidateURL) + if err != nil { + return candidateURL, nil + } + + var newURL = fmt.Sprintf("%s://%s%s", u.Scheme, u.Host, u.Path) + + return newURL, nil } func getCommitInfo(ctx context.Context, repo *git.Repository, hash plumbing.Hash) (*commitInfo, error) { -- Gitee