mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-30 05:04:22 +01:00
typo
This commit is contained in:
1 parent
562b7e27c0
commit
f27c0a62c9
2 files changed
+24
-25
No files matched your search
@@ -39,7 +39,6 @@ func start(opts *Options, repoUrl string) {
|
|||||||
|
|
||||||
report := getLeaks(repoName)
|
report := getLeaks(repoName)
|
||||||
cleanup(repoName)
|
cleanup(repoName)
|
||||||
|
|
||||||
reportJson, _ := json.MarshalIndent(report, "", "\t")
|
reportJson, _ := json.MarshalIndent(report, "", "\t")
|
||||||
err = ioutil.WriteFile(fmt.Sprintf("%s_leaks.json", repoName), reportJson, 0644)
|
err = ioutil.WriteFile(fmt.Sprintf("%s_leaks.json", repoName), reportJson, 0644)
|
||||||
}
|
}
|
||||||
@@ -56,29 +55,35 @@ func cleanup(repoName string) {
|
|||||||
|
|
||||||
func getLeaks(repoName string) []LeakElem {
|
func getLeaks(repoName string) []LeakElem {
|
||||||
var (
|
var (
|
||||||
out []byte
|
out []byte
|
||||||
err error
|
err error
|
||||||
wg sync.WaitGroup
|
commitWG sync.WaitGroup
|
||||||
concurrent = 100
|
gitLeakReceiverWG sync.WaitGroup
|
||||||
semaphoreChan = make(chan struct{}, concurrent)
|
concurrent = 100
|
||||||
gitLeaks = make(chan LeakElem)
|
semaphoreChan = make(chan struct{}, concurrent)
|
||||||
|
gitLeaks = make(chan LeakElem)
|
||||||
|
report []LeakElem
|
||||||
)
|
)
|
||||||
|
|
||||||
|
go func(commitWG *sync.WaitGroup, gitLeakReceiverWG *sync.WaitGroup) {
|
||||||
|
for gitLeak := range gitLeaks {
|
||||||
|
fmt.Println(gitLeak)
|
||||||
|
report = append(report, gitLeak)
|
||||||
|
gitLeakReceiverWG.Done()
|
||||||
|
}
|
||||||
|
}(&commitWG, &gitLeakReceiverWG)
|
||||||
|
|
||||||
out, err = exec.Command("git", "rev-list", "--all", "--remotes", "--topo-order").Output()
|
out, err = exec.Command("git", "rev-list", "--all", "--remotes", "--topo-order").Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("error retrieving commits%v\n", err)
|
log.Fatalf("error retrieving commits%v\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
commits := bytes.Split(out, []byte("\n"))
|
commits := bytes.Split(out, []byte("\n"))
|
||||||
for j, currCommitB := range commits {
|
commitWG.Add(len(commits))
|
||||||
|
for _, currCommitB := range commits {
|
||||||
currCommit := string(currCommitB)
|
currCommit := string(currCommitB)
|
||||||
if j == len(commits)-2 {
|
go func(currCommit string, repoName string, commitWG *sync.WaitGroup, gitLeakReceiverWG *sync.WaitGroup) {
|
||||||
break
|
defer commitWG.Done()
|
||||||
}
|
|
||||||
|
|
||||||
wg.Add(1)
|
|
||||||
go func(currCommit string, repoName string) {
|
|
||||||
defer wg.Done()
|
|
||||||
var leakPrs bool
|
var leakPrs bool
|
||||||
|
|
||||||
if err := os.Chdir(fmt.Sprintf("%s/%s", appRoot, repoName)); err != nil {
|
if err := os.Chdir(fmt.Sprintf("%s/%s", appRoot, repoName)); err != nil {
|
||||||
@@ -101,19 +106,14 @@ func getLeaks(repoName string) []LeakElem {
|
|||||||
for _, line := range lines {
|
for _, line := range lines {
|
||||||
leakPrs = checkEntropy(line)
|
leakPrs = checkEntropy(line)
|
||||||
if leakPrs {
|
if leakPrs {
|
||||||
|
gitLeakReceiverWG.Add(1)
|
||||||
gitLeaks <- LeakElem{line, currCommit}
|
gitLeaks <- LeakElem{line, currCommit}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}(currCommit, repoName, &commitWG, &gitLeakReceiverWG)
|
||||||
}(currCommit, repoName)
|
|
||||||
}
|
}
|
||||||
go func() {
|
|
||||||
for gitLeak := range gitLeaks {
|
|
||||||
fmt.Println(gitLeak)
|
|
||||||
report = append(report, gitLeak)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
wg.Wait()
|
|
||||||
|
|
||||||
|
commitWG.Wait()
|
||||||
|
gitLeakReceiverWG.Wait()
|
||||||
return report
|
return report
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user