@@ -13,7 +13,7 @@ import (
1313 "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb"
1414)
1515
16- type Scanner struct {
16+ type Scanner struct {
1717 detectors.DefaultMultiPartCredentialProvider
1818}
1919
@@ -37,20 +37,22 @@ func (s Scanner) Keywords() []string {
3737// FromData will find and optionally verify Auth0oauth secrets in a given set of bytes.
3838func (s Scanner ) FromData (ctx context.Context , verify bool , data []byte ) (results []detectors.Result , err error ) {
3939 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+ }
4052
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 {
5456 s1 := detectors.Result {
5557 DetectorType : detectorspb .DetectorType_Auth0oauth ,
5658 Redacted : clientIdRes ,
0 commit comments