Compare commits

...
25 Commits
Author SHA1 Message Date
Zachary Rice f50577be1c Merge pull request #131 from zricethezav/feature/default-regex
Feature/default regex
2018-10-26 14:04:15 -05:00
zach rice c358ae9310 changelog 2018-10-26 13:53:16 -05:00
zach rice 9554258d02 adding some more defaults 2018-10-26 13:48:14 -05:00
Zachary Rice 95ee2cc30e Merge pull request #128 from r--w/patch-1
Telegram bot API token
2018-10-26 13:26:08 -05:00
Zachary Rice 79a35f0c27 Merge branch 'master' into patch-1 2018-10-26 13:25:58 -05:00
Zachary Rice 7a021cda9e Merge pull request #129 from harston/patch-1
Add PGP header
2018-10-26 13:25:23 -05:00
Zachary Rice 447f7a04cb Merge branch 'master' into patch-1 2018-10-26 13:24:55 -05:00
Zachary Rice e5b62cbc7c Merge pull request #130 from harston/patch-2
Add slack token
2018-10-26 13:24:01 -05:00
Paweł Gawinek 6739a34f74 Add slack token
Add Slack token from https://api.slack.com/docs/token-types 

#hactoberfest #greywizard
2018-10-26 10:36:04 +02:00
Paweł Gawinek e502bf29de Add PGP header
Add PGP private key header 

#hactoberfest #greywizard
2018-10-26 10:23:26 +02:00
Radoslaw Wesolowski 51b504bf99 Telegram bot API token
Format is described here: https://core.telegram.org/bots/api#authorizing-your-bot

#hactoberfest #greywizard
2018-10-26 09:22:18 +02:00
Zachary Rice 107d582e7b Merge pull request #127 from zricethezav/fix/ssh-logic
fixing default ssh logic
2018-10-25 12:38:14 -05:00
zach rice ea42ed406f fixing default ssh logic 2018-10-25 12:27:50 -05:00
Zachary Rice c869812875 Merge pull request #125 from ziyaddin/patch-1
Fix typos in docs
2018-10-24 17:06:43 -05:00
Zachary Rice 4f7ce9c195 Merge pull request #126 from zricethezav/fix/concurrency
Fix/concurrency
2018-10-24 16:56:01 -05:00
zach rice 847687a637 fixing test. travis doesnt have rsa id 2018-10-24 16:48:34 -05:00
zach rice 94389137e8 removing private opts 2018-10-24 16:00:15 -05:00
zach rice 98e6ba9378 better ssh handling 2018-10-24 15:49:53 -05:00
zach rice e288db29a8 fixing tests 2018-10-24 12:40:05 -05:00
zach rice 98aeee9b1d fixing everything 2018-10-24 12:28:54 -05:00
Ziyaddin Sadigov 45a2aa8495 Fix typos in changelog 2018-10-24 21:19:40 +04:00
Ziyaddin Sadigov 4b350987a1 Fix typos in contributing.md 2018-10-24 21:11:29 +04:00
Ziyaddin Sadigov 3b2b754fe5 Fix typos in readme 2018-10-24 21:06:08 +04:00
zach rice 64e7afea98 updating version 2018-10-24 09:58:39 -05:00
zach rice 16765c19cf adding go routines does not help performance much.... posting benchmarks soon 2018-10-24 09:38:36 -05:00
7 changed files with 138 additions and 182 deletions

No files matched your search

+19 -4
View File
@@ -1,6 +1,21 @@
CHANGELOG
=========
1.17.0
----
- Default regex added to search: slack, telegram.
- Default whitelisting: bin, doc, jpeg, gif
1.16.1
----
- Fixing default ssh auth logic
1.16.0
----
- Better commit coverage. Now iterates through each commit in git log and generates a patch with each commit's parent.
- Removing the need for --private/-p option. Instead gitleaks will determine if the repo is private or not.
1.15.0
----
- Whitelist repos use regex now
@@ -72,14 +87,14 @@ CHANGELOG
1.6.0
-----
- Default maximum goroutines spawned is number of cores your cpu run with. See benchmarks in wiki.
- Cleanup after each repo audit for organizations rather than waiting for the entire organization to complete. Eliminates risk of running out of disk space.
- Default maximum goroutines spawned is number of cores your CPU run with. See benchmarks in wiki.
- Cleanup after each repo audit for organizations rather than waiting for the entire organization to complete. Eliminates the risk of running out of disk space.
1.5.0
-----
- Support for CSV reporting
- Refactoring github user/owner audits
- Refactoring Github user/owner audits
1.4.0
-----
@@ -96,7 +111,7 @@ CHANGELOG
1.2.0
-----
- Added support for providing an alternate GitHub URL to support scanning GitHub Enteprise repositories
- Added support for providing an alternate GitHub URL to support scanning GitHub Enterprise repositories
1.1.2
-----
+3 -3
View File
@@ -5,14 +5,14 @@ contributions via GitHub pull requests.
## How to Contribute
Open a PR. Give the PR a descriptive title. Add some comments describing whats the purpose of the PR.
Open a PR. Give the PR a descriptive title. Add some comments describing what is the purpose of the PR.
__BUT before you do that!__
Make sure you pass this list of requirements.
- You've ran `go fmt`.
- You've ran `golint`.
- You've run `go fmt`.
- You've run `golint`.
- Your Go changes are confined to `gitleaks_test.go` and `main.go`. This is subject to change as the project evolves. Stylistically, I like having a single go file considering the size of this project (its tiny).
- You've added test cases for your changes.
- You've updated [the changelog](CHANGELOG.md).
+4 -5
View File
@@ -68,7 +68,6 @@ Application Options:
--github-org= Github organization to audit
--github-url= GitHub API Base URL, use for GitHub Enterprise. Example: https://github.example.com/api/v3/ (default: https://api.github.com/)
--github-pr= Github PR url to audit. This does not clone the repo. GITHUB_TOKEN must be set
-p, --private Include private repos in audit
-b, --branch= branch name to audit (defaults to HEAD)
-c, --commit= sha of commit to stop at
--depth= maximum commit depth
@@ -94,7 +93,7 @@ Help Options:
```
#### Exit Codes
Gitleaks provides consisten exist codes to assist in automation workflows such as CICD platforms and bulk scanning.
Gitleaks provides consistent exist codes to assist in automation workflows such as CICD platforms and bulk scanning.
These can be effectively used in conjunction with the report output file to detect and return meaningful data back to the user or external system about if leaks have been detected, and where they reside.
@@ -114,10 +113,10 @@ The code return codes are:
* [Rewrite git history with the BFG (theguardian.com)](https://www.theguardian.com/info/developer-blog/2013/apr/29/rewrite-git-history-with-the-bfg)
* [Auditing Bitbucket Server Data for Credentials in AWS (sourcedgroup.com)](https://www.sourcedgroup.com/blog/auditing-bitbucket-server-data-credentials-in-aws)
This blog post details how gitleaks was used to audit data in Atlassian Bitbucket server when hosted on AWS, and visualise the results in a compliance dashboard using Splunk.
This blog post details how gitleaks was used to audit data in Atlassian Bitbucket server when hosted on AWS and visualise the results in a compliance dashboard using Splunk.
* How does gitleaks differ to github token scanning ?
* [Github recently announced](https://blog.github.com/2018-10-16-future-of-software/#github-token-scanning-for-public-repositories-public-beta) a new capbility to their cloud platform that detects exposed credentials for a number of common services and platforms and automatically notifies the provider for revocation or similar action. Gitleaks provides a similar detection capability for non-github cloud users, in which repositories can be easily audited and results provided in a number of formats.
* How does gitleaks differ to Github token scanning?
* [Github recently announced](https://blog.github.com/2018-10-16-future-of-software/#github-token-scanning-for-public-repositories-public-beta) a new capability to their cloud platform that detects exposed credentials for a number of common services and platforms and automatically notifies the provider for revocation or similar action. Gitleaks provides a similar detection capability for non-Github cloud users, in which repositories can be easily audited and results provided in a number of formats.
+4 -18
View File
@@ -117,11 +117,7 @@ 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)
}
pagedGithubRepos, resp, err = githubClient.Repositories.List(ctx, opts.GithubUser, githubOptions)
if err != nil {
done = true
}
@@ -147,12 +143,8 @@ func auditGithubRepos() ([]Leak, error) {
}
}
}
if err != nil {
return nil, err
}
if opts.Disk {
ownerDir, err = ioutil.TempDir(dir, opts.GithubUser)
os.RemoveAll(ownerDir)
ownerDir, _ = ioutil.TempDir(dir, opts.GithubUser)
}
for _, githubRepo := range githubRepos {
repo, err := cloneGithubRepo(githubRepo)
@@ -199,10 +191,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 +202,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,
+9
View File
@@ -20,6 +20,15 @@ regex = '''(?i)facebook.*['\"][0-9a-f]{32}['\"]'''
[[regexes]]
description = "Twitter"
regex = '''(?i)twitter.*['\"][0-9a-zA-Z]{35,44}['\"]'''
[[regexes]]
description = "Telegram"
regex = '''(?i)telegram.*['\"][0-9]{1,12}+:[0-9a-zA-Z-]{32,44}['\"]'''
[[regexes]]
description = "PGP"
regex = '''-----BEGIN PGP PRIVATE KEY BLOCK-----'''
[[regexes]]
description = "Slack token"
regex = '''xoxo[bapr]-.*'''
[whitelist]
regexes = [
+20 -44
View File
@@ -167,17 +167,15 @@ func TestGetRepo(t *testing.T) {
},
{
testOpts: Options{
Repo: "https://github.com/gitleakstest/private",
IncludePrivate: true,
Repo: "https://github.com/gitleakstest/private",
},
description: "test private repo",
expectedErrMsg: "invalid auth method",
},
{
testOpts: Options{
Repo: "https://github.com/gitleakstest/private",
IncludePrivate: true,
Disk: true,
Repo: "https://github.com/gitleakstest/private",
Disk: true,
},
description: "test private repo",
expectedErrMsg: "invalid auth method",
@@ -264,13 +262,12 @@ func TestRun(t *testing.T) {
},
{
testOpts: Options{
GithubOrg: "gitleakstestorg",
IncludePrivate: true,
SSHKey: "reallyreallyreallyreallywrongpath",
Repo: "git@github.com:gitleakstest/gronit.git",
SSHKey: "trash",
},
description: "test private org no ssh",
description: "test leak",
numLeaks: 0,
expectedErrMsg: "unable to generate ssh key: open reallyreallyreallyreallywrongpath: no such file or directory",
expectedErrMsg: "unable to generate ssh key: open trash: no such file or directory",
},
{
testOpts: Options{
@@ -634,28 +631,28 @@ func TestAuditRepo(t *testing.T) {
testOpts: Options{
Entropy: 4.7,
},
numLeaks: 7,
numLeaks: 6,
},
{
repo: leaksRepo,
description: "Audit until specific commit",
numLeaks: 1,
numLeaks: 2,
testOpts: Options{
Commit: "f6839959b7bbdcd23008f1fb16f797f35bcd3a0c",
},
},
{
repo: leaksRepo,
description: "commit depth = 1, no leaks",
numLeaks: 0,
description: "commit depth = 1, one leak",
numLeaks: 1,
testOpts: Options{
Depth: 1,
},
},
{
repo: leaksRepo,
description: "commit depth = 2, one leak",
numLeaks: 1,
description: "commit depth = 2, two leaks",
numLeaks: 2,
testOpts: Options{
Depth: 2,
},
@@ -663,7 +660,7 @@ func TestAuditRepo(t *testing.T) {
{
repo: leaksRepo,
description: "toml entropy range",
numLeaks: 422,
numLeaks: 283,
configPath: path.Join(configsDir, "entropy"),
},
{
@@ -751,45 +748,24 @@ func TestOptionGuard(t *testing.T) {
},
{
testOpts: Options{
IncludePrivate: true,
GithubOrg: "fakeOrg",
},
description: "private org no githubtoken",
expectedErrMsg: "user/organization private repos require env var GITHUB_TOKEN to be set",
githubToken: false,
},
{
testOpts: Options{
IncludePrivate: true,
GithubUser: "fakeUser",
},
description: "private user no githubtoken",
expectedErrMsg: "user/organization private repos require env var GITHUB_TOKEN to be set",
githubToken: false,
},
{
testOpts: Options{
IncludePrivate: true,
GithubUser: "fakeUser",
GithubOrg: "fakeOrg",
GithubUser: "fakeUser",
GithubOrg: "fakeOrg",
},
description: "double owner",
expectedErrMsg: "github user and organization set",
},
{
testOpts: Options{
IncludePrivate: true,
GithubOrg: "fakeOrg",
OwnerPath: "/dev/null",
GithubOrg: "fakeOrg",
OwnerPath: "/dev/null",
},
description: "local and remote target",
expectedErrMsg: "github organization set and local owner path",
},
{
testOpts: Options{
IncludePrivate: true,
GithubUser: "fakeUser",
OwnerPath: "/dev/null",
GithubUser: "fakeUser",
OwnerPath: "/dev/null",
},
description: "local and remote target",
expectedErrMsg: "github user set and local owner path",
+79 -108
View File
@@ -60,12 +60,11 @@ type RepoDescriptor struct {
// Options for gitleaks
type Options struct {
// remote target options
Repo string `short:"r" long:"repo" description:"Repo url to audit"`
GithubUser string `long:"github-user" description:"Github user to audit"`
GithubOrg string `long:"github-org" description:"Github organization to audit"`
GithubURL string `long:"github-url" default:"https://api.github.com/" description:"GitHub API Base URL, use for GitHub Enterprise. Example: https://github.example.com/api/v3/"`
GithubPR string `long:"github-pr" description:"Github PR url to audit. This does not clone the repo. GITHUB_TOKEN must be set"`
IncludePrivate bool `short:"p" long:"private" description:"Include private repos in audit"`
Repo string `short:"r" long:"repo" description:"Repo url to audit"`
GithubUser string `long:"github-user" description:"Github user to audit"`
GithubOrg string `long:"github-org" description:"Github organization to audit"`
GithubURL string `long:"github-url" default:"https://api.github.com/" description:"GitHub API Base URL, use for GitHub Enterprise. Example: https://github.example.com/api/v3/"`
GithubPR string `long:"github-pr" description:"Github PR url to audit. This does not clone the repo. GITHUB_TOKEN must be set"`
/*
TODO:
@@ -137,7 +136,7 @@ type entropyRange struct {
}
const defaultGithubURL = "https://api.github.com/"
const version = "1.15.0"
const version = "1.17.0"
const errExit = 2
const leakExit = 1
const defaultConfig = `
@@ -146,53 +145,61 @@ const defaultConfig = `
# is set, gitleaks will load configurations from that path. If option --config-path is set, gitleaks will load
# configurations from that path. Gitleaks does not whitelist anything by default.
title = "gitleaks config"
# add regexes to the regex table
[[regexes]]
description = "AWS"
regex = '''AKIA[0-9A-Z]{16}'''
[[regexes]]
description = "RKCS8"
description = "PKCS8"
regex = '''-----BEGIN PRIVATE KEY-----'''
[[regexes]]
description = "RSA"
regex = '''-----BEGIN RSA PRIVATE KEY-----'''
[[regexes]]
description = "Github"
regex = '''(?i)github.*['\"][0-9a-zA-Z]{35,40}['\"]'''
[[regexes]]
description = "SSH"
regex = '''-----BEGIN OPENSSH PRIVATE KEY-----'''
[[regexes]]
description = "PGP"
regex = '''-----BEGIN PGP PRIVATE KEY BLOCK-----'''
[[regexes]]
description = "Facebook"
regex = '''(?i)facebook.*['\"][0-9a-f]{32}['\"]'''
[[regexes]]
description = "Twitter"
regex = '''(?i)twitter.*['\"][0-9a-zA-Z]{35,44}['\"]'''
[[regexes]]
description = "Github"
regex = '''(?i)github.*['\"][0-9a-zA-Z]{35,40}['\"]'''
[[regexes]]
description = "Slack"
regex = '''xoxo[bapr]-.*'''
[[regexes]]
description = "Telegram"
regex = '''\d{5,}:A[a-zA-Z0-9_\-]{34,34}'''
[whitelist]
#regexes = [
# "AKAIMYFAKEAWKKEY",
#]
#files = [
# "(.*?)(jpg|gif|doc|pdf|bin)$"
#]
regexes = [
'''(?i)github.*ref.*['\"][0-9a-fA-F]{35,40}['\"]''',
'''(?i)shasum.*['\"][0-9a-fA-F]{40}['\"]''',
'''(?i)githead.*['\"][0-9a-fA-F]{40}['\"]''',
'''(?i)email_hash.*['\"][0-9a-fA-F]{40}['\"]''',
'''(?i)email_hash.*['\"][0-9a-fA-F]{32}['\"]''',
'''(?i)rev.*:.*['\"][0-9a-fA-F]{40}['\"]''',
]
files = [
"(.*?)(jpg|gif|doc|pdf|bin)$"
]
#commits = [
# "BADHA5H1",
# "BADHA5H2",
#]
#branches = [
# "dev/goodrepo"
#]
#repos = [
# "mygoodrepo"
#]
[misc]
#entropy = [
# "3.3-4.30"
@@ -280,13 +287,11 @@ func run() ([]Leak, error) {
if err != nil {
return nil, err
}
if opts.IncludePrivate {
// if including private repos use ssh as authentication
sshAuth, err = getSSHAuth()
if err != nil {
return nil, err
}
sshAuth, err = getSSHAuth()
if err != nil {
return leaks, err
}
if opts.Disk {
// temporary directory where all the gitleaks plain clones will reside
dir, err = ioutil.TempDir("", "gitleaks")
@@ -319,8 +324,7 @@ func run() ([]Leak, error) {
leaks = append(leaksFromRepo, leaks...)
}
} else if opts.GithubOrg != "" || opts.GithubUser != "" {
// Audit a github owner -- a user or organization. If you want to include
// private repos you must pass a --private/-p option and have your ssh keys set
// Audit a github owner -- a user or organization.
leaks, err = auditGithubRepos()
if err != nil {
return leaks, err
@@ -355,9 +359,7 @@ func writeReport(leaks []Leak) error {
return err
}
// cloneRepo clones a repo to memory(default) or to disk if the --disk option is set. If you want to
// clone a private repo you must set the --private/-p option, use a ssh target, and have your ssh keys
// configured. If you want to audit a local repo, getRepo will load up a repo located at --repo-path
// cloneRepo clones a repo to memory(default) or to disk if the --disk option is set.
func cloneRepo() (*RepoDescriptor, error) {
var (
err error
@@ -372,7 +374,7 @@ func cloneRepo() (*RepoDescriptor, error) {
if opts.Disk {
log.Infof("cloning %s", opts.Repo)
cloneTarget := fmt.Sprintf("%s/%x", dir, md5.Sum([]byte(fmt.Sprintf("%s%s", opts.GithubUser, opts.Repo))))
if opts.IncludePrivate {
if strings.HasPrefix(opts.Repo, "git") {
repo, err = git.PlainClone(cloneTarget, false, &git.CloneOptions{
URL: opts.Repo,
Progress: os.Stdout,
@@ -385,11 +387,11 @@ func cloneRepo() (*RepoDescriptor, error) {
})
}
} else if opts.RepoPath != "" {
log.Infof("opening %s", opts.Repo)
log.Infof("opening %s", opts.RepoPath)
repo, err = git.PlainOpen(opts.RepoPath)
} else {
log.Infof("cloning %s", opts.Repo)
if opts.IncludePrivate {
if strings.HasPrefix(opts.Repo, "git") {
repo, err = git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
URL: opts.Repo,
Progress: os.Stdout,
@@ -473,95 +475,58 @@ func auditGitRepo(repo *RepoDescriptor) ([]Leak, error) {
}
// auditGitReference beings the audit for a git reference. This function will
// traverse the git reference and audit each line of each diff. Set maximum concurrency with
// the --max-go option (default is set to the number of cores on your cpu).
// traverse the git reference and audit each line of each diff.
func auditGitReference(repo *RepoDescriptor, ref *plumbing.Reference) []Leak {
var (
err error
prevCommit *object.Commit
semaphore chan bool
repoName string
leaks []Leak
commitCount int
commitWg sync.WaitGroup
mutex = &sync.Mutex{}
commitCount int
semaphore chan bool
)
repoName = repo.name
if opts.MaxGoRoutines != 0 {
maxGo = opts.MaxGoRoutines
}
if opts.RepoPath != "" {
maxGo = 1
}
semaphore = make(chan bool, maxGo)
cIter, err := repo.repository.Log(&git.LogOptions{From: ref.Hash()})
if err != nil {
return nil
}
err = cIter.ForEach(func(c *object.Commit) error {
if c.Hash.String() == opts.Commit || (opts.Depth != 0 && commitCount == opts.Depth) {
if c == nil || c.Hash.String() == opts.Commit || (opts.Depth != 0 && commitCount == opts.Depth) {
cIter.Close()
return errors.New("ErrStop")
}
commitCount = commitCount + 1
totalCommits = totalCommits + 1
if whiteListCommits[c.Hash.String()] {
prevCommit = c
log.Infof("skipping commit: %s\n", c.Hash.String())
return nil
}
if prevCommit != nil {
if whiteListCommits[prevCommit.Hash.String()] {
prevCommit = c
log.Infof("skipping commit: %s\n", c.Hash.String())
return nil
}
}
commitWg.Add(1)
semaphore <- true
go func(c *object.Commit, prevCommit *object.Commit) {
var (
filePath string
skipFile bool
)
defer func() {
commitWg.Done()
<-semaphore
if r := recover(); r != nil {
log.Warnf("recoverying from panic on commit %s, likely large diff causing panic", c.Hash.String())
}
}()
if prevCommit == nil {
t, _ := c.Tree()
files := t.Files()
err := files.ForEach(func(file *object.File) error {
content, err := file.Contents()
if err != nil {
return err
err = c.Parents().ForEach(func(parent *object.Commit) error {
commitWg.Add(1)
semaphore <- true
go func(c *object.Commit, parent *object.Commit) {
var (
filePath string
skipFile bool
)
defer func() {
commitWg.Done()
<-semaphore
if r := recover(); r != nil {
log.Warnf("recoverying from panic on commit %s, likely large diff causing panic", c.Hash.String())
}
diff := gitDiff{
branchName: string(ref.Name()),
repoName: repoName,
filePath: file.Name,
content: content,
sha: c.Hash.String(),
author: c.Author.String(),
message: c.Message,
}
chunkLeaks := inspect(diff)
for _, leak := range chunkLeaks {
mutex.Lock()
leaks = append(leaks, leak)
mutex.Unlock()
}
return nil
})
if err != nil {
log.Warnf("problem generating diff for commit: %s\n", c.Hash.String())
return
}
} else {
patch, err := c.Patch(prevCommit)
}()
patch, err := c.Patch(parent)
if err != nil {
log.Warnf("problem generating patch for commit: %s\n", c.Hash.String())
return
@@ -592,9 +557,9 @@ func auditGitReference(repo *RepoDescriptor, ref *plumbing.Reference) []Leak {
repoName: repoName,
filePath: filePath,
content: chunk.Content(),
sha: prevCommit.Hash.String(),
author: prevCommit.Author.String(),
message: prevCommit.Message,
sha: c.Hash.String(),
author: c.Author.String(),
message: c.Message,
}
chunkLeaks := inspect(diff)
for _, leak := range chunkLeaks {
@@ -605,9 +570,9 @@ func auditGitReference(repo *RepoDescriptor, ref *plumbing.Reference) []Leak {
}
}
}
}
}(c, prevCommit)
prevCommit = c
}(c, parent)
return nil
})
return nil
})
commitWg.Wait()
@@ -773,8 +738,6 @@ func optsGuard() error {
return fmt.Errorf("github organization set and local owner path")
} else if opts.GithubUser != "" && opts.OwnerPath != "" {
return fmt.Errorf("github user set and local owner path")
} else if opts.IncludePrivate && os.Getenv("GITHUB_TOKEN") == "" && (opts.GithubOrg != "" || opts.GithubUser != "") {
return fmt.Errorf("user/organization private repos require env var GITHUB_TOKEN to be set")
}
// do the URL Parse and error checking here, so we can skip it later
@@ -921,14 +884,22 @@ func getSSHAuth() (*ssh.PublicKeys, error) {
if opts.SSHKey != "" {
sshKeyPath = opts.SSHKey
} else {
c, _ := user.Current()
// try grabbing default
c, err := user.Current()
if err != nil {
return nil, nil
}
sshKeyPath = fmt.Sprintf("%s/.ssh/id_rsa", c.HomeDir)
}
sshAuth, err := ssh.NewPublicKeysFromFile("git", sshKeyPath, "")
if err != nil {
return nil, fmt.Errorf("unable to generate ssh key: %v", err)
if strings.HasPrefix(opts.Repo, "git") {
// if you are attempting to clone a git repo via ssh and supply a bad ssh key,
// the clone will fail.
return nil, fmt.Errorf("unable to generate ssh key: %v", err)
}
}
return sshAuth, err
return sshAuth, nil
}
func (leak Leak) log() {