mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-12-01 05:24:22 +01:00
sprucing up the joint
This commit is contained in:
1 parent
6f5079c193
commit
1e250f1a14
6 files changed
+54
-55
No files matched your search
+13
-12
@@ -4,23 +4,24 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func init(){
|
||||
opts = &Options{
|
||||
Concurrency: 10,
|
||||
B64EntropyCutoff: 70,
|
||||
HexEntropyCutoff: 40,
|
||||
Entropy: false,
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckRegex(t *testing.T) {
|
||||
var results []string
|
||||
checks := map[string]int{
|
||||
"github.com": 0,
|
||||
"github.com/user/": 0,
|
||||
"github.com/user -- Sys": 0,
|
||||
"github_api_client = \"sample key\"\naws=afewafewafewafewaf": 2,
|
||||
"aws=\"afewafewafewafewaf\"": 1,
|
||||
"aws\"afewafewafewafewaf\"": 0,
|
||||
"heroku := \"afewafewafewafewaf\"": 1,
|
||||
"heroku_client_secret := \"afewafewafewafewaf\"": 1,
|
||||
"reddit_api_secreit = \"Fwe4fa431FgklreF\"": 1,
|
||||
"+ * [Github Help: Managing Deploy Keys](https://help.github.com/articles/managing-deploy-keys)": 0,
|
||||
"aws=\"AKIALALEMEL33243OLIAE": 1,
|
||||
"aws\"afewafewafewafewaf\"": 0,
|
||||
}
|
||||
|
||||
for k, v := range checks {
|
||||
results = checkRegex(k)
|
||||
results = doChecks(k)
|
||||
if v != len(results) {
|
||||
t.Errorf("regexCheck failed on string %s", k)
|
||||
}
|
||||
@@ -36,7 +37,7 @@ func TestEntropy(t *testing.T) {
|
||||
"aws_secret= \"AKIAIMNOJVGFDXXFE4OA\"": true,
|
||||
}
|
||||
for k, v := range checks {
|
||||
enoughEntropy = checkShannonEntropy(k, 70, 40)
|
||||
enoughEntropy = checkShannonEntropy(k)
|
||||
if v != enoughEntropy {
|
||||
t.Errorf("checkEntropy failed for %s. Expected %t, got %t", k, v, enoughEntropy)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user