From 87f3f27dab01268e880a6a3e4891e7dc414036ea Mon Sep 17 00:00:00 2001 From: Brendan Shaklovitz Date: Thu, 4 May 2023 12:25:20 -0500 Subject: [PATCH] Fix SquareApp detector type return value (#1322) * Change SquareApp detector type to report as SquareApp instead of Square. --- pkg/detectors/squareapp/squareapp.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pkg/detectors/squareapp/squareapp.go b/pkg/detectors/squareapp/squareapp.go index 8be979936..6b388fbc2 100644 --- a/pkg/detectors/squareapp/squareapp.go +++ b/pkg/detectors/squareapp/squareapp.go @@ -20,7 +20,7 @@ type Scanner struct{} var _ detectors.Detector = (*Scanner)(nil) var ( - //possibly always `sq0csp` for secret + // possibly always `sq0csp` for secret // and `sq0idb` for app keyPat = regexp.MustCompile(`[\w\-]*sq0i[a-z]{2}-[0-9A-Za-z\-_]{22,43}`) secPat = regexp.MustCompile(`[\w\-]*sq0c[a-z]{2}-[0-9A-Za-z\-_]{40,50}`) @@ -39,7 +39,6 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result matches := keyPat.FindAllString(dataStr, -1) secMatches := secPat.FindAllString(dataStr, -1) for _, match := range matches { - for _, secMatch := range secMatches { if detectors.IsKnownFalsePositive(strings.ToLower(secMatch), detectors.DefaultFalsePositives, true) { @@ -47,7 +46,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } s := detectors.Result{ - DetectorType: detectorspb.DetectorType_Square, + DetectorType: detectorspb.DetectorType_SquareApp, Raw: []byte(match), Redacted: match, } @@ -72,7 +71,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result req.Header.Add("Content-Type", "application/json") // unclear if this version needs to be set or matters, seems to work without, but docs want it - //req.Header.Add("Square-Version", "2020-08-12") + // req.Header.Add("Square-Version", "2020-08-12") res, err := client.Do(req) if err == nil { res.Body.Close() // The request body is unused. @@ -95,5 +94,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } func (s Scanner) Type() detectorspb.DetectorType { - return detectorspb.DetectorType_Square + return detectorspb.DetectorType_SquareApp }