Compare commits

...
34 Commits
Author SHA1 Message Date
Zachary Rice d2baa9e675 jk i am prepared. no more games 2019-01-06 19:57:46 -06:00
Zachary Rice 7fa9c802f5 u r not prepared 2019-01-06 18:47:43 -06:00
zach rice 8f1bc74e26 new logo 2019-01-06 18:29:02 -06:00
zach rice 8de38be418 bump version 2019-01-06 17:48:08 -06:00
Zachary Rice ec1ebd4686 Merge pull request #171 from milo-minderbinder/bugfix/report-memory
fix memory issue when writing json report (#168)
2019-01-06 08:58:43 -06:00
zach rice 81ddfbed88 dupe code 2019-01-06 08:52:31 -06:00
Zachary Rice 63814f1eaf Merge pull request #172 from zricethezav/repo-config
Repo config
2019-01-05 21:35:51 -06:00
zach rice 38a36add57 typo 2019-01-05 20:51:59 -06:00
zach rice 9e39927ac6 turning down logging, adding test 2019-01-05 20:50:17 -06:00
Milo Minderbinder 0ba9dda0f0 fix memory issue when writing json report (#168)
Previously, gitleaks.writeReport used json.MarshallIndent on the entire
set of leaks when writing json reports, which would cause failures due
to excessive memory consumption when a large number of leaks were
identified.

This PR addresses the problem by doing incremental marshalling and
writing of leaks to the report file, and reduces the memory footprint by
several GB in tests with >30k leaks.
2019-01-04 18:49:25 -05:00
zach rice a24f9a2c92 working on getting pinned config working 2019-01-04 16:31:33 -06:00
Zachary Rice f57158a893 Merge pull request #170 from syk0saje/master
Fix typo in recovery message
2019-01-04 09:45:13 -06:00
Pepe Bawagan 1e3bf42464 Fix typo in recovery message 2019-01-04 15:23:26 +08:00
Zachary Rice 9d6a75fbab Merge pull request #163 from milo-minderbinder/bugfix/whitelist-checks
fix file (#162) & line (#161) whitelist checks
2019-01-01 11:09:54 -06:00
Milo Minderbinder 6fa52ae7cc Merge remote-tracking branch 'upstream/master' into bugfix/whitelist-checks 2018-12-31 16:54:53 -05:00
Milo Minderbinder bb9c459a1a check whiteListFiles for root commit & GitHub PRs
add missing checks against `whiteListFiles` regexes for files in the
root/initial commit and in GitHub PRs (in `auditGithubPR` function)
2018-12-31 12:49:49 -05:00
Zachary Rice 777601a0ea Merge pull request #165 from camaya/update-report-creation
Write report only when leaks are found
2018-12-27 16:16:24 -06:00
Zachary Rice 35d170018e Merge pull request #166 from arbazkiraak/patch-1
Adding Stripe API Regex
2018-12-27 16:15:38 -06:00
Arbaz Hussain af2e99ef45 Adding Strip API Regex
```
→ 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"
```
2018-12-27 21:45:39 +05:30
Zachary Rice 734befb555 bad cops bad cops 2018-12-25 09:31:58 -06:00
Milo Minderbinder 64c8d618a2 fix file (#162) & line (#161) whitelist checks
* only check entropyRegexes and whiteListRegexes once per line, and only
  if regex or entropy leak type was found, since regex checks are expensive
* check whiteListFiles once for each FilePatch, instead of for
  every Chunk
2018-12-13 13:14:54 -05:00
Cristhian Amaya 92bb4ea6fc Write report only when leaks are found 2018-12-11 18:33:11 +01:00
zach rice 98b025da72 bumping versions 2018-12-10 09:48:48 -06:00
Zachary Rice af7717412f Merge pull request #159 from camaya/reduce-entropy-noise
Reduce noise when running entropy checks
2018-12-10 09:40:05 -06:00
Cristhian Amaya 68c2a18f6f Update entropy noise reduction
Instead of reducing noise by default, there's a new flag called
`--noise-reduction` to enable that.
2018-12-10 16:24:53 +01:00
Cristhian Amaya ea49078ffd 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%
2018-12-04 10:23:42 +01:00
Zachary Rice b902d7310a Merge pull request #158 from camaya/redact-only-secret-on-line
Change redacted behaviour on the line information
2018-11-30 08:55:22 -06:00
Zachary Rice 3591560b34 Merge pull request #157 from camaya/add-commit-date-prs
Add commit date to Github PRs checks
2018-11-30 08:54:56 -06:00
Cristhian Amaya 949029ca89 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
2018-11-30 14:13:18 +01:00
Cristhian Amaya cde0894711 Add commit date to Github PRs checks 2018-11-30 13:37:18 +01:00
Zachary Rice 342e9f80db Merge pull request #152 from camaya/fix-github-pr-nilcheck
Fix Github PR checks error
2018-11-29 09:10:36 -06:00
Zachary Rice 96b0f4aab7 Merge pull request #153 from madblobfish/patch-1
Fix releases link in readme
2018-11-26 12:03:40 -06:00
madblobfish 3af6a546ac fix releases link in readme 2018-11-26 11:20:17 +01:00
Cristhian Amaya 6e086c4297 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.
2018-11-23 11:56:49 +01:00
6 changed files with 270 additions and 76 deletions

No files matched your search

+5
View File
@@ -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
+30 -26
View File
@@ -1,5 +1,5 @@
<p align="center">
<img alt="gitleaks" src="https://raw.githubusercontent.com/zricethezav/gifs/master/gitleaks5.png" height="140" />
<img alt="gitleaks" src="https://raw.githubusercontent.com/zricethezav/gifs/master/gitleaksnew2.gif"/>
<p align="center">
<a href="https://travis-ci.org/zricethezav/gitleaks"><img alt="Travis" src="https://img.shields.io/travis/zricethezav/gitleaks/master.svg?style=flat-square"></a>
</p>
@@ -33,7 +33,7 @@ It has been sucessfully used in a number of different scenarios, including;
</p>
#### 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
@@ -63,30 +63,32 @@ 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
--repo-config Load config from target repo. Config file must be ".gitleaks.toml"
-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
@@ -127,6 +129,8 @@ From C-U at Home:
<b>Donate</b>: https://www.cuathome.us/give/
#### Speaking of Community
Please read this https://corruptcu.com/
+16
View File
@@ -51,6 +51,21 @@ func auditGithubPR() ([]Leak, error) {
}
files := commit.Files
for _, f := range files {
skipFile := false
if f.Patch == nil || f.Filename == nil {
continue
}
for _, re := range whiteListFiles {
if re.FindString(f.GetFilename()) != "" {
log.Infof("skipping whitelisted file (matched regex '%s'): %s", re.String(), f.GetFilename())
skipFile = true
break
}
}
if skipFile {
continue
}
diff := gitDiff{
sha: commit.GetSHA(),
content: *f.Patch,
@@ -59,6 +74,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)...)
}
+4 -4
View File
@@ -21,19 +21,19 @@ regex = '''(?i)facebook.*['\"][0-9a-f]{32}['\"]'''
description = "Twitter"
regex = '''(?i)twitter.*['\"][0-9a-zA-Z]{35,44}['\"]'''
[[regexes]]
description = "Telegram"
regex = '''(?i)telegram.*['\"][0-9]{1,12}+:[0-9a-zA-Z-]{32,44}['\"]'''
[[regexes]]
description = "PGP"
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 = [
# "AKIA.*EXAMPLE",
]
files = [
"(.*?)(jpg|gif|doc|pdf|bin|go)$"
"(.*?)(jpg|gif|doc|pdf|bin)$"
]
+35
View File
@@ -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 {
@@ -480,6 +489,14 @@ func TestAuditRepo(t *testing.T) {
whiteListRegexes []*regexp.Regexp
configPath string
}{
{
repo: leaksRepo,
description: "pinned config",
numLeaks: 0,
testOpts: Options{
RepoConfig: true,
},
},
{
repo: leaksRepo,
description: "commit depth = 1, one leak",
@@ -583,6 +600,15 @@ func TestAuditRepo(t *testing.T) {
},
numLeaks: 6,
},
{
repo: leaksRepo,
description: "leaks present with entropy",
testOpts: Options{
Entropy: 4.7,
NoiseReduction: true,
},
numLeaks: 2,
},
{
repo: leaksRepo,
description: "Audit until specific commit",
@@ -605,6 +631,15 @@ func TestAuditRepo(t *testing.T) {
numLeaks: 298,
configPath: path.Join(configsDir, "entropy"),
},
{
repo: leaksRepo,
testOpts: Options{
NoiseReduction: true,
},
description: "toml entropy range",
numLeaks: 58,
configPath: path.Join(configsDir, "entropy"),
},
{
repo: leaksRepo,
description: "toml bad entropy range",
+180 -46
View File
@@ -23,6 +23,7 @@ import (
"gopkg.in/src-d/go-git.v4/plumbing"
diffType "gopkg.in/src-d/go-git.v4/plumbing/format/diff"
"gopkg.in/src-d/go-git.v4/plumbing/object"
"gopkg.in/src-d/go-git.v4/plumbing/transport/ssh"
"gopkg.in/src-d/go-git.v4/storage/memory"
@@ -30,9 +31,9 @@ import (
"github.com/BurntSushi/toml"
"github.com/google/go-github/github"
"github.com/hako/durafmt"
flags "github.com/jessevdk/go-flags"
"github.com/jessevdk/go-flags"
log "github.com/sirupsen/logrus"
git "gopkg.in/src-d/go-git.v4"
"gopkg.in/src-d/go-git.v4"
)
// Leak represents a leaked secret or regex match.
@@ -77,13 +78,15 @@ 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"`
RepoConfig bool `long:"repo-config" description:"Load config from target repo. Config file must be \".gitleaks.toml\""`
// TODO: IncludeMessages string `long:"messages" description:"include commit messages in audit"`
// Output options
@@ -101,6 +104,9 @@ type Config struct {
Description string
Regex string
}
Entropy struct {
LineRegexes []string
}
Whitelist struct {
Files []string
Regexes []string
@@ -130,7 +136,7 @@ type entropyRange struct {
}
const defaultGithubURL = "https://api.github.com/"
const version = "1.21.0"
const version = "1.23.0"
const errExit = 2
const leakExit = 1
const defaultConfig = `
@@ -169,6 +175,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 +217,7 @@ var (
whiteListCommits map[string]bool
whiteListRepos []*regexp.Regexp
entropyRanges []entropyRange
entropyRegexes []*regexp.Regexp
fileDiffRegex *regexp.Regexp
sshAuth *ssh.PublicKeys
dir string
@@ -325,6 +347,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") {
@@ -340,8 +366,41 @@ func writeReport(leaks []Leak) error {
}
w.Flush()
} else {
reportJSON, _ := json.MarshalIndent(leaks, "", "\t")
err = ioutil.WriteFile(opts.Report, reportJSON, 0644)
var (
f *os.File
encoder *json.Encoder
)
f, err := os.Create(opts.Report)
if err != nil {
return err
}
defer f.Close()
encoder = json.NewEncoder(f)
encoder.SetIndent("", "\t")
if _, err := f.WriteString("[\n"); err != nil {
return err
}
for i := 0; i < len(leaks); i++ {
if err := encoder.Encode(leaks[i]); err != nil {
return err
}
// for all but the last leak, seek back and overwrite the newline appended by Encode() with comma & newline
if i+1 < len(leaks) {
if _, err := f.Seek(-1, 1); err != nil {
return err
}
if _, err := f.WriteString(",\n"); err != nil {
return err
}
}
}
if _, err := f.WriteString("]"); err != nil {
return err
}
if err := f.Sync(); err != nil {
log.Error(err)
return err
}
}
return err
}
@@ -412,6 +471,14 @@ func auditGitRepo(repo *RepoDescriptor) ([]Leak, error) {
}
}
// check if target contains an external gitleaks toml
if opts.RepoConfig {
err := externalConfig(repo)
if err != nil {
return leaks, nil
}
}
// clear commit cache
commitMap = make(map[string]bool)
@@ -432,6 +499,29 @@ func auditGitRepo(repo *RepoDescriptor) ([]Leak, error) {
return leaks, err
}
// externalConfig will attempt to load a pinned ".gitleaks.toml" configuration file
// from a remote or local repo. Use the --repo-config option to trigger this.
func externalConfig(repo *RepoDescriptor) error {
var config Config
wt, err := repo.repository.Worktree()
if err != nil {
return err
}
f, err := wt.Filesystem.Open(".gitleaks.toml")
if err != nil {
return err
}
if _, err := toml.DecodeReader(f, &config); err != nil {
return fmt.Errorf("problem loading config: %v", err)
}
f.Close()
if err != nil {
return err
}
updateConfig(config)
return nil
}
// auditGitReference beings the audit for a git reference. This function will
// traverse the git reference and audit each line of each diff.
func auditGitReference(repo *RepoDescriptor, ref *plumbing.Reference) []Leak {
@@ -488,6 +578,12 @@ func auditGitReference(repo *RepoDescriptor, ref *plumbing.Reference) []Leak {
if bin || err != nil {
return nil
}
for _, re := range whiteListFiles {
if re.FindString(f.Name) != "" {
log.Debugf("skipping whitelisted file (matched regex '%s'): %s", re.String(), f.Name)
return nil
}
}
content, err := f.Contents()
if err != nil {
return nil
@@ -535,7 +631,7 @@ func auditGitReference(repo *RepoDescriptor, ref *plumbing.Reference) []Leak {
commitWg.Done()
<-semaphore
if r := recover(); r != nil {
log.Warnf("recoverying from panic on commit %s, likely large diff causing panic", c.Hash.String())
log.Warnf("recovering from panic on commit %s, likely large diff causing panic", c.Hash.String())
}
}()
patch, err := c.Patch(parent)
@@ -555,12 +651,19 @@ func auditGitReference(repo *RepoDescriptor, ref *plumbing.Reference) []Leak {
} else if to != nil {
filePath = to.Path()
}
for _, re := range whiteListFiles {
if re.FindString(filePath) != "" {
log.Debugf("skipping whitelisted file (matched regex '%s'): %s", re.String(), filePath)
skipFile = true
break
}
}
if skipFile {
continue
}
chunks := f.Chunks()
for _, chunk := range chunks {
if chunk.Type() == 1 || chunk.Type() == 2 {
if chunk.Type() == diffType.Add || chunk.Type() == diffType.Delete {
diff := gitDiff{
repoName: repoName,
filePath: filePath,
@@ -598,12 +701,6 @@ func inspect(diff gitDiff) []Leak {
skipLine bool
)
for _, re := range whiteListFiles {
if re.FindString(diff.filePath) != "" {
return leaks
}
}
lines := strings.Split(diff.content, "\n")
for _, line := range lines {
@@ -613,47 +710,44 @@ func inspect(diff gitDiff) []Leak {
if match == "" {
continue
}
// if offender matches whitelist regex, ignore it
for _, wRe := range whiteListRegexes {
whitelistMatch := wRe.FindString(line)
if whitelistMatch != "" {
skipLine = true
break
}
}
if skipLine {
if skipLine = isLineWhitelisted(line); skipLine {
break
}
leaks = addLeak(leaks, line, match, leakType, diff)
}
if opts.Entropy > 0 || len(entropyRanges) != 0 {
entropyLeak := false
if !skipLine && (opts.Entropy > 0 || len(entropyRanges) != 0) {
words := strings.Fields(line)
for _, word := range words {
entropy := getShannonEntropy(word)
if entropy >= opts.Entropy && len(entropyRanges) == 0 {
entropyLeak = true
// Only check entropyRegexes and whiteListRegexes once per line, and only if an entropy leak type
// was found above, since regex checks are expensive.
if !entropyIsHighEnough(entropy) {
continue
}
if len(entropyRanges) != 0 {
for _, eR := range entropyRanges {
if entropy > eR.v1 && entropy < eR.v2 {
entropyLeak = true
}
}
}
if entropyLeak {
leaks = addLeak(leaks, line, word, fmt.Sprintf("Entropy: %.2f", entropy), diff)
entropyLeak = false
// If either the line is whitelisted or the line fails the noiseReduction check (when enabled),
// then we can skip checking the rest of the line for high entropy words.
if skipLine = !highEntropyLineIsALeak(line) || isLineWhitelisted(line); skipLine {
break
}
leaks = addLeak(leaks, line, word, fmt.Sprintf("Entropy: %.2f", entropy), diff)
}
}
}
return leaks
}
// isLineWhitelisted returns true iff the line is matched by at least one of the whiteListRegexes.
func isLineWhitelisted(line string) bool {
for _, wRe := range whiteListRegexes {
whitelistMatch := wRe.FindString(line)
if whitelistMatch != "" {
return true
}
}
return false
}
// addLeak is helper for func inspect() to append leaks if found during a diff check.
func addLeak(leaks []Leak, line string, offender string, leakType string, diff gitDiff) []Leak {
leak := Leak{
@@ -669,7 +763,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 {
@@ -700,6 +794,36 @@ 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 {
if !opts.NoiseReduction {
return true
}
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) {
@@ -835,6 +959,11 @@ func loadToml() error {
}
}
return updateConfig(config)
}
// updateConfig will update a the global config values
func updateConfig(config Config) error {
if len(config.Misc.Entropy) != 0 {
err := entropyLimits(config.Misc.Entropy)
if err != nil {
@@ -842,6 +971,10 @@ func loadToml() error {
}
}
for _, regex := range config.Entropy.LineRegexes {
entropyRegexes = append(entropyRegexes, regexp.MustCompile(regex))
}
if singleSearchRegex != nil {
regexes["singleSearch"] = singleSearchRegex
} else {
@@ -864,6 +997,7 @@ func loadToml() error {
}
return nil
}
// entropyLimits hydrates entropyRanges which allows for fine tuning entropy checking