@@ -13,7 +13,7 @@ import (
13
13
"github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb"
14
14
)
15
15
16
- type Scanner struct {
16
+ type Scanner struct {
17
17
detectors.DefaultMultiPartCredentialProvider
18
18
}
19
19
@@ -37,20 +37,22 @@ func (s Scanner) Keywords() []string {
37
37
// FromData will find and optionally verify Auth0oauth secrets in a given set of bytes.
38
38
func (s Scanner ) FromData (ctx context.Context , verify bool , data []byte ) (results []detectors.Result , err error ) {
39
39
dataStr := string (data )
40
+ uniqueDomainMatches := make (map [string ]struct {})
41
+ uniqueClientIDs := make (map [string ]struct {})
42
+ uniqueSecrets := make (map [string ]struct {})
43
+ for _ , m := range domainPat .FindAllStringSubmatch (dataStr , - 1 ) {
44
+ uniqueDomainMatches [strings .TrimSpace (m [1 ])] = struct {}{}
45
+ }
46
+ for _ , m := range clientIdPat .FindAllStringSubmatch (dataStr , - 1 ) {
47
+ uniqueClientIDs [strings .TrimSpace (m [1 ])] = struct {}{}
48
+ }
49
+ for _ , m := range clientSecretPat .FindAllStringSubmatch (dataStr , - 1 ) {
50
+ uniqueSecrets [strings .TrimSpace (m [1 ])] = struct {}{}
51
+ }
40
52
41
- clientIdMatches := clientIdPat .FindAllStringSubmatch (dataStr , - 1 )
42
- clientSecretMatches := clientSecretPat .FindAllStringSubmatch (dataStr , - 1 )
43
- domainMatches := domainPat .FindAllStringSubmatch (dataStr , - 1 )
44
-
45
- for _ , clientIdMatch := range clientIdMatches {
46
- clientIdRes := strings .TrimSpace (clientIdMatch [1 ])
47
-
48
- for _ , clientSecretMatch := range clientSecretMatches {
49
- clientSecretRes := strings .TrimSpace (clientSecretMatch [1 ])
50
-
51
- for _ , domainMatch := range domainMatches {
52
- domainRes := strings .TrimSpace (domainMatch [1 ])
53
-
53
+ for clientIdRes := range uniqueClientIDs {
54
+ for clientSecretRes := range uniqueSecrets {
55
+ for domainRes := range uniqueDomainMatches {
54
56
s1 := detectors.Result {
55
57
DetectorType : detectorspb .DetectorType_Auth0oauth ,
56
58
Redacted : clientIdRes ,
0 commit comments