From 169a137e7f4474eed9b8dff322a3af5b2e3661a6 Mon Sep 17 00:00:00 2001
From: Cristhian Amaya
Date: Tue, 13 Nov 2018 11:54:25 +0100
Subject: [PATCH 01/15] Fix files whitelisting when checking Github PRs
Files whitelisting code was not executed when running the tool against a
Github PR so the config was ignored.
To avoid duplication, the whitelist files check has been moved to the `inspect`
function which is always executed.
---
gitleaks_test.go | 18 ++++++++++++++++++
main.go | 22 +++++++++-------------
2 files changed, 27 insertions(+), 13 deletions(-)
diff --git a/gitleaks_test.go b/gitleaks_test.go
index 21e79b07..ced32fe8 100644
--- a/gitleaks_test.go
+++ b/gitleaks_test.go
@@ -176,6 +176,7 @@ func TestRun(t *testing.T) {
description string
expectedErrMsg string
whiteListRepos []string
+ whiteListFiles []*regexp.Regexp
numLeaks int
configPath string
commitPerPage int
@@ -290,6 +291,18 @@ func TestRun(t *testing.T) {
expectedErrMsg: "",
commitPerPage: 1,
},
+ {
+ testOpts: Options{
+ GithubPR: "https://github.com/gitleakstest/gronit/pull/1",
+ },
+ description: "test github pr with whitelisted files",
+ numLeaks: 0,
+ expectedErrMsg: "",
+ commitPerPage: 1,
+ whiteListFiles: []*regexp.Regexp{
+ regexp.MustCompile("main.go"),
+ },
+ },
}
g := goblin.Goblin(t)
for _, test := range tests {
@@ -301,6 +314,11 @@ func TestRun(t *testing.T) {
if test.commitPerPage != 0 {
githubPages = test.commitPerPage
}
+ if test.whiteListFiles != nil {
+ whiteListFiles = test.whiteListFiles
+ } else {
+ whiteListFiles = nil
+ }
opts = test.testOpts
leaks, err := run()
if err != nil {
diff --git a/main.go b/main.go
index 4f66b7a1..9ea81bce 100644
--- a/main.go
+++ b/main.go
@@ -174,7 +174,7 @@ regex = '''xox[baprs]-([0-9a-zA-Z]{10,48})?'''
[whitelist]
files = [
- "(.*?)(jpg|gif|doc|pdf|bin)$"
+ "(.*?)(jpg|gif|doc|pdf|bin)$"
]
#commits = [
# "BADHA5H1",
@@ -486,11 +486,6 @@ func auditGitReference(repo *RepoDescriptor, ref *plumbing.Reference) []Leak {
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
@@ -558,12 +553,6 @@ func auditGitReference(repo *RepoDescriptor, ref *plumbing.Reference) []Leak {
} else if to != nil {
filePath = to.Path()
}
- for _, re := range whiteListFiles {
- if re.FindString(filePath) != "" {
- skipFile = true
- break
- }
- }
if skipFile {
continue
}
@@ -602,12 +591,19 @@ func auditGitReference(repo *RepoDescriptor, ref *plumbing.Reference) []Leak {
// will skip lines that include a whitelisted regex. A list of leaks is returned.
// If verbose mode (-v/--verbose) is set, then checkDiff will log leaks as they are discovered.
func inspect(diff gitDiff) []Leak {
- lines := strings.Split(diff.content, "\n")
var (
leaks []Leak
skipLine bool
)
+ for _, re := range whiteListFiles {
+ if re.FindString(diff.filePath) != "" {
+ return leaks
+ }
+ }
+
+ lines := strings.Split(diff.content, "\n")
+
for _, line := range lines {
skipLine = false
for leakType, re := range regexes {
From f8e609d4bfd055874e38178c1f6a9b88576c41ea Mon Sep 17 00:00:00 2001
From: Adam Kobi
Date: Thu, 15 Nov 2018 17:58:54 +0200
Subject: [PATCH 02/15] added case for when using oauth token for both listing
and cloning repos
---
github.go | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/github.go b/github.go
index 744cd9a2..201259c6 100644
--- a/github.go
+++ b/github.go
@@ -14,6 +14,7 @@ import (
log "github.com/sirupsen/logrus"
"golang.org/x/oauth2"
git "gopkg.in/src-d/go-git.v4"
+ gitHttp "gopkg.in/src-d/go-git.v4/plumbing/transport/http"
"gopkg.in/src-d/go-git.v4/storage/memory"
)
@@ -177,6 +178,7 @@ func cloneGithubRepo(githubRepo *github.Repository) (*RepoDescriptor, error) {
repo *git.Repository
err error
)
+ githubToken := os.Getenv("GITHUB_TOKEN")
if opts.ExcludeForks && githubRepo.GetFork() {
return nil, fmt.Errorf("skipping %s, excluding forks", *githubRepo.Name)
}
@@ -191,22 +193,38 @@ func cloneGithubRepo(githubRepo *github.Repository) (*RepoDescriptor, error) {
if err != nil {
return nil, fmt.Errorf("unable to generater owner temp dir: %v", err)
}
- if sshAuth != nil {
+ if sshAuth != nil && githubToken == "" {
repo, err = git.PlainClone(fmt.Sprintf("%s/%s", ownerDir, *githubRepo.Name), false, &git.CloneOptions{
URL: *githubRepo.SSHURL,
Auth: sshAuth,
})
+ } else if githubToken != "" {
+ repo, err = git.PlainClone(fmt.Sprintf("%s/%s", ownerDir, *githubRepo.Name), false, &git.CloneOptions{
+ URL: *githubRepo.CloneURL,
+ Auth: &gitHttp.BasicAuth{
+ Username: "fakeUsername", // yes, this can be anything except an empty string
+ Password: githubToken,
+ },
+ })
} else {
repo, err = git.PlainClone(fmt.Sprintf("%s/%s", ownerDir, *githubRepo.Name), false, &git.CloneOptions{
URL: *githubRepo.CloneURL,
})
}
} else {
- if sshAuth != nil {
+ if sshAuth != nil && githubToken == "" {
repo, err = git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
URL: *githubRepo.SSHURL,
Auth: sshAuth,
})
+ } else if githubToken != "" {
+ repo, err = git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
+ URL: *githubRepo.CloneURL,
+ Auth: &gitHttp.BasicAuth{
+ Username: "fakeUsername", // yes, this can be anything except an empty string
+ Password: githubToken,
+ },
+ })
} else {
repo, err = git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
URL: *githubRepo.CloneURL,
From 392d79b9e2f353af4462c888e612ec1ea0e8ca15 Mon Sep 17 00:00:00 2001
From: Adam Kobi
Date: Thu, 15 Nov 2018 19:04:51 +0200
Subject: [PATCH 03/15] added changes to changelog
---
CHANGELOG.md | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 728febfd..19944326 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,10 @@
CHANGELOG
=========
+1.21.0
+----
+- added support for cloning repositories using github api
+
1.20.0
----
- adding gitlab user and group support
From dbb6d4cc5f575384230694fc216d0f19c6d73262 Mon Sep 17 00:00:00 2001
From: zricethezav
Date: Sun, 18 Nov 2018 08:42:32 -0600
Subject: [PATCH 04/15] including camayas changes in version bump
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 19944326..87cf1568 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,7 @@ CHANGELOG
1.21.0
----
- added support for cloning repositories using github api
+- auditing PRs now allows for whitelisting files
1.20.0
----
From db08fc0564610deb6bab5d9c2cf0aec5eafc9a0c Mon Sep 17 00:00:00 2001
From: zricethezav
Date: Sun, 18 Nov 2018 08:43:05 -0600
Subject: [PATCH 05/15] actually bump version in code >.<
---
main.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/main.go b/main.go
index bd03bfda..d3bbd20d 100644
--- a/main.go
+++ b/main.go
@@ -130,7 +130,7 @@ type entropyRange struct {
}
const defaultGithubURL = "https://api.github.com/"
-const version = "1.20.0"
+const version = "1.21.0"
const errExit = 2
const leakExit = 1
const defaultConfig = `
From 6e086c42976f433993327cceb50054ec39c6a938 Mon Sep 17 00:00:00 2001
From: Cristhian Amaya
Date: Fri, 23 Nov 2018 11:56:49 +0100
Subject: [PATCH 06/15] Fix Github PR checks error
When a commit contained a file without patch information like an added
empty file, there was a nil pointer dereference.
---
github.go | 4 ++++
gitleaks_test.go | 9 +++++++++
2 files changed, 13 insertions(+)
diff --git a/github.go b/github.go
index 201259c6..b07e1cee 100644
--- a/github.go
+++ b/github.go
@@ -51,6 +51,10 @@ func auditGithubPR() ([]Leak, error) {
}
files := commit.Files
for _, f := range files {
+ if f.Patch == nil || f.Filename == nil {
+ continue
+ }
+
diff := gitDiff{
sha: commit.GetSHA(),
content: *f.Patch,
diff --git a/gitleaks_test.go b/gitleaks_test.go
index 5db7c76a..54bae5e8 100644
--- a/gitleaks_test.go
+++ b/gitleaks_test.go
@@ -311,6 +311,15 @@ func TestRun(t *testing.T) {
regexp.MustCompile("main.go"),
},
},
+ {
+ testOpts: Options{
+ GithubPR: "https://github.com/gitleakstest/gronit/pull/2",
+ },
+ description: "test github pr with commits without patch info",
+ numLeaks: 0,
+ expectedErrMsg: "",
+ commitPerPage: 1,
+ },
}
g := goblin.Goblin(t)
for _, test := range tests {
From 3af6a546ace0ca6ccfbe8a14a80d48d7750b3893 Mon Sep 17 00:00:00 2001
From: madblobfish <12998362+madblobfish@users.noreply.github.com>
Date: Mon, 26 Nov 2018 11:20:17 +0100
Subject: [PATCH 07/15] fix releases link in readme
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 9855a9ed..c06b3e1b 100644
--- a/README.md
+++ b/README.md
@@ -33,7 +33,7 @@ It has been sucessfully used in a number of different scenarios, including;
#### Installation
-Written in Go, gitleaks is available in binary form for many popular platforms and OS types from the [releases page](https://github.com/zricethezav/gitleaks). Alternatively, executed via Docker or it can be installed using Go directly, as per the below;
+Written in Go, gitleaks is available in binary form for many popular platforms and OS types from the [releases page](https://github.com/zricethezav/gitleaks/releases). Alternatively, executed via Docker or it can be installed using Go directly, as per the below;
##### Docker
From cde089471159303ae4a1d64bc9b056d1f7a2d1ff Mon Sep 17 00:00:00 2001
From: Cristhian Amaya
Date: Fri, 30 Nov 2018 13:37:18 +0100
Subject: [PATCH 08/15] Add commit date to Github PRs checks
---
github.go | 1 +
1 file changed, 1 insertion(+)
diff --git a/github.go b/github.go
index b07e1cee..b3b7c5e3 100644
--- a/github.go
+++ b/github.go
@@ -63,6 +63,7 @@ func auditGithubPR() ([]Leak, error) {
githubCommit: commit,
author: commit.GetCommitter().GetLogin(),
message: *commit.Commit.Message,
+ date: *commit.Commit.Committer.Date,
}
leaks = append(leaks, inspect(diff)...)
}
From 949029ca8964e22746be887c964825bed4b0d39e Mon Sep 17 00:00:00 2001
From: Cristhian Amaya
Date: Fri, 30 Nov 2018 14:13:18 +0100
Subject: [PATCH 09/15] Change redacted behaviour on the line information
The line information sometimes contains useful context information so
instead of redacting the whole line, this change redacts only the
secret
---
main.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/main.go b/main.go
index d3bbd20d..a311678e 100644
--- a/main.go
+++ b/main.go
@@ -669,7 +669,7 @@ func addLeak(leaks []Leak, line string, offender string, leakType string, diff g
}
if opts.Redact {
leak.Offender = "REDACTED"
- leak.Line = "REDACTED"
+ leak.Line = strings.Replace(line, offender, "REDACTED", -1)
}
if opts.Verbose {
From ea49078ffd6c62e825bf7b444e972933c2c34829 Mon Sep 17 00:00:00 2001
From: Cristhian Amaya
Date: Tue, 4 Dec 2018 10:23:42 +0100
Subject: [PATCH 10/15] Reduce noise when running entropy checks
When there's a word on a line with high entropy, we check if the line
matches any of the regex configured on the `lineregexes` element of the
`entropy` section. If so, it's marked as a leaked.
This has reduced the number of leaks found with entropy enabled up to
80%
---
gitleaks_test.go | 4 +--
main.go | 64 ++++++++++++++++++++++++++++++++++++++----------
2 files changed, 53 insertions(+), 15 deletions(-)
diff --git a/gitleaks_test.go b/gitleaks_test.go
index 54bae5e8..36cca870 100644
--- a/gitleaks_test.go
+++ b/gitleaks_test.go
@@ -590,7 +590,7 @@ func TestAuditRepo(t *testing.T) {
testOpts: Options{
Entropy: 4.7,
},
- numLeaks: 6,
+ numLeaks: 2,
},
{
repo: leaksRepo,
@@ -611,7 +611,7 @@ func TestAuditRepo(t *testing.T) {
{
repo: leaksRepo,
description: "toml entropy range",
- numLeaks: 298,
+ numLeaks: 58,
configPath: path.Join(configsDir, "entropy"),
},
{
diff --git a/main.go b/main.go
index a311678e..d9b2f42f 100644
--- a/main.go
+++ b/main.go
@@ -101,6 +101,9 @@ type Config struct {
Description string
Regex string
}
+ Entropy struct {
+ LineRegexes []string
+ }
Whitelist struct {
Files []string
Regexes []string
@@ -169,6 +172,21 @@ regex = '''(?i)github(.{0,4})?['\"][0-9a-zA-Z]{35,40}['\"]'''
description = "Slack"
regex = '''xox[baprs]-([0-9a-zA-Z]{10,48})?'''
+[entropy]
+lineregexes = [
+ "api",
+ "key",
+ "signature",
+ "secret",
+ "password",
+ "pass",
+ "pwd",
+ "token",
+ "curl",
+ "wget",
+ "https?",
+]
+
[whitelist]
files = [
"(.*?)(jpg|gif|doc|pdf|bin)$"
@@ -196,6 +214,7 @@ var (
whiteListCommits map[string]bool
whiteListRepos []*regexp.Regexp
entropyRanges []entropyRange
+ entropyRegexes []*regexp.Regexp
fileDiffRegex *regexp.Regexp
sshAuth *ssh.PublicKeys
dir string
@@ -630,23 +649,12 @@ func inspect(diff gitDiff) []Leak {
}
if opts.Entropy > 0 || len(entropyRanges) != 0 {
- entropyLeak := false
words := strings.Fields(line)
for _, word := range words {
entropy := getShannonEntropy(word)
- if entropy >= opts.Entropy && len(entropyRanges) == 0 {
- entropyLeak = true
- }
- if len(entropyRanges) != 0 {
- for _, eR := range entropyRanges {
- if entropy > eR.v1 && entropy < eR.v2 {
- entropyLeak = true
- }
- }
- }
- if entropyLeak {
+
+ if entropyIsHighEnough(entropy) && highEntropyLineIsALeak(line) {
leaks = addLeak(leaks, line, word, fmt.Sprintf("Entropy: %.2f", entropy), diff)
- entropyLeak = false
}
}
}
@@ -700,6 +708,32 @@ func getShannonEntropy(data string) (entropy float64) {
return entropy
}
+func entropyIsHighEnough(entropy float64) bool {
+ if entropy >= opts.Entropy && len(entropyRanges) == 0 {
+ return true
+ }
+
+ if len(entropyRanges) != 0 {
+ for _, eR := range entropyRanges {
+ if entropy > eR.v1 && entropy < eR.v2 {
+ return true
+ }
+ }
+ }
+
+ return false
+}
+
+func highEntropyLineIsALeak(line string) bool {
+ for _, re := range entropyRegexes {
+ if re.FindString(line) != "" {
+ return true
+ }
+ }
+
+ return false
+}
+
// discoverRepos walks all the children of `path`. If a child directory
// contain a .git file then that repo will be added to the list of repos returned
func discoverRepos(ownerPath string) ([]*RepoDescriptor, error) {
@@ -842,6 +876,10 @@ func loadToml() error {
}
}
+ for _, regex := range config.Entropy.LineRegexes {
+ entropyRegexes = append(entropyRegexes, regexp.MustCompile(regex))
+ }
+
if singleSearchRegex != nil {
regexes["singleSearch"] = singleSearchRegex
} else {
From 68c2a18f6fa959e516e9bfb534006244262ca3a9 Mon Sep 17 00:00:00 2001
From: Cristhian Amaya
Date: Mon, 10 Dec 2018 16:24:53 +0100
Subject: [PATCH 11/15] Update entropy noise reduction
Instead of reducing noise by default, there's a new flag called
`--noise-reduction` to enable that.
---
README.md | 49 ++++++++++++++++++++++++------------------------
gitleaks_test.go | 18 ++++++++++++++++++
main.go | 19 ++++++++++++-------
3 files changed, 55 insertions(+), 31 deletions(-)
diff --git a/README.md b/README.md
index c06b3e1b..53ece63a 100644
--- a/README.md
+++ b/README.md
@@ -63,30 +63,31 @@ Usage:
gitleaks [OPTIONS]
Application Options:
- -r, --repo= Repo url to audit
- --github-user= Github user to audit
- --github-org= Github organization to audit
- --github-url= GitHub API Base URL, use for GitHub Enterprise. Example: https://github.example.com/api/v3/ (default: https://api.github.com/)
- --github-pr= Github PR url to audit. This does not clone the repo. GITHUB_TOKEN must be set
- --gitlab-user= GitLab user ID to audit
- --gitlab-org= GitLab group ID to audit
- -c, --commit= sha of commit to stop at
- --depth= maximum commit depth
- --repo-path= Path to repo
- --owner-path= Path to owner directory (repos discovered)
- --threads= Maximum number of threads gitleaks spawns
- --disk Clones repo(s) to disk
- --single-search= single regular expression to search for
- --config= path to gitleaks config
- --ssh-key= path to ssh key
- --exclude-forks exclude forks for organization/user audits
- -e, --entropy= Include entropy checks during audit. Entropy scale: 0.0(no entropy) - 8.0(max entropy)
- -l, --log= log level
- -v, --verbose Show verbose output from gitleaks audit
- --report= path to write report file
- --redact redact secrets from log messages and report
- --version version number
- --sample-config prints a sample config file
+ -r, --repo= Repo url to audit
+ --github-user= Github user to audit
+ --github-org= Github organization to audit
+ --github-url= GitHub API Base URL, use for GitHub Enterprise. Example: https://github.example.com/api/v3/ (default: https://api.github.com/)
+ --github-pr= Github PR url to audit. This does not clone the repo. GITHUB_TOKEN must be set
+ --gitlab-user= GitLab user ID to audit
+ --gitlab-org= GitLab group ID to audit
+ -c, --commit= sha of commit to stop at
+ --depth= maximum commit depth
+ --repo-path= Path to repo
+ --owner-path= Path to owner directory (repos discovered)
+ --threads= Maximum number of threads gitleaks spawns
+ --disk Clones repo(s) to disk
+ --single-search= single regular expression to search for
+ --config= path to gitleaks config
+ --ssh-key= path to ssh key
+ --exclude-forks exclude forks for organization/user audits
+ -e, --entropy= Include entropy checks during audit. Entropy scale: 0.0(no entropy) - 8.0(max entropy)
+ --noise-reduction Reduce the number of finds when entropy checks are enabled
+ -l, --log= log level
+ -v, --verbose Show verbose output from gitleaks audit
+ --report= path to write report file
+ --redact redact secrets from log messages and report
+ --version version number
+ --sample-config prints a sample config file
Help Options:
-h, --help Show this help message
diff --git a/gitleaks_test.go b/gitleaks_test.go
index 36cca870..d9088dea 100644
--- a/gitleaks_test.go
+++ b/gitleaks_test.go
@@ -590,6 +590,15 @@ func TestAuditRepo(t *testing.T) {
testOpts: Options{
Entropy: 4.7,
},
+ numLeaks: 6,
+ },
+ {
+ repo: leaksRepo,
+ description: "leaks present with entropy",
+ testOpts: Options{
+ Entropy: 4.7,
+ NoiseReduction: true,
+ },
numLeaks: 2,
},
{
@@ -611,6 +620,15 @@ func TestAuditRepo(t *testing.T) {
{
repo: leaksRepo,
description: "toml entropy range",
+ numLeaks: 298,
+ configPath: path.Join(configsDir, "entropy"),
+ },
+ {
+ repo: leaksRepo,
+ testOpts: Options{
+ NoiseReduction: true,
+ },
+ description: "toml entropy range",
numLeaks: 58,
configPath: path.Join(configsDir, "entropy"),
},
diff --git a/main.go b/main.go
index d9b2f42f..b7d26a85 100644
--- a/main.go
+++ b/main.go
@@ -77,13 +77,14 @@ type Options struct {
OwnerPath string `long:"owner-path" description:"Path to owner directory (repos discovered)"`
// Process options
- Threads int `long:"threads" description:"Maximum number of threads gitleaks spawns"`
- Disk bool `long:"disk" description:"Clones repo(s) to disk"`
- SingleSearch string `long:"single-search" description:"single regular expression to search for"`
- ConfigPath string `long:"config" description:"path to gitleaks config"`
- SSHKey string `long:"ssh-key" description:"path to ssh key"`
- ExcludeForks bool `long:"exclude-forks" description:"exclude forks for organization/user audits"`
- Entropy float64 `long:"entropy" short:"e" description:"Include entropy checks during audit. Entropy scale: 0.0(no entropy) - 8.0(max entropy)"`
+ Threads int `long:"threads" description:"Maximum number of threads gitleaks spawns"`
+ Disk bool `long:"disk" description:"Clones repo(s) to disk"`
+ SingleSearch string `long:"single-search" description:"single regular expression to search for"`
+ ConfigPath string `long:"config" description:"path to gitleaks config"`
+ SSHKey string `long:"ssh-key" description:"path to ssh key"`
+ ExcludeForks bool `long:"exclude-forks" description:"exclude forks for organization/user audits"`
+ Entropy float64 `long:"entropy" short:"e" description:"Include entropy checks during audit. Entropy scale: 0.0(no entropy) - 8.0(max entropy)"`
+ NoiseReduction bool `long:"noise-reduction" description:"Reduce the number of finds when entropy checks are enabled"`
// TODO: IncludeMessages string `long:"messages" description:"include commit messages in audit"`
// Output options
@@ -725,6 +726,10 @@ func entropyIsHighEnough(entropy float64) bool {
}
func highEntropyLineIsALeak(line string) bool {
+ if !opts.NoiseReduction {
+ return true
+ }
+
for _, re := range entropyRegexes {
if re.FindString(line) != "" {
return true
From 98b025da7204d30500b942578dab747e0de23f0b Mon Sep 17 00:00:00 2001
From: zach rice
Date: Mon, 10 Dec 2018 09:48:48 -0600
Subject: [PATCH 12/15] bumping versions
---
CHANGELOG.md | 5 +++++
main.go | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 87cf1568..292a86af 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,11 @@
CHANGELOG
=========
+1.22.0
+----
+- context inclusion for redactions
+- noise reduction for entropy signals
+
1.21.0
----
- added support for cloning repositories using github api
diff --git a/main.go b/main.go
index b7d26a85..476fc24f 100644
--- a/main.go
+++ b/main.go
@@ -134,7 +134,7 @@ type entropyRange struct {
}
const defaultGithubURL = "https://api.github.com/"
-const version = "1.21.0"
+const version = "1.22.0"
const errExit = 2
const leakExit = 1
const defaultConfig = `
From 92bb4ea6fc64aba4966ad0eecde5c5a6a33fb7d2 Mon Sep 17 00:00:00 2001
From: Cristhian Amaya
Date: Tue, 11 Dec 2018 18:33:11 +0100
Subject: [PATCH 13/15] Write report only when leaks are found
---
main.go | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/main.go b/main.go
index 476fc24f..0a834b75 100644
--- a/main.go
+++ b/main.go
@@ -345,6 +345,10 @@ func run() ([]Leak, error) {
// writeReport writes a report to a file specified in the --report= option.
// Default format for report is JSON. You can use the --csv option to write the report as a csv
func writeReport(leaks []Leak) error {
+ if len(leaks) == 0 {
+ return nil
+ }
+
var err error
log.Infof("writing report to %s", opts.Report)
if strings.HasSuffix(opts.Report, ".csv") {
From 734befb555696a4e312e6ff6baca72df6389cc29 Mon Sep 17 00:00:00 2001
From: Zachary Rice
Date: Tue, 25 Dec 2018 09:31:58 -0600
Subject: [PATCH 14/15] bad cops bad cops
---
README.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/README.md b/README.md
index 53ece63a..05ab30c1 100644
--- a/README.md
+++ b/README.md
@@ -128,6 +128,8 @@ From C-U at Home:
Donate: https://www.cuathome.us/give/
+#### Speaking of Community
+Please read this https://corruptcu.com/
From af2e99ef457e8cc5e4850984326e7ece45b88850 Mon Sep 17 00:00:00 2001
From: Arbaz Hussain <13177578+arbazkiraak@users.noreply.github.com>
Date: Thu, 27 Dec 2018 21:45:39 +0530
Subject: [PATCH 15/15] Adding Strip API Regex
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
```
→ printf ' Stripe.api_key = "Sk_test_41u0zAKbiWmTVhvHcS6gAjp9"
Stripe.api_key = "sk_live_VhYCleaZwuUBGSFYFc7WUboz"
STRIPE_PUBLIC_KEY= "pk_live_8sCPFZoLtW5pXuVHGrRKrROs"' | grep -P "(?i)(sk|pk)_(test|live)_[0-9a-zA-Z]{10,32}"
Stripe.api_key = "Sk_test_41u0zAKbiWmTVhvHcS6gAjp9"
Stripe.api_key = "sk_live_VhYCleaZwuUBGSFYFc7WUboz"
STRIPE_PUBLIC_KEY= "pk_live_8sCPFZoLtW5pXuVHGrRKrROs"
```
---
gitleaks.toml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/gitleaks.toml b/gitleaks.toml
index a6f929df..67d22979 100644
--- a/gitleaks.toml
+++ b/gitleaks.toml
@@ -29,6 +29,9 @@ regex = '''-----BEGIN PGP PRIVATE KEY BLOCK-----'''
[[regexes]]
description = "Slack token"
regex = '''xox[baprs]-.*'''
+[[regexes]]
+description = "Strip API Key"
+regex = '''(?i)(sk|pk)_(test|live)_[0-9a-zA-Z]{10,32}'''
[whitelist]
regexes = [