mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-30 21:24:21 +01:00
--since sh-sh-sha
This commit is contained in:
1 parent
2186f22999
commit
7a0ce07f99
2 files changed
+28
-19
No files matched your search
@@ -27,13 +27,13 @@ func start(opts *Options) {
|
|||||||
c := make(chan os.Signal, 2)
|
c := make(chan os.Signal, 2)
|
||||||
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
||||||
|
|
||||||
fmt.Printf("Cloning \x1b[37;1m%s\x1b[0m...\n", opts.RepoURL)
|
// fmt.Printf("Cloning \x1b[37;1m%s\x1b[0m...\n", opts.RepoURL)
|
||||||
err := exec.Command("git", "clone", opts.RepoURL).Run()
|
err := exec.Command("git", "clone", opts.RepoURL).Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("failed to clone repo %v", err)
|
log.Printf("failed to clone repo %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Printf("Evaluating \x1b[37;1m%s\x1b[0m...\n", opts.RepoURL)
|
// fmt.Printf("Evaluating \x1b[37;1m%s\x1b[0m...\n", opts.RepoURL)
|
||||||
repoName := getLocalRepoName(opts.RepoURL)
|
repoName := getLocalRepoName(opts.RepoURL)
|
||||||
if err = os.Chdir(repoName); err != nil {
|
if err = os.Chdir(repoName); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
@@ -46,7 +46,7 @@ func start(opts *Options) {
|
|||||||
|
|
||||||
report := getLeaks(repoName, opts)
|
report := getLeaks(repoName, opts)
|
||||||
if len(report) == 0 {
|
if len(report) == 0 {
|
||||||
fmt.Printf("No Leaks detected for \x1b[35;2m%s\x1b[0m...\n\n", opts.RepoURL)
|
// fmt.Printf("No Leaks detected for \x1b[35;2m%s\x1b[0m...\n\n", opts.RepoURL)
|
||||||
}
|
}
|
||||||
cleanup(repoName)
|
cleanup(repoName)
|
||||||
reportJSON, _ := json.MarshalIndent(report, "", "\t")
|
reportJSON, _ := json.MarshalIndent(report, "", "\t")
|
||||||
@@ -108,19 +108,21 @@ func getLeaks(repoName string, opts *Options) []LeakElem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
commits := bytes.Split(out, []byte("\n"))
|
commits := bytes.Split(out, []byte("\n"))
|
||||||
commitWG.Add(len(commits))
|
|
||||||
for _, currCommitB := range commits {
|
for _, currCommitB := range commits {
|
||||||
currCommit := string(currCommitB)
|
currCommit := string(currCommitB)
|
||||||
|
if currCommit == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if currCommit == opts.SinceCommit {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
commitWG.Add(1)
|
||||||
go func(currCommit string, repoName string, commitWG *sync.WaitGroup,
|
go func(currCommit string, repoName string, commitWG *sync.WaitGroup,
|
||||||
gitLeakReceiverWG *sync.WaitGroup) {
|
gitLeakReceiverWG *sync.WaitGroup) {
|
||||||
|
|
||||||
defer commitWG.Done()
|
defer commitWG.Done()
|
||||||
|
|
||||||
if currCommit == "" {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := os.Chdir(fmt.Sprintf("%s/%s", appRoot, repoName)); err != nil {
|
if err := os.Chdir(fmt.Sprintf("%s/%s", appRoot, repoName)); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-11
@@ -9,15 +9,16 @@ import (
|
|||||||
const usage = `usage: gitleaks [options] <url>
|
const usage = `usage: gitleaks [options] <url>
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-c Concurrency factor (default is 10)
|
-c Concurrency factor (default is 10)
|
||||||
-u --user Git user url
|
-u --user Git user url
|
||||||
-r --repo Git repo url
|
-r --repo Git repo url
|
||||||
-o --org Git organization url
|
-o --org Git organization url
|
||||||
-s --strict Strict mode uses stopwords in config.yml
|
-s --since Commit to stop at
|
||||||
-b --b64Entropy Base64 entropy cutoff (default is 70)
|
-b --b64Entropy Base64 entropy cutoff (default is 70)
|
||||||
-x --hexEntropy Hex entropy cutoff (default is 40)
|
-x --hexEntropy Hex entropy cutoff (default is 40)
|
||||||
-e --entropy Enable entropy
|
-e --entropy Enable entropy
|
||||||
-h --help Display this message
|
-h --help Display this message
|
||||||
|
--strict Enables stopwords
|
||||||
`
|
`
|
||||||
|
|
||||||
// Options for gitleaks
|
// Options for gitleaks
|
||||||
@@ -30,6 +31,7 @@ type Options struct {
|
|||||||
RepoURL string
|
RepoURL string
|
||||||
Strict bool
|
Strict bool
|
||||||
Entropy bool
|
Entropy bool
|
||||||
|
SinceCommit string
|
||||||
}
|
}
|
||||||
|
|
||||||
// help prints the usage string and exits
|
// help prints the usage string and exits
|
||||||
@@ -73,10 +75,16 @@ func parseOptions(args []string) *Options {
|
|||||||
Entropy: false,
|
Entropy: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(args) == 0 {
|
||||||
|
help()
|
||||||
|
}
|
||||||
|
|
||||||
for i := 0; i < len(args); i++ {
|
for i := 0; i < len(args); i++ {
|
||||||
arg := args[i]
|
arg := args[i]
|
||||||
switch arg {
|
switch arg {
|
||||||
case "-s", "--strict":
|
case "-s", "--since":
|
||||||
|
opts.SinceCommit = optionsNextString(args, &i)
|
||||||
|
case "--strict":
|
||||||
opts.Strict = true
|
opts.Strict = true
|
||||||
case "-b", "--b64Entropy":
|
case "-b", "--b64Entropy":
|
||||||
opts.B64EntropyCutoff = optionsNextInt(args, &i)
|
opts.B64EntropyCutoff = optionsNextInt(args, &i)
|
||||||
@@ -102,7 +110,6 @@ func parseOptions(args []string) *Options {
|
|||||||
} else {
|
} else {
|
||||||
fmt.Printf("Uknown option %s\n\n", arg)
|
fmt.Printf("Uknown option %s\n\n", arg)
|
||||||
help()
|
help()
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user