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
@@ -1,10 +1,13 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "fmt"
|
||||
"fmt"
|
||||
"github.com/nbutton23/zxcvbn-go"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// check each line of a diff and see if there are any potential
|
||||
// secrets
|
||||
func checkRegex(diff string) ([]string, bool) {
|
||||
var match string
|
||||
var results []string
|
||||
@@ -26,3 +29,19 @@ func checkRegex(diff string) ([]string, bool) {
|
||||
}
|
||||
return results, secretsPresent
|
||||
}
|
||||
|
||||
// checkEntropy determines whether target contains enough
|
||||
// entropy for a hash
|
||||
func checkEntropy(target string) bool {
|
||||
index := assignRegex.FindStringIndex(target)
|
||||
if len(index) == 0 {
|
||||
return false
|
||||
}
|
||||
target = strings.Trim(target[index[1]:len(target)], " ")
|
||||
entropy := zxcvbn.PasswordStrength(target, nil).Entropy
|
||||
// tune this/make option
|
||||
if entropy > 70 {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
Reference in new issue
Block a user