mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-26 19:30:55 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aae23acff3 | ||
|
|
705595aaf6 | ||
|
|
43ec22429f |
No files matched your search
@@ -290,7 +290,17 @@ will be given precedence.
|
||||
|
||||
|
||||
## Sponsorships
|
||||
[](https://www.tines.com/?utm_source=oss&utm_medium=sponsorship&utm_campaign=gitleaks)
|
||||
<p align="left">
|
||||
<a href="https://www.tines.com/?utm_source=oss&utm_medium=sponsorship&utm_campaign=gitleaks">
|
||||
<img alt="Tines Sponsorship" src="https://user-images.githubusercontent.com/15034943/146411864-4878f936-b4f7-49a0-b625-f9f40c704bfa.png" width=200>
|
||||
</a>
|
||||
</p>
|
||||
<a href="https://www.typeform.com/">
|
||||
<img src="https://user-images.githubusercontent.com/15034943/146945294-a6473d55-86b8-4f53-941e-7f185ad6b3d7.png" width=200/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
## Exit Codes
|
||||
|
||||
@@ -20,6 +20,7 @@ func FromFiles(source string, cfg config.Config, outputOptions Options) ([]repor
|
||||
findings []report.Finding
|
||||
mu sync.Mutex
|
||||
)
|
||||
concurrentGoroutines := make(chan struct{}, 4)
|
||||
g, _ := errgroup.WithContext(context.Background())
|
||||
paths := make(chan string)
|
||||
g.Go(func() error {
|
||||
@@ -41,12 +42,15 @@ func FromFiles(source string, cfg config.Config, outputOptions Options) ([]repor
|
||||
for pa := range paths {
|
||||
p := pa
|
||||
g.Go(func() error {
|
||||
concurrentGoroutines <- struct{}{}
|
||||
b, err := os.ReadFile(p)
|
||||
if err != nil {
|
||||
<-concurrentGoroutines
|
||||
return err
|
||||
}
|
||||
|
||||
if !godocutil.IsText(b) {
|
||||
<-concurrentGoroutines
|
||||
return nil
|
||||
}
|
||||
fis := DetectFindings(cfg, b, p, "")
|
||||
@@ -65,6 +69,7 @@ func FromFiles(source string, cfg config.Config, outputOptions Options) ([]repor
|
||||
findings = append(findings, fi)
|
||||
mu.Unlock()
|
||||
}
|
||||
<-concurrentGoroutines
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
func writeJson(findings []Finding, w io.WriteCloser) error {
|
||||
if len(findings) == 0 {
|
||||
return nil
|
||||
findings = []Finding{}
|
||||
}
|
||||
encoder := json.NewEncoder(w)
|
||||
encoder.SetIndent("", " ")
|
||||
|
||||
+1
-2
@@ -39,9 +39,8 @@ func TestWriteJSON(t *testing.T) {
|
||||
}},
|
||||
{
|
||||
|
||||
wantEmpty: true,
|
||||
testReportName: "empty",
|
||||
expected: filepath.Join(expectPath, "report", "this_should_not_exist.json"),
|
||||
expected: filepath.Join(expectPath, "report", "empty.json"),
|
||||
findings: []Finding{}},
|
||||
}
|
||||
|
||||
|
||||
@@ -14,9 +14,6 @@ const (
|
||||
)
|
||||
|
||||
func Write(findings []Finding, cfg config.Config, ext string, reportPath string) error {
|
||||
if len(findings) == 0 {
|
||||
return nil
|
||||
}
|
||||
file, err := os.Create(reportPath)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
[]
|
||||
Reference in new issue
Block a user