Skip to content

Commit 715309a

Browse files
Missed Smartsheet Tokens (#4358)
* updated the length in smartsheet detector regex pattern * added pattern test cases for updated length
1 parent 10f895d commit 715309a

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

pkg/detectors/smartsheets/smartsheets.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var (
2222
client = common.SaneHttpClient()
2323

2424
// Make sure that your group is surrounded in boundary characters such as below to reduce false positives.
25-
keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"sheet"}) + `\b([a-zA-Z0-9]{37})\b`)
25+
keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"sheet"}) + `\b([a-zA-Z0-9]{26}|[a-zA-Z0-9]{37})\b`)
2626
)
2727

2828
// Keywords are used for efficiently pre-filtering chunks.

pkg/detectors/smartsheets/smartsheets_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,31 @@ func TestSmartsheets_Pattern(t *testing.T) {
5555
`,
5656
want: []string{},
5757
},
58+
{
59+
name: "valid pattern - 26 characters",
60+
input: `
61+
# smartsheet credentials
62+
sheet_token := "fakeiq999fakeecyfake3ifake"
63+
`,
64+
want: []string{"fakeiq999fakeecyfake3ifake"},
65+
},
66+
{
67+
name: "valid pattern - 26 and 37 characters",
68+
input: `
69+
# smartsheet multiple length credentials
70+
sheet_token := "fakeiq999fakeecyfake3ifake"
71+
sheet_token2 := "fakezmdxfakenFAKELzhonda7tvMpkqJ3fake"
72+
`,
73+
want: []string{"fakeiq999fakeecyfake3ifake", "fakezmdxfakenFAKELzhonda7tvMpkqJ3fake"},
74+
},
75+
{
76+
name: "invalid pattern - 30 characters",
77+
input: `
78+
# smartsheet invalid credentials
79+
sheet_token := "fakeiq999fakeecyfake3ifakeuiop"
80+
`,
81+
want: []string{},
82+
},
5883
{
5984
name: "invalid pattern",
6085
input: `

0 commit comments

Comments
 (0)