mirror of
https://github.com/trufflesecurity/trufflehog.git
synced 2024-11-10 15:14:38 +00:00
Added support for SSH URIs (#725)
This commit is contained in:
parent
df53dd5a5b
commit
4cc3529bc5
1 changed files with 13 additions and 0 deletions
|
@ -266,6 +266,12 @@ func CloneRepoUsingUnauthenticated(url string, args ...string) (string, *git.Rep
|
||||||
return CloneRepo(nil, url, args...)
|
return 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 {
|
func GitCmdCheck() error {
|
||||||
if errors.Is(exec.Command("git").Run(), exec.ErrNotFound) {
|
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")
|
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)
|
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:
|
default:
|
||||||
return "", remote, fmt.Errorf("unsupported Git URI: %s", uriString)
|
return "", remote, fmt.Errorf("unsupported Git URI: %s", uriString)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue