mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-30 13:14:22 +01:00
Add commit date to leaks
This commit is contained in:
1 parent
03c53d2978
commit
23b5ce3264
2 files changed
+17
-11
No files matched your search
@@ -8,6 +8,7 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/franela/goblin"
|
"github.com/franela/goblin"
|
||||||
git "gopkg.in/src-d/go-git.v4"
|
git "gopkg.in/src-d/go-git.v4"
|
||||||
@@ -368,6 +369,7 @@ func TestWriteReport(t *testing.T) {
|
|||||||
Author: "some",
|
Author: "some",
|
||||||
File: "sleep",
|
File: "sleep",
|
||||||
Branch: "thxu",
|
Branch: "thxu",
|
||||||
|
Date: time.Now(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,15 +37,16 @@ import (
|
|||||||
|
|
||||||
// Leak represents a leaked secret or regex match.
|
// Leak represents a leaked secret or regex match.
|
||||||
type Leak struct {
|
type Leak struct {
|
||||||
Line string `json:"line"`
|
Line string `json:"line"`
|
||||||
Commit string `json:"commit"`
|
Commit string `json:"commit"`
|
||||||
Offender string `json:"offender"`
|
Offender string `json:"offender"`
|
||||||
Type string `json:"reason"`
|
Type string `json:"reason"`
|
||||||
Message string `json:"commitMsg"`
|
Message string `json:"commitMsg"`
|
||||||
Author string `json:"author"`
|
Author string `json:"author"`
|
||||||
File string `json:"file"`
|
File string `json:"file"`
|
||||||
Branch string `json:"branch"`
|
Branch string `json:"branch"`
|
||||||
Repo string `json:"repo"`
|
Repo string `json:"repo"`
|
||||||
|
Date time.Time `json:"date"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// RepoDescriptor contains a src-d git repository and other data about the repo
|
// RepoDescriptor contains a src-d git repository and other data about the repo
|
||||||
@@ -128,6 +129,7 @@ type gitDiff struct {
|
|||||||
sha string
|
sha string
|
||||||
message string
|
message string
|
||||||
author string
|
author string
|
||||||
|
date time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
type entropyRange struct {
|
type entropyRange struct {
|
||||||
@@ -348,9 +350,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", "branch"})
|
w.Write([]string{"repo", "line", "commit", "offender", "reason", "commitMsg", "author", "file", "branch", "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.Branch})
|
w.Write([]string{leak.Repo, leak.Line, leak.Commit, leak.Offender, leak.Type, leak.Message, leak.Author, leak.File, leak.Branch, leak.Date.Format(time.RFC3339)})
|
||||||
}
|
}
|
||||||
w.Flush()
|
w.Flush()
|
||||||
} else {
|
} else {
|
||||||
@@ -561,6 +563,7 @@ func auditGitReference(repo *RepoDescriptor, ref *plumbing.Reference) []Leak {
|
|||||||
sha: c.Hash.String(),
|
sha: c.Hash.String(),
|
||||||
author: c.Author.String(),
|
author: c.Author.String(),
|
||||||
message: c.Message,
|
message: c.Message,
|
||||||
|
date: c.Author.When,
|
||||||
}
|
}
|
||||||
chunkLeaks := inspect(diff)
|
chunkLeaks := inspect(diff)
|
||||||
for _, leak := range chunkLeaks {
|
for _, leak := range chunkLeaks {
|
||||||
@@ -651,6 +654,7 @@ func addLeak(leaks []Leak, line string, offender string, leakType string, diff g
|
|||||||
Branch: diff.branchName,
|
Branch: diff.branchName,
|
||||||
Repo: diff.repoName,
|
Repo: diff.repoName,
|
||||||
Message: diff.message,
|
Message: diff.message,
|
||||||
|
Date: diff.date,
|
||||||
}
|
}
|
||||||
if opts.Redact {
|
if opts.Redact {
|
||||||
leak.Offender = "REDACTED"
|
leak.Offender = "REDACTED"
|
||||||
|
|||||||
Reference in new issue
Block a user