From 443ef98e41badaef2f17f1bed80aac9fd8fc2b91 Mon Sep 17 00:00:00 2001 From: joeleonjr <20135619+joeleonjr@users.noreply.github.com> Date: Mon, 22 Jan 2024 16:57:51 -0500 Subject: [PATCH] updating detector logic for zenscrape (#2316) * updating detector logic for zenscrape * updating to use status endpoint --- pkg/detectors/zenscrape/zenscrape.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/pkg/detectors/zenscrape/zenscrape.go b/pkg/detectors/zenscrape/zenscrape.go index 1ec246c1f..08b93f7cd 100644 --- a/pkg/detectors/zenscrape/zenscrape.go +++ b/pkg/detectors/zenscrape/zenscrape.go @@ -2,7 +2,6 @@ package zenscrape import ( "context" - "io" "net/http" "regexp" "strings" @@ -48,7 +47,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } if verify { - req, err := http.NewRequestWithContext(ctx, "GET", "https://app.zenscrape.com/api/v1/get?url=http://www.google.com", nil) + req, err := http.NewRequestWithContext(ctx, "GET", "https://app.zenscrape.com/api/v1/status", nil) if err != nil { continue } @@ -56,20 +55,13 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result res, err := client.Do(req) if err == nil { defer res.Body.Close() - bodyBytes, err := io.ReadAll(res.Body) - if err != nil { - continue - } - body := string(bodyBytes) - - if !strings.Contains(body, "Not enough requests.") { + if (res.StatusCode >= 200 && res.StatusCode < 300) || res.StatusCode == 429 { s1.Verified = true } else { if detectors.IsKnownFalsePositive(resMatch, detectors.DefaultFalsePositives, true) { continue } } - } }