@@ -67,29 +67,30 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
67
67
68
68
matches := keyPat .FindAllStringSubmatch (dataStr , - 1 )
69
69
for _ , match := range matches {
70
+ resMatch := strings .TrimSpace (match [1 ])
71
+
70
72
// ignore v2 detectors which have a prefix of `glpat-`
71
73
if strings .Contains (match [0 ], "glpat-" ) {
72
74
continue
73
75
}
74
- resMatch := strings .TrimSpace (match [1 ])
75
76
76
77
// to avoid false positives
77
78
if detectors .StringShannonEntropy (resMatch ) < 3.6 {
78
79
continue
79
80
}
80
81
81
- s1 := detectors.Result {
82
- DetectorType : detectorspb .DetectorType_Gitlab ,
83
- Raw : []byte (resMatch ),
84
- ExtraData : map [string ]string {},
85
- }
86
- s1 .ExtraData = map [string ]string {
87
- "rotation_guide" : "https://howtorotate.com/docs/tutorials/gitlab/" ,
88
- "version" : fmt .Sprintf ("%d" , s .Version ()),
89
- }
82
+ for _ , endpoint := range s .Endpoints () {
83
+ s1 := detectors.Result {
84
+ DetectorType : detectorspb .DetectorType_Gitlab ,
85
+ Raw : []byte (resMatch ),
86
+ RawV2 : []byte (resMatch + endpoint ),
87
+ ExtraData : map [string ]string {
88
+ "rotation_guide" : "https://howtorotate.com/docs/tutorials/gitlab/" ,
89
+ "version" : fmt .Sprintf ("%d" , s .Version ()),
90
+ },
91
+ }
90
92
91
- if verify {
92
- for _ , endpoint := range s .Endpoints () {
93
+ if verify {
93
94
isVerified , extraData , verificationErr := VerifyGitlab (ctx , s .getClient (), endpoint , resMatch )
94
95
s1 .Verified = isVerified
95
96
maps .Copy (s1 .ExtraData , extraData )
@@ -102,11 +103,15 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
102
103
"key" : resMatch ,
103
104
"host" : endpoint ,
104
105
}
106
+
107
+ // if secret is verified with one endpoint, break the loop to continue to next secret
108
+ results = append (results , s1 )
109
+ break
105
110
}
106
111
}
107
- }
108
112
109
- results = append (results , s1 )
113
+ results = append (results , s1 )
114
+ }
110
115
}
111
116
112
117
return results , nil
0 commit comments