From 0c54b884dcad844fdc846344d3bf0307b7d3db1a Mon Sep 17 00:00:00 2001 From: Johann Saunier <1763341+jjsaunier@users.noreply.github.com> Date: Fri, 11 Nov 2022 21:24:17 +0100 Subject: [PATCH] Update Scrapfly API Key Format (#910) --- pkg/detectors/scrapfly/scrapfly.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/detectors/scrapfly/scrapfly.go b/pkg/detectors/scrapfly/scrapfly.go index c0fa5cf7c1a0..960ba2691e59 100644 --- a/pkg/detectors/scrapfly/scrapfly.go +++ b/pkg/detectors/scrapfly/scrapfly.go @@ -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. @@ -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 }