mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-29 20:54:22 +01:00
updated readme, better logging
This commit is contained in:
1 parent
c104ff9157
commit
1cecd5e090
7 files changed
+133
-90
No files matched your search
@@ -1,13 +1,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "fmt"
|
||||
"math"
|
||||
"strings"
|
||||
_"fmt"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
|
||||
// TODO LOCAL REPO!!!!
|
||||
|
||||
// checks Regex and if enabled, entropy and stopwords
|
||||
@@ -19,12 +17,13 @@ func doChecks(diff string, commit Commit, opts *Options, repo RepoDesc) []LeakEl
|
||||
)
|
||||
|
||||
lines := strings.Split(diff, "\n")
|
||||
file := ""
|
||||
file := "unable to determine file"
|
||||
for _, line := range lines {
|
||||
if strings.Contains(line, "diff --git a"){
|
||||
re := regexp.MustCompile("diff --git a.+b/")
|
||||
idx := re.FindStringIndex(line)
|
||||
file = line[idx[1]:]
|
||||
if strings.Contains(line, "diff --git a") {
|
||||
idx := fileDiffRegex.FindStringIndex(line)
|
||||
if len(idx) == 2 {
|
||||
file = line[idx[1]:]
|
||||
}
|
||||
}
|
||||
|
||||
for leakType, re := range regexes {
|
||||
@@ -40,11 +39,11 @@ func doChecks(diff string, commit Commit, opts *Options, repo RepoDesc) []LeakEl
|
||||
Commit: commit.Hash,
|
||||
Offender: match,
|
||||
Reason: leakType,
|
||||
Msg: commit.Msg,
|
||||
Time: commit.Time,
|
||||
Author: commit.Author,
|
||||
File: file,
|
||||
RepoURL: repo.url,
|
||||
Msg: commit.Msg,
|
||||
Time: commit.Time,
|
||||
Author: commit.Author,
|
||||
File: file,
|
||||
RepoURL: repo.url,
|
||||
}
|
||||
leaks = append(leaks, leak)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user