mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-30 05:04:22 +01:00
Update entropy noise reduction
Instead of reducing noise by default, there's a new flag called `--noise-reduction` to enable that.
This commit is contained in:
1 parent
ea49078ffd
commit
68c2a18f6f
3 files changed
+55
-31
No files matched your search
@@ -63,30 +63,31 @@ Usage:
|
|||||||
gitleaks [OPTIONS]
|
gitleaks [OPTIONS]
|
||||||
|
|
||||||
Application Options:
|
Application Options:
|
||||||
-r, --repo= Repo url to audit
|
-r, --repo= Repo url to audit
|
||||||
--github-user= Github user to audit
|
--github-user= Github user to audit
|
||||||
--github-org= Github organization 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-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
|
--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-user= GitLab user ID to audit
|
||||||
--gitlab-org= GitLab group ID to audit
|
--gitlab-org= GitLab group ID to audit
|
||||||
-c, --commit= sha of commit to stop at
|
-c, --commit= sha of commit to stop at
|
||||||
--depth= maximum commit depth
|
--depth= maximum commit depth
|
||||||
--repo-path= Path to repo
|
--repo-path= Path to repo
|
||||||
--owner-path= Path to owner directory (repos discovered)
|
--owner-path= Path to owner directory (repos discovered)
|
||||||
--threads= Maximum number of threads gitleaks spawns
|
--threads= Maximum number of threads gitleaks spawns
|
||||||
--disk Clones repo(s) to disk
|
--disk Clones repo(s) to disk
|
||||||
--single-search= single regular expression to search for
|
--single-search= single regular expression to search for
|
||||||
--config= path to gitleaks config
|
--config= path to gitleaks config
|
||||||
--ssh-key= path to ssh key
|
--ssh-key= path to ssh key
|
||||||
--exclude-forks exclude forks for organization/user audits
|
--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)
|
-e, --entropy= Include entropy checks during audit. Entropy scale: 0.0(no entropy) - 8.0(max entropy)
|
||||||
-l, --log= log level
|
--noise-reduction Reduce the number of finds when entropy checks are enabled
|
||||||
-v, --verbose Show verbose output from gitleaks audit
|
-l, --log= log level
|
||||||
--report= path to write report file
|
-v, --verbose Show verbose output from gitleaks audit
|
||||||
--redact redact secrets from log messages and report
|
--report= path to write report file
|
||||||
--version version number
|
--redact redact secrets from log messages and report
|
||||||
--sample-config prints a sample config file
|
--version version number
|
||||||
|
--sample-config prints a sample config file
|
||||||
|
|
||||||
Help Options:
|
Help Options:
|
||||||
-h, --help Show this help message
|
-h, --help Show this help message
|
||||||
|
|||||||
@@ -590,6 +590,15 @@ func TestAuditRepo(t *testing.T) {
|
|||||||
testOpts: Options{
|
testOpts: Options{
|
||||||
Entropy: 4.7,
|
Entropy: 4.7,
|
||||||
},
|
},
|
||||||
|
numLeaks: 6,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
repo: leaksRepo,
|
||||||
|
description: "leaks present with entropy",
|
||||||
|
testOpts: Options{
|
||||||
|
Entropy: 4.7,
|
||||||
|
NoiseReduction: true,
|
||||||
|
},
|
||||||
numLeaks: 2,
|
numLeaks: 2,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -611,6 +620,15 @@ func TestAuditRepo(t *testing.T) {
|
|||||||
{
|
{
|
||||||
repo: leaksRepo,
|
repo: leaksRepo,
|
||||||
description: "toml entropy range",
|
description: "toml entropy range",
|
||||||
|
numLeaks: 298,
|
||||||
|
configPath: path.Join(configsDir, "entropy"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
repo: leaksRepo,
|
||||||
|
testOpts: Options{
|
||||||
|
NoiseReduction: true,
|
||||||
|
},
|
||||||
|
description: "toml entropy range",
|
||||||
numLeaks: 58,
|
numLeaks: 58,
|
||||||
configPath: path.Join(configsDir, "entropy"),
|
configPath: path.Join(configsDir, "entropy"),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -77,13 +77,14 @@ type Options struct {
|
|||||||
OwnerPath string `long:"owner-path" description:"Path to owner directory (repos discovered)"`
|
OwnerPath string `long:"owner-path" description:"Path to owner directory (repos discovered)"`
|
||||||
|
|
||||||
// Process options
|
// Process options
|
||||||
Threads int `long:"threads" description:"Maximum number of threads gitleaks spawns"`
|
Threads int `long:"threads" description:"Maximum number of threads gitleaks spawns"`
|
||||||
Disk bool `long:"disk" description:"Clones repo(s) to disk"`
|
Disk bool `long:"disk" description:"Clones repo(s) to disk"`
|
||||||
SingleSearch string `long:"single-search" description:"single regular expression to search for"`
|
SingleSearch string `long:"single-search" description:"single regular expression to search for"`
|
||||||
ConfigPath string `long:"config" description:"path to gitleaks config"`
|
ConfigPath string `long:"config" description:"path to gitleaks config"`
|
||||||
SSHKey string `long:"ssh-key" description:"path to ssh key"`
|
SSHKey string `long:"ssh-key" description:"path to ssh key"`
|
||||||
ExcludeForks bool `long:"exclude-forks" description:"exclude forks for organization/user audits"`
|
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)"`
|
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"`
|
// TODO: IncludeMessages string `long:"messages" description:"include commit messages in audit"`
|
||||||
|
|
||||||
// Output options
|
// Output options
|
||||||
@@ -725,6 +726,10 @@ func entropyIsHighEnough(entropy float64) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func highEntropyLineIsALeak(line string) bool {
|
func highEntropyLineIsALeak(line string) bool {
|
||||||
|
if !opts.NoiseReduction {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
for _, re := range entropyRegexes {
|
for _, re := range entropyRegexes {
|
||||||
if re.FindString(line) != "" {
|
if re.FindString(line) != "" {
|
||||||
return true
|
return true
|
||||||
|
|||||||
Reference in new issue
Block a user