Missed Smartsheet Tokens (#4358)
* updated the length in smartsheet detector regex pattern * added pattern test cases for updated length
This commit is contained in:
@@ -22,7 +22,7 @@ var (
|
||||
client = common.SaneHttpClient()
|
||||
|
||||
// Make sure that your group is surrounded in boundary characters such as below to reduce false positives.
|
||||
keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"sheet"}) + `\b([a-zA-Z0-9]{37})\b`)
|
||||
keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"sheet"}) + `\b([a-zA-Z0-9]{26}|[a-zA-Z0-9]{37})\b`)
|
||||
)
|
||||
|
||||
// Keywords are used for efficiently pre-filtering chunks.
|
||||
|
||||
@@ -55,6 +55,31 @@ func TestSmartsheets_Pattern(t *testing.T) {
|
||||
`,
|
||||
want: []string{},
|
||||
},
|
||||
{
|
||||
name: "valid pattern - 26 characters",
|
||||
input: `
|
||||
# smartsheet credentials
|
||||
sheet_token := "fakeiq999fakeecyfake3ifake"
|
||||
`,
|
||||
want: []string{"fakeiq999fakeecyfake3ifake"},
|
||||
},
|
||||
{
|
||||
name: "valid pattern - 26 and 37 characters",
|
||||
input: `
|
||||
# smartsheet multiple length credentials
|
||||
sheet_token := "fakeiq999fakeecyfake3ifake"
|
||||
sheet_token2 := "fakezmdxfakenFAKELzhonda7tvMpkqJ3fake"
|
||||
`,
|
||||
want: []string{"fakeiq999fakeecyfake3ifake", "fakezmdxfakenFAKELzhonda7tvMpkqJ3fake"},
|
||||
},
|
||||
{
|
||||
name: "invalid pattern - 30 characters",
|
||||
input: `
|
||||
# smartsheet invalid credentials
|
||||
sheet_token := "fakeiq999fakeecyfake3ifakeuiop"
|
||||
`,
|
||||
want: []string{},
|
||||
},
|
||||
{
|
||||
name: "invalid pattern",
|
||||
input: `
|
||||
|
||||
Reference in New Issue
Block a user