This commit is contained in:
edoardottt
2021-11-28 12:43:58 +01:00
parent 99b22b6396
commit e911ea581d
3 changed files with 22 additions and 16 deletions
+1 -1
View File
@@ -346,7 +346,7 @@ func huntSecrets(secretsFile []string, target string, body string) []scanner.Sec
func SecretsMatch(url string, body string, secretsFile []string) []scanner.SecretMatched {
var secrets []scanner.SecretMatched
if len(secretsFile) == 0 {
for _, secret := range scanner.GetRegexes() {
for _, secret := range scanner.GetSecretRegexes() {
if matched, err := regexp.Match(secret.Regex, []byte(body)); err == nil && matched {
re := regexp.MustCompile(secret.Regex)
match := re.FindStringSubmatch(body)
+19
View File
@@ -29,3 +29,22 @@ type ErrorMatched struct {
Error Error
Url string
}
//GetErrorRegexes returns all the error regexes
func GetErrorRegexes() []Error {
var regexes = []Error{
{
"PHP error",
`(php warning|php error|include_path|undefined index|undefined variable|\\?php|expects parameter [0-9]*)`,
},
{
"General error",
`(((fatal|critical|severe|high|medium) error)|uncaught exception)`,
},
{
"Debug information",
`(Debug trace|stack trace\\:)`,
},
}
return regexes
}
+2 -15
View File
@@ -39,8 +39,8 @@ type SecretMatched struct {
Match string
}
//GetRegexes returns all the regexes
func GetRegexes() []Secret {
//GetSecretRegexes returns all the secret regexes
func GetSecretRegexes() []Secret {
var regexes = []Secret{
{
"AWS Access Key",
@@ -327,16 +327,3 @@ func GetRegexes() []Secret {
}
return regexes
}
//RemoveDuplicateSecrets removes duplicates from secrets found
func RemoveDuplicateSecrets(input []SecretMatched) []SecretMatched {
keys := make(map[string]bool)
list := []SecretMatched{}
for _, entry := range input {
if _, value := keys[entry.Url]; !value {
keys[entry.Url] = true
list = append(list, entry)
}
}
return list
}