diff --git a/scanner/errors.go b/scanner/errors.go index 2bb81c0..2593f4d 100644 --- a/scanner/errors.go +++ b/scanner/errors.go @@ -28,6 +28,7 @@ type Error struct { type ErrorMatched struct { Error Error Url string + Match string } //GetErrorRegexes returns all the error regexes @@ -48,3 +49,16 @@ func GetErrorRegexes() []Error { } return regexes } + +//RemoveDuplicateErrors removes duplicates from secrets found +func RemoveDuplicateErrors(input []ErrorMatched) []ErrorMatched { + keys := make(map[string]bool) + list := []ErrorMatched{} + for _, entry := range input { + if _, value := keys[entry.Match+entry.Url]; !value { + keys[entry.Url] = true + list = append(list, entry) + } + } + return list +} diff --git a/scanner/secrets.go b/scanner/secrets.go index 36b2b11..c3972b1 100644 --- a/scanner/secrets.go +++ b/scanner/secrets.go @@ -333,7 +333,7 @@ func RemoveDuplicateSecrets(input []SecretMatched) []SecretMatched { keys := make(map[string]bool) list := []SecretMatched{} for _, entry := range input { - if _, value := keys[entry.Url]; !value { + if _, value := keys[entry.Match+entry.Url]; !value { keys[entry.Url] = true list = append(list, entry) }