@@ -34,6 +34,14 @@ func (s Scanner) Keywords() []string {
34
34
return []string {"aha.io" }
35
35
}
36
36
37
+ func (s Scanner ) Type () detectorspb.DetectorType {
38
+ return detectorspb .DetectorType_Aha
39
+ }
40
+
41
+ func (s Scanner ) Description () string {
42
+ return "Aha is a product management software suite. Aha API keys can be used to access and modify product data and workflows."
43
+ }
44
+
37
45
func (s Scanner ) getClient () * http.Client {
38
46
if s .client != nil {
39
47
return s .client
@@ -44,30 +52,39 @@ func (s Scanner) getClient() *http.Client {
44
52
// FromData will find and optionally verify Aha secrets in a given set of bytes.
45
53
func (s Scanner ) FromData (ctx context.Context , verify bool , data []byte ) (results []detectors.Result , err error ) {
46
54
dataStr := string (data )
55
+
56
+ var uniqueFoundUrls = make (map [string ]struct {})
57
+
47
58
matches := keyPat .FindAllStringSubmatch (dataStr , - 1 )
48
- URLmatches := URLPat .FindAllStringSubmatch (dataStr , - 1 )
49
59
50
- resURLMatch := "aha.io"
51
- for _ , URLmatch := range URLmatches {
52
- resURLMatch = strings .TrimSpace (URLmatch [1 ])
60
+ for _ , match := range URLPat .FindAllStringSubmatch (dataStr , - 1 ) {
61
+ uniqueFoundUrls [match [1 ]] = struct {}{}
53
62
}
54
63
55
- for _ , match := range matches {
56
- resMatch := strings .TrimSpace (match [1 ])
57
-
58
- s1 := detectors.Result {
59
- DetectorType : detectorspb .DetectorType_Aha ,
60
- Raw : []byte (resMatch ),
61
- }
64
+ // if no url was found use the default
65
+ if len (uniqueFoundUrls ) == 0 {
66
+ uniqueFoundUrls ["aha.io" ] = struct {}{}
67
+ }
62
68
63
- if verify {
64
- client := s .getClient ()
65
- isVerified , verificationErr := verifyAha (ctx , client , resMatch , resURLMatch )
66
- s1 .Verified = isVerified
67
- s1 .SetVerificationError (verificationErr , resMatch )
69
+ for _ , match := range matches {
70
+ for url := range uniqueFoundUrls {
71
+ resMatch := strings .TrimSpace (match [1 ])
72
+
73
+ s1 := detectors.Result {
74
+ DetectorType : detectorspb .DetectorType_Aha ,
75
+ Raw : []byte (resMatch ),
76
+ RawV2 : []byte (resMatch + url ),
77
+ }
78
+
79
+ if verify {
80
+ client := s .getClient ()
81
+ isVerified , verificationErr := verifyAha (ctx , client , resMatch , url )
82
+ s1 .Verified = isVerified
83
+ s1 .SetVerificationError (verificationErr , resMatch )
84
+ }
85
+
86
+ results = append (results , s1 )
68
87
}
69
-
70
- results = append (results , s1 )
71
88
}
72
89
73
90
return results , nil
@@ -98,11 +115,3 @@ func verifyAha(ctx context.Context, client *http.Client, resMatch, resURLMatch s
98
115
return false , fmt .Errorf ("unexpected HTTP response status %d" , res .StatusCode )
99
116
}
100
117
}
101
-
102
- func (s Scanner ) Type () detectorspb.DetectorType {
103
- return detectorspb .DetectorType_Aha
104
- }
105
-
106
- func (s Scanner ) Description () string {
107
- return "Aha is a product management software suite. Aha API keys can be used to access and modify product data and workflows."
108
- }
0 commit comments