Skip to content

Commit

Permalink
Tighten up regex for twist detector (trufflesecurity#1908)
Browse files Browse the repository at this point in the history
  • Loading branch information
dustin-decker authored Oct 18, 2023
1 parent b9f4993 commit 93cf523
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/detectors/twist/twist.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,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{"twist"}) + `\b([0-9a-f:]{40,47})\b`)
accessToken = regexp.MustCompile(detectors.PrefixRegex([]string{"twist"}) + `\b(?:oauth2:)?([0-9a-f]{40})\b`)
)

// Keywords are used for efficiently pre-filtering chunks.
Expand All @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string {
func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) {
dataStr := string(data)

matches := keyPat.FindAllStringSubmatch(dataStr, -1)
matches := accessToken.FindAllStringSubmatch(dataStr, -1)

for _, match := range matches {
if len(match) != 2 {
Expand Down

0 comments on commit 93cf523

Please sign in to comment.