Find, verify, and analyze leaked credentials
Go credentialsdevsecopsdynamic-analysisprecommitscanningsecretsecret-managementsecretssecuritysecurity-toolstrufflehogverification
Added support for SSH URIs (#725)
Haz4cc3529bc559
diff --git a/pkg/sources/git/git.go b/pkg/sources/git/git.goindex e796855d0..8b5d5bbfb 100644--- a/pkg/sources/git/git.go+++ b/pkg/sources/git/git.go@@ -266,6 +266,12 @@ func CloneRepoUsingUnauthenticated(url string, args ...string) (string, *git.Repreturn CloneRepo(nil, url, args...)}+// CloneRepoUsingUnauthenticated clones a repo with no authentication required.+func CloneRepoUsingSSH(gitUrl string, args ...string) (string, *git.Repository, error) {+ userInfo := url.User("git")+ return CloneRepo(userInfo, gitUrl, args...)+}+func GitCmdCheck() error {if errors.Is(exec.Command("git").Run(), exec.ErrNotFound) {return fmt.Errorf("'git' command not found in $PATH. Make sure git is installed and included in $PATH")@@ -581,6 +587,13 @@ func PrepareRepo(uriString string) (string, bool, error) {return path, remote, fmt.Errorf("failed to clone unauthenticated Git repo (%s): %s", remotePath, err)}}+ case "ssh":+ remotePath := uri.String()+ remote = true+ path, _, err = CloneRepoUsingSSH(remotePath)+ if err != nil {+ return path, remote, fmt.Errorf("failed to clone unauthenticated Git repo (%s): %s", remotePath, err)+ }default:return "", remote, fmt.Errorf("unsupported Git URI: %s", uriString)}