Skip to content

Commit

Permalink
Update Scrapfly API Key Format (trufflesecurity#910)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjsaunier authored and mac2000 committed Nov 16, 2022
1 parent 809dea9 commit 0c54b88
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/detectors/scrapfly/scrapfly.go
Expand Up @@ -22,7 +22,11 @@ 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{"scrapfly"}) + `\b([a-z0-9]{32})\b`)
// examples of api valid keys:
// - scp-live-03b9e7d0d0024e4b8fccc1ffe923e899 (new format)
// - scp-test-03b9e7d0d0024e4b8fccc1ffe923e899 (new format)
// - 03b9e7d0d0024e4b8fccc1ffe923e899 (old format)
keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"scrapfly"}) + `\b([a-z0-9]{32}|scp-(?:live|test)-[a-z0-9]{32})\b`)
)

// Keywords are used for efficiently pre-filtering chunks.
Expand Down Expand Up @@ -51,7 +55,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
if verify {
timeout := 10 * time.Second
client.Timeout = timeout
req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("https://api.scrapfly.io/scrape?key=%s&url=https://google.com", resMatch), nil)
req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("https://api.scrapfly.io/scrape?key=%s&url=https://httpbin.org/status/200", resMatch), nil)
if err != nil {
continue
}
Expand Down

0 comments on commit 0c54b88

Please sign in to comment.