mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-29 04:34:46 +01:00
working on filetype filtering
This commit is contained in:
1 parent
87d6c588a6
commit
cb74386ef0
4 files changed
+67
-3
No files matched your search
+14
-2
@@ -41,9 +41,9 @@ func writeReport(leaks []Leak) error {
|
||||
}
|
||||
defer f.Close()
|
||||
w := csv.NewWriter(f)
|
||||
w.Write([]string{"repo", "line", "commit", "offender", "rule", "info", "tags", "commitMsg", "author", "email", "file", "date"})
|
||||
w.Write([]string{"repo", "line", "commit", "offender", "rule", "info", "tags", "severity", "commitMsg", "author", "email", "file", "date"})
|
||||
for _, leak := range leaks {
|
||||
w.Write([]string{leak.Repo, leak.Line, leak.Commit, leak.Offender, leak.Rule, leak.Info, leak.Tags, leak.Message, leak.Author, leak.Email, leak.File, leak.Date.Format(time.RFC3339)})
|
||||
w.Write([]string{leak.Repo, leak.Line, leak.Commit, leak.Offender, leak.Rule, leak.Info, leak.Tags, leak.Severity, leak.Message, leak.Author, leak.Email, leak.File, leak.Date.Format(time.RFC3339)})
|
||||
}
|
||||
w.Flush()
|
||||
} else {
|
||||
@@ -86,10 +86,22 @@ func writeReport(leaks []Leak) error {
|
||||
func (rule *Rule) check(line string, commit *commitInfo) (*Leak, error) {
|
||||
var (
|
||||
match string
|
||||
fileMatch string
|
||||
entropy float64
|
||||
entropyWord string
|
||||
)
|
||||
|
||||
for _, f := range rule.fileTypes {
|
||||
fileMatch = f.FindString(commit.filePath)
|
||||
if fileMatch != "" {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if fileMatch == "" && len(rule.fileTypes) != 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
if rule.entropies != nil {
|
||||
if rule.entropyROI == "line" {
|
||||
_entropy := getShannonEntropy(line)
|
||||
|
||||
Reference in new issue
Block a user