mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-12-01 21:44:23 +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
+24
No files matched your search
@@ -81,6 +81,7 @@ Application Options:
|
||||
--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
|
||||
|
||||
@@ -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"),
|
||||
},
|
||||
|
||||
@@ -84,6 +84,7 @@ type Options struct {
|
||||
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
|
||||
|
||||
Reference in new issue
Block a user