mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-30 05:04:22 +01:00
[update] entropy check
This commit is contained in:
1 parent
8af639d7ff
commit
ec2fc9d6cb
3 files changed
+50
-10
No files matched your search
@@ -10,6 +10,7 @@ func TestCheckRegex(t *testing.T) {
|
||||
checks := map[string]bool{
|
||||
"github.com": false,
|
||||
"github.com/user/": false,
|
||||
"github.com/user -- Sys": false,
|
||||
"github_api_client = \"sample key\"": true,
|
||||
"aws=\"afewafewafewafewaf\"": true,
|
||||
"aws\"afewafewafewafewaf\"": false,
|
||||
@@ -25,3 +26,21 @@ func TestCheckRegex(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestEntropy(t *testing.T) {
|
||||
var enoughEntropy bool
|
||||
checks := map[string]bool{
|
||||
"heroku_client_secret = settings.HEROKU_CLIENT": false,
|
||||
"heroku_client_secret = conf.heroku": false,
|
||||
"reddit_secret = settings.REDDIT_API": false,
|
||||
"reddit_api_secret = \"Fwe4fa431FgklreF\"": true,
|
||||
"aws_secret= \"AKIAIMNOJVGFDXXXE4OA\"": true,
|
||||
}
|
||||
for k, v := range checks {
|
||||
enoughEntropy = checkEntropy(k)
|
||||
if v != enoughEntropy {
|
||||
t.Errorf("checkEntropy failed for %s. Expected %t, got %t", k, v, enoughEntropy)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user