mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-30 13:14:22 +01:00
spliting up email and author
This commit is contained in:
1 parent
f9be4e543a
commit
56c89866a2
3 files changed
+18
-8
No files matched your search
@@ -520,6 +520,14 @@ func TestAuditRepo(t *testing.T) {
|
|||||||
numLeaks: 2,
|
numLeaks: 2,
|
||||||
testOpts: &Options{},
|
testOpts: &Options{},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
repo: leaksRepo,
|
||||||
|
description: "no leaks present on branch",
|
||||||
|
numLeaks: 0,
|
||||||
|
testOpts: &Options{
|
||||||
|
Branch: "dev",
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
repo: leaksRepo,
|
repo: leaksRepo,
|
||||||
description: "two leaks present limit goroutines",
|
description: "two leaks present limit goroutines",
|
||||||
@@ -561,10 +569,7 @@ func TestAuditRepo(t *testing.T) {
|
|||||||
description: "two leaks present whitelist bad commit",
|
description: "two leaks present whitelist bad commit",
|
||||||
configPath: path.Join(configsDir, "commit"),
|
configPath: path.Join(configsDir, "commit"),
|
||||||
testOpts: &Options{},
|
testOpts: &Options{},
|
||||||
// whiteListCommits: map[string]bool{
|
numLeaks: 1,
|
||||||
// "eaeffdc65b4c73ccb67e75d96bd8743be2c85973": true,
|
|
||||||
// },
|
|
||||||
numLeaks: 1,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
repo: leaksRepo,
|
repo: leaksRepo,
|
||||||
|
|||||||
+5
-2
@@ -26,6 +26,7 @@ type Leak struct {
|
|||||||
Type string `json:"reason"`
|
Type string `json:"reason"`
|
||||||
Message string `json:"commitMsg"`
|
Message string `json:"commitMsg"`
|
||||||
Author string `json:"author"`
|
Author string `json:"author"`
|
||||||
|
Email string `json:"email"`
|
||||||
File string `json:"file"`
|
File string `json:"file"`
|
||||||
Repo string `json:"repo"`
|
Repo string `json:"repo"`
|
||||||
Date time.Time `json:"date"`
|
Date time.Time `json:"date"`
|
||||||
@@ -250,7 +251,8 @@ func (repoInfo *RepoInfo) audit() ([]Leak, error) {
|
|||||||
filePath: filePath,
|
filePath: filePath,
|
||||||
content: chunk.Content(),
|
content: chunk.Content(),
|
||||||
sha: c.Hash.String(),
|
sha: c.Hash.String(),
|
||||||
author: c.Author.String(),
|
author: c.Author.Name,
|
||||||
|
email: c.Author.Email,
|
||||||
message: strings.Replace(c.Message, "\n", " ", -1),
|
message: strings.Replace(c.Message, "\n", " ", -1),
|
||||||
date: c.Author.When,
|
date: c.Author.When,
|
||||||
}
|
}
|
||||||
@@ -301,7 +303,8 @@ func (repoInfo *RepoInfo) auditSingleCommit(c *object.Commit) []Leak {
|
|||||||
filePath: f.Name,
|
filePath: f.Name,
|
||||||
content: content,
|
content: content,
|
||||||
sha: c.Hash.String(),
|
sha: c.Hash.String(),
|
||||||
author: c.Author.String(),
|
author: c.Author.Name,
|
||||||
|
email: c.Author.Email,
|
||||||
message: strings.Replace(c.Message, "\n", " ", -1),
|
message: strings.Replace(c.Message, "\n", " ", -1),
|
||||||
date: c.Author.When,
|
date: c.Author.When,
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -22,6 +22,7 @@ type commitInfo struct {
|
|||||||
sha string
|
sha string
|
||||||
message string
|
message string
|
||||||
author string
|
author string
|
||||||
|
email string
|
||||||
date time.Time
|
date time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,9 +41,9 @@ func writeReport(leaks []Leak) error {
|
|||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
w := csv.NewWriter(f)
|
w := csv.NewWriter(f)
|
||||||
w.Write([]string{"repo", "line", "commit", "offender", "reason", "commitMsg", "author", "file", "date"})
|
w.Write([]string{"repo", "line", "commit", "offender", "reason", "commitMsg", "author", "email", "file", "date"})
|
||||||
for _, leak := range leaks {
|
for _, leak := range leaks {
|
||||||
w.Write([]string{leak.Repo, leak.Line, leak.Commit, leak.Offender, leak.Type, leak.Message, leak.Author, leak.File, leak.Date.Format(time.RFC3339)})
|
w.Write([]string{leak.Repo, leak.Line, leak.Commit, leak.Offender, leak.Type, leak.Message, leak.Author, leak.Email, leak.File, leak.Date.Format(time.RFC3339)})
|
||||||
}
|
}
|
||||||
w.Flush()
|
w.Flush()
|
||||||
} else {
|
} else {
|
||||||
@@ -145,6 +146,7 @@ func addLeak(leaks []Leak, line string, offender string, leakType string, commit
|
|||||||
Offender: offender,
|
Offender: offender,
|
||||||
Type: leakType,
|
Type: leakType,
|
||||||
Author: commit.author,
|
Author: commit.author,
|
||||||
|
Email: commit.email,
|
||||||
File: commit.filePath,
|
File: commit.filePath,
|
||||||
Repo: commit.repoName,
|
Repo: commit.repoName,
|
||||||
Message: commit.message,
|
Message: commit.message,
|
||||||
|
|||||||
Reference in new issue
Block a user