File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
pkg/detectors/baremetrics Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change 22
22
client = common .SaneHttpClient ()
23
23
24
24
// Make sure that your group is surrounded in boundary characters such as below to reduce false positives.
25
- keyPat = regexp .MustCompile (detectors .PrefixRegex ([]string {"baremetrics" }) + `\b([a-zA-Z0-9_]{25})\b` )
25
+ /*
26
+ Baremetrics has two type of keys:
27
+ - Sandbox: starts with `sk_`
28
+ - Production: starts with `lk_`
29
+ The length of key is not fixed and can range between 18 to 25 characters.
30
+ */
31
+ keyPat = regexp .MustCompile (detectors .PrefixRegex ([]string {"baremetrics" }) + `\b((?:sk|lk)_[a-zA-Z0-9]{18,25})\b` )
26
32
)
27
33
28
34
// Keywords are used for efficiently pre-filtering chunks.
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import (
12
12
)
13
13
14
14
var (
15
- validPattern = "FNdRZCc2qoPLrwrLJIBE6vovy "
15
+ validPattern = "sk_nGDJWCkPiFAKE5XFTzUUA "
16
16
complexPattern = `
17
17
func main() {
18
18
url := "https://api.example.com/v1/resource"
24
24
return
25
25
}
26
26
27
- baremetricsToken := "Bearer FN_RZCc2qoPLrwrLJIBE6vovy "
27
+ baremetricsToken := "Bearer sk_nGDJWCkPiFAKE5XFTzUUA "
28
28
req.Header.Set("Authorization", baremetricsToken)
29
29
30
30
// Perform the request
40
40
}
41
41
}
42
42
`
43
- invalidPattern = "FNdRZCc-qoPLrwrLJIBE6vovyu "
43
+ invalidPattern = "sk_nGDJWC_io8Q025XFTzUUA "
44
44
)
45
45
46
46
func TestBareMetrics_Pattern (t * testing.T ) {
@@ -55,12 +55,12 @@ func TestBareMetrics_Pattern(t *testing.T) {
55
55
{
56
56
name : "valid pattern" ,
57
57
input : fmt .Sprintf ("baremetrics credentials: %s" , validPattern ),
58
- want : []string {"FNdRZCc2qoPLrwrLJIBE6vovy " },
58
+ want : []string {"sk_nGDJWCkPiFAKE5XFTzUUA " },
59
59
},
60
60
{
61
61
name : "valid pattern - complex" ,
62
62
input : complexPattern ,
63
- want : []string {"FN_RZCc2qoPLrwrLJIBE6vovy " },
63
+ want : []string {"sk_nGDJWCkPiFAKE5XFTzUUA " },
64
64
},
65
65
{
66
66
name : "invalid pattern" ,
You can’t perform that action at this time.
0 commit comments