From 7befefd369f693837cb54bc8bb51ee90067bc2d5 Mon Sep 17 00:00:00 2001 From: Dustin Decker Date: Mon, 29 Jan 2024 11:28:46 -0800 Subject: [PATCH] Improve fp ignore logic (#2351) * forgot field change * use aho corasick for filter * reduce wordlist sensitivity --- go.mod | 2 +- .../azuresearchquerykey.go | 3 +- pkg/detectors/badlist.txt | 25 +--------- pkg/detectors/falsepositives.go | 48 ++++++++++--------- pkg/detectors/falsepositives_test.go | 32 ++++++++++++- pkg/detectors/programmingbooks.txt | 3 +- 6 files changed, 61 insertions(+), 52 deletions(-) diff --git a/go.mod b/go.mod index 915abcfd3482..57b42b31345c 100644 --- a/go.mod +++ b/go.mod @@ -39,6 +39,7 @@ require ( github.com/go-sql-driver/mysql v1.7.1 github.com/gobwas/glob v0.2.3 github.com/golang-jwt/jwt v3.2.2+incompatible + github.com/golang-jwt/jwt/v4 v4.5.0 github.com/google/go-cmp v0.6.0 github.com/google/go-containerregistry v0.17.0 github.com/google/go-github/v42 v42.0.0 @@ -166,7 +167,6 @@ require ( github.com/go-ole/go-ole v1.2.6 // indirect github.com/goccy/go-json v0.10.0 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect - github.com/golang-jwt/jwt/v4 v4.5.0 // indirect github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe // indirect github.com/golang-sql/sqlexp v0.1.0 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect diff --git a/pkg/detectors/azuresearchquerykey/azuresearchquerykey.go b/pkg/detectors/azuresearchquerykey/azuresearchquerykey.go index 27e21951f8ba..dbb7a396253f 100644 --- a/pkg/detectors/azuresearchquerykey/azuresearchquerykey.go +++ b/pkg/detectors/azuresearchquerykey/azuresearchquerykey.go @@ -52,7 +52,8 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result s1 := detectors.Result{ DetectorType: detectorspb.DetectorType_AzureSearchQueryKey, - Raw: []byte(resMatch + resUrlMatch), + Raw: []byte(resMatch), + RawV2: []byte(resMatch + resUrlMatch), } if verify { client := s.client diff --git a/pkg/detectors/badlist.txt b/pkg/detectors/badlist.txt index 274a32ceada8..713871d7efc4 100644 --- a/pkg/detectors/badlist.txt +++ b/pkg/detectors/badlist.txt @@ -4,12 +4,7 @@ array uint boolean config -/> -