Skip to content

Find, verify, and analyze leaked credentials

Use url redaction in git (#1399)

trufflesteeeve11bff81def49
diff --git a/pkg/sources/git/git.go b/pkg/sources/git/git.go
index e269c5309..4f38c399d 100644
--- a/pkg/sources/git/git.go
+++ b/pkg/sources/git/git.go
@@ -660,9 +660,7 @@ func stripPassword(u string) (string, error) {
return "", errors.WrapPrefix(err, "repo remote cannot be sanitized as URI", 0)
}
- repoURL.User = nil
-
- return repoURL.String(), nil
+ return repoURL.Redacted(), nil
}
// TryAdditionalBaseRefs looks for additional possible base refs for a repo and returns a hash if found.
@@ -739,7 +737,7 @@ func PrepareRepoSinceCommit(ctx context.Context, uriString, commitHash string) (
var path string
switch {
case uri.User != nil:
- ctx.Logger().V(1).Info("cloning repo with authentication", "uri", uri)
+ ctx.Logger().V(1).Info("cloning repo with authentication", "uri", uri.Redacted())
password, ok := uri.User.Password()
if !ok {
return "", true, fmt.Errorf("password must be included in Git repo URL when username is provided")
@@ -777,7 +775,7 @@ func PrepareRepo(ctx context.Context, uriString string) (string, bool, error) {
remote = true
switch {
case uri.User != nil:
- ctx.Logger().V(1).Info("cloning repo with authentication", "uri", uri)
+ ctx.Logger().V(1).Info("cloning repo with authentication", "uri", uri.Redacted())
password, ok := uri.User.Password()
if !ok {
return "", remote, fmt.Errorf("password must be included in Git repo URL when username is provided")