This commit is contained in:
Zach Rice committed 2022-03-11 09:30:12 -06:00
1 parent 9326f35380
commit 593bb6ffad
11 files changed
+345 -698

No files matched your search

-22
View File
@@ -2,7 +2,6 @@ package config
import (
"regexp"
"strings"
)
type Rule struct {
@@ -16,27 +15,6 @@ type Rule struct {
Allowlist Allowlist
}
func (r *Rule) IncludeEntropy(secret string) (bool, float64) {
// NOTE: this is a goofy hack to get around the fact there golang's regex engine
// does not support positive lookaheads. Ideally we would want to add a
// restriction on generic rules regex that requires the secret match group
// contains both numbers and alphabetical characters. What this bit of code does is
// check if the ruleid is prepended with "generic" and enforces the
// secret contains both digits and alphabetical characters.
if strings.HasPrefix(r.RuleID, "generic") {
if !containsDigit(secret) {
return false, 0.0
}
}
// group = 0 will check the entropy of the whole regex match
e := shannonEntropy(secret)
if e > r.Entropy {
return true, e
}
return false, e
}
func (r *Rule) EntropySet() bool {
if r.Entropy == 0.0 {
return false