Skip to content

Commit

Permalink
Use url redaction in git (trufflesecurity#1399)
Browse files Browse the repository at this point in the history
Co-authored-by: Zachary Rice <[email protected]>
  • Loading branch information
trufflesteeeve and zricethezav authored Jun 26, 2023
1 parent 06f2d3a commit 11bff81
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions pkg/sources/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 11bff81

Please sign in to comment.