file, author, repourl, time, commitmsg to leakElem

This commit is contained in:
zricethezav committed 2018-02-25 11:49:15 -06:00
1 parent 1b06f1a0dc
commit c104ff9157
3 files changed
+119 -46

No files matched your search

+25 -6
View File
@@ -3,15 +3,30 @@ package main
import (
"math"
"strings"
_"fmt"
"regexp"
)
// TODO LOCAL REPO!!!!
// checks Regex and if enabled, entropy and stopwords
func doChecks(diff string, commit string, opts *Options) []LeakElem {
var match string
var leaks []LeakElem
var leak LeakElem
func doChecks(diff string, commit Commit, opts *Options, repo RepoDesc) []LeakElem {
var (
match string
leaks []LeakElem
leak LeakElem
)
lines := strings.Split(diff, "\n")
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]:]
}
for leakType, re := range regexes {
match = re.FindString(line)
if len(match) == 0 ||
@@ -22,11 +37,15 @@ func doChecks(diff string, commit string, opts *Options) []LeakElem {
leak = LeakElem{
Line: line,
Commit: commit,
Commit: commit.Hash,
Offender: match,
Reason: leakType,
Msg: commit.Msg,
Time: commit.Time,
Author: commit.Author,
File: file,
RepoURL: repo.url,
}
leaks = append(leaks, leak)
}
}