From 77a82847af2e6630f2fe2558c8d08ff330ef34cc Mon Sep 17 00:00:00 2001 From: Corben Leo Date: Thu, 5 Oct 2023 12:27:06 -0500 Subject: [PATCH] Detector-Competition-Fix: fix notion.so false negative verification (#1866) * Detector-Competition-Fix: fix notion.so false negative verification * Detector-Competition-Fix: fix notion.so verification --- pkg/detectors/notion/notion.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/detectors/notion/notion.go b/pkg/detectors/notion/notion.go index 55042156..9edb7a84 100644 --- a/pkg/detectors/notion/notion.go +++ b/pkg/detectors/notion/notion.go @@ -51,19 +51,29 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result if err != nil { continue } - req.Header.Add("Notion-Version", "2021-05-11") + req.Header.Add("Notion-Version", "2022-06-28") req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", resMatch)) res, err := client.Do(req) if err == nil { defer res.Body.Close() - if res.StatusCode >= 200 && res.StatusCode < 300 { + if res.StatusCode >= 200 && res.StatusCode < 300 || res.StatusCode == 403 { + // if >= 200 and < 300, the secret is valid and has privileges for the /v1/users endpoint + // If 403, the secret is valid, but does not have privileges for the /v1/users endpoint, + // Notion returns 401 for all non-valid keys, thus 403 indicates it has fine-tuned permissions, + // /v1/search, /v1/databases/*, etc. may work. s1.Verified = true + + } else if res.StatusCode == 401 { + // The secret is determinately not verified (nothing to do) + // Nothing returns 401 on all requests not containing a api key. } else { // This function will check false positives for common test words, but also it will make sure the key appears 'random' enough to be a real key. if detectors.IsKnownFalsePositive(resMatch, detectors.DefaultFalsePositives, true) { continue } } + } else { + s1.VerificationError = err } }