mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-28 12:14:22 +01:00
better ssh handling
This commit is contained in:
1 parent
e288db29a8
commit
98e6ba9378
3 files changed
+57
-73
No files matched your search
@@ -117,11 +117,11 @@ func auditGithubRepos() ([]Leak, error) {
|
||||
break
|
||||
}
|
||||
if opts.GithubUser != "" {
|
||||
if opts.IncludePrivate {
|
||||
pagedGithubRepos, resp, err = githubClient.Repositories.List(ctx, "", githubOptions)
|
||||
} else {
|
||||
pagedGithubRepos, resp, err = githubClient.Repositories.List(ctx, opts.GithubUser, githubOptions)
|
||||
}
|
||||
// if opts.IncludePrivate {
|
||||
// pagedGithubRepos, resp, err = githubClient.Repositories.List(ctx, "", githubOptions)
|
||||
// } else {
|
||||
pagedGithubRepos, resp, err = githubClient.Repositories.List(ctx, opts.GithubUser, githubOptions)
|
||||
// }
|
||||
if err != nil {
|
||||
done = true
|
||||
}
|
||||
@@ -199,10 +199,7 @@ func cloneGithubRepo(githubRepo *github.Repository) (*RepoDescriptor, error) {
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to generater owner temp dir: %v", err)
|
||||
}
|
||||
if opts.IncludePrivate {
|
||||
if sshAuth == nil {
|
||||
return nil, fmt.Errorf("no ssh auth available")
|
||||
}
|
||||
if sshAuth != nil {
|
||||
repo, err = git.PlainClone(fmt.Sprintf("%s/%s", ownerDir, *githubRepo.Name), false, &git.CloneOptions{
|
||||
URL: *githubRepo.SSHURL,
|
||||
Auth: sshAuth,
|
||||
@@ -213,10 +210,7 @@ func cloneGithubRepo(githubRepo *github.Repository) (*RepoDescriptor, error) {
|
||||
})
|
||||
}
|
||||
} else {
|
||||
if opts.IncludePrivate {
|
||||
if sshAuth == nil {
|
||||
return nil, fmt.Errorf("no ssh auth available")
|
||||
}
|
||||
if sshAuth != nil {
|
||||
repo, err = git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
|
||||
URL: *githubRepo.SSHURL,
|
||||
Auth: sshAuth,
|
||||
|
||||
Reference in new issue
Block a user