mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-29 12:44:22 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
35531233d9 | ||
|
|
54949bd62a | ||
|
|
e95a8a7158 | ||
|
|
de0a70a835 | ||
|
|
9f8feca926 | ||
|
|
c50187559b | ||
|
|
7d5ed837a4 | ||
|
|
60267523e9 | ||
|
|
8153da6e9c |
No files matched your search
@@ -1,6 +1,21 @@
|
|||||||
CHANGELOG
|
CHANGELOG
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
1.19.3
|
||||||
|
----
|
||||||
|
- memoizing root commit
|
||||||
|
- only count commits (not commit + parent) for total commit number
|
||||||
|
|
||||||
|
1.19.2
|
||||||
|
----
|
||||||
|
- fixed a bug where gitleaks was skipping the initial commit
|
||||||
|
- commit cache now checks curr commit + parent commit hash
|
||||||
|
- removed newlines from commit message
|
||||||
|
|
||||||
|
1.19.1
|
||||||
|
----
|
||||||
|
- mistakenly removed default whitelist files
|
||||||
|
|
||||||
1.19.0
|
1.19.0
|
||||||
----
|
----
|
||||||
- removed `--all-refs`. By default gitleaks now scans all branches, remote and local.
|
- removed `--all-refs`. By default gitleaks now scans all branches, remote and local.
|
||||||
|
|||||||
+9
-9
@@ -454,6 +454,14 @@ func TestAuditRepo(t *testing.T) {
|
|||||||
whiteListRegexes []*regexp.Regexp
|
whiteListRegexes []*regexp.Regexp
|
||||||
configPath string
|
configPath string
|
||||||
}{
|
}{
|
||||||
|
{
|
||||||
|
repo: leaksRepo,
|
||||||
|
description: "commit depth = 1, one leak",
|
||||||
|
numLeaks: 1,
|
||||||
|
testOpts: Options{
|
||||||
|
Depth: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
repo: leaksRepo,
|
repo: leaksRepo,
|
||||||
description: "two leaks present",
|
description: "two leaks present",
|
||||||
@@ -557,14 +565,6 @@ func TestAuditRepo(t *testing.T) {
|
|||||||
Commit: "f6839959b7bbdcd23008f1fb16f797f35bcd3a0c",
|
Commit: "f6839959b7bbdcd23008f1fb16f797f35bcd3a0c",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
repo: leaksRepo,
|
|
||||||
description: "commit depth = 1, one leak",
|
|
||||||
numLeaks: 1,
|
|
||||||
testOpts: Options{
|
|
||||||
Depth: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
repo: leaksRepo,
|
repo: leaksRepo,
|
||||||
description: "commit depth = 2, two leaks",
|
description: "commit depth = 2, two leaks",
|
||||||
@@ -576,7 +576,7 @@ func TestAuditRepo(t *testing.T) {
|
|||||||
{
|
{
|
||||||
repo: leaksRepo,
|
repo: leaksRepo,
|
||||||
description: "toml entropy range",
|
description: "toml entropy range",
|
||||||
numLeaks: 284,
|
numLeaks: 298,
|
||||||
configPath: path.Join(configsDir, "entropy"),
|
configPath: path.Join(configsDir, "entropy"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ type entropyRange struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const defaultGithubURL = "https://api.github.com/"
|
const defaultGithubURL = "https://api.github.com/"
|
||||||
const version = "1.19.0"
|
const version = "1.19.3"
|
||||||
const errExit = 2
|
const errExit = 2
|
||||||
const leakExit = 1
|
const leakExit = 1
|
||||||
const defaultConfig = `
|
const defaultConfig = `
|
||||||
@@ -173,6 +173,9 @@ description = "Slack"
|
|||||||
regex = '''xox[baprs]-([0-9a-zA-Z]{10,48})?'''
|
regex = '''xox[baprs]-([0-9a-zA-Z]{10,48})?'''
|
||||||
|
|
||||||
[whitelist]
|
[whitelist]
|
||||||
|
files = [
|
||||||
|
"(.*?)(jpg|gif|doc|pdf|bin)$"
|
||||||
|
]
|
||||||
#commits = [
|
#commits = [
|
||||||
# "BADHA5H1",
|
# "BADHA5H1",
|
||||||
# "BADHA5H2",
|
# "BADHA5H2",
|
||||||
@@ -453,24 +456,77 @@ func auditGitReference(repo *RepoDescriptor, ref *plumbing.Reference) []Leak {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
err = cIter.ForEach(func(c *object.Commit) error {
|
err = cIter.ForEach(func(c *object.Commit) error {
|
||||||
if commitMap[c.Hash.String()] {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
cMutex.Lock()
|
|
||||||
commitMap[c.Hash.String()] = true
|
|
||||||
cMutex.Unlock()
|
|
||||||
if c == nil || c.Hash.String() == opts.Commit || (opts.Depth != 0 && commitCount == opts.Depth) {
|
if c == nil || c.Hash.String() == opts.Commit || (opts.Depth != 0 && commitCount == opts.Depth) {
|
||||||
cIter.Close()
|
cIter.Close()
|
||||||
return errors.New("ErrStop")
|
return errors.New("ErrStop")
|
||||||
}
|
}
|
||||||
commitCount = commitCount + 1
|
commitCount = commitCount + 1
|
||||||
totalCommits = totalCommits + 1
|
|
||||||
if whiteListCommits[c.Hash.String()] {
|
if whiteListCommits[c.Hash.String()] {
|
||||||
log.Infof("skipping commit: %s\n", c.Hash.String())
|
log.Infof("skipping commit: %s\n", c.Hash.String())
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// commits w/o parent (root of git the git ref)
|
||||||
|
if len(c.ParentHashes) == 0 {
|
||||||
|
if commitMap[c.Hash.String()] {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
cMutex.Lock()
|
||||||
|
commitMap[c.Hash.String()] = true
|
||||||
|
cMutex.Unlock()
|
||||||
|
|
||||||
|
totalCommits = totalCommits + 1
|
||||||
|
|
||||||
|
fIter, err := c.Files()
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
err = fIter.ForEach(func(f *object.File) error {
|
||||||
|
bin, err := f.IsBinary()
|
||||||
|
if bin || err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
for _, re := range whiteListFiles {
|
||||||
|
if re.FindString(f.Name) != "" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
content, err := f.Contents()
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
diff := gitDiff{
|
||||||
|
repoName: repoName,
|
||||||
|
filePath: f.Name,
|
||||||
|
content: content,
|
||||||
|
sha: c.Hash.String(),
|
||||||
|
author: c.Author.String(),
|
||||||
|
message: strings.Replace(c.Message, "\n", " ", -1),
|
||||||
|
date: c.Author.When,
|
||||||
|
}
|
||||||
|
fileLeaks := inspect(diff)
|
||||||
|
mutex.Lock()
|
||||||
|
leaks = append(leaks, fileLeaks...)
|
||||||
|
mutex.Unlock()
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
skipCount := false
|
||||||
err = c.Parents().ForEach(func(parent *object.Commit) error {
|
err = c.Parents().ForEach(func(parent *object.Commit) error {
|
||||||
|
// check if we've seen this diff before
|
||||||
|
if commitMap[c.Hash.String()+parent.Hash.String()] {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
cMutex.Lock()
|
||||||
|
commitMap[c.Hash.String()+parent.Hash.String()] = true
|
||||||
|
cMutex.Unlock()
|
||||||
|
|
||||||
|
if !skipCount {
|
||||||
|
totalCommits = totalCommits + 1
|
||||||
|
skipCount = true
|
||||||
|
}
|
||||||
|
|
||||||
commitWg.Add(1)
|
commitWg.Add(1)
|
||||||
semaphore <- true
|
semaphore <- true
|
||||||
go func(c *object.Commit, parent *object.Commit) {
|
go func(c *object.Commit, parent *object.Commit) {
|
||||||
@@ -520,7 +576,7 @@ func auditGitReference(repo *RepoDescriptor, ref *plumbing.Reference) []Leak {
|
|||||||
content: chunk.Content(),
|
content: chunk.Content(),
|
||||||
sha: c.Hash.String(),
|
sha: c.Hash.String(),
|
||||||
author: c.Author.String(),
|
author: c.Author.String(),
|
||||||
message: c.Message,
|
message: strings.Replace(c.Message, "\n", " ", -1),
|
||||||
date: c.Author.When,
|
date: c.Author.When,
|
||||||
}
|
}
|
||||||
chunkLeaks := inspect(diff)
|
chunkLeaks := inspect(diff)
|
||||||
|
|||||||
Reference in new issue
Block a user