external repo file support

This commit is contained in:
zricethezav committed 2018-03-10 13:32:05 -06:00
1 parent 2c80ad5ea9
commit ccef3680d5
6 files changed
+96 -15

No files matched your search

+25 -1
View File
@@ -22,7 +22,6 @@ func doChecks(diff string, commit Commit, repo *Repo) []Leak {
file = line[idx[1]:]
}
}
for leakType, re := range regexes {
match = re.FindString(line)
if len(match) == 0 ||
@@ -44,6 +43,31 @@ func doChecks(diff string, commit Commit, repo *Repo) []Leak {
}
leaks = append(leaks, leak)
}
// Check for external regex matches
if externalRegex != nil {
for _, re := range externalRegex {
match = re.FindString(line)
if len(match) == 0 ||
(opts.Strict && containsStopWords(line)) ||
(opts.Entropy && !checkShannonEntropy(line, opts)) {
continue
}
leak = Leak{
Line: line,
Commit: commit.Hash,
Offender: match,
Reason: "match: " + re.String(),
Msg: commit.Msg,
Time: commit.Time,
Author: commit.Author,
File: file,
RepoURL: repo.url,
}
leaks = append(leaks, leak)
}
}
}
return leaks