From 4addd81e29c1daebe0046bc6a7fcd4bc079f70b1 Mon Sep 17 00:00:00 2001 From: Richard Gomez <32133502+rgmz@users.noreply.github.com> Date: Thu, 13 Jun 2024 11:22:25 -0400 Subject: [PATCH] test: fix compile errors (#2964) --- .../gcpapplicationdefaultcredentials_test.go | 5 ++--- pkg/detectors/groq/groq_test.go | 5 ++--- pkg/detectors/intra42/intra42_test.go | 6 +++--- pkg/detectors/openai/openai_test.go | 5 ++--- pkg/detectors/snykkey/snykkey_test.go | 5 ++--- pkg/sources/github/github_integration_test.go | 2 +- 6 files changed, 12 insertions(+), 16 deletions(-) diff --git a/pkg/detectors/gcpapplicationdefaultcredentials/gcpapplicationdefaultcredentials_test.go b/pkg/detectors/gcpapplicationdefaultcredentials/gcpapplicationdefaultcredentials_test.go index 7bed123d1a3d..c161e420a999 100644 --- a/pkg/detectors/gcpapplicationdefaultcredentials/gcpapplicationdefaultcredentials_test.go +++ b/pkg/detectors/gcpapplicationdefaultcredentials/gcpapplicationdefaultcredentials_test.go @@ -44,9 +44,8 @@ func TestGcpapplicationdefaultcredentials_Pattern(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - chunkSpecificDetectors := make(map[ahocorasick.DetectorKey]detectors.Detector, 2) - ahoCorasickCore.FindDetectorMatches(test.input, chunkSpecificDetectors) - if len(chunkSpecificDetectors) == 0 { + detectorMatches := ahoCorasickCore.FindDetectorMatches([]byte(test.input)) + if len(detectorMatches) == 0 { t.Errorf("keywords '%v' not matched by: %s", d.Keywords(), test.input) return } diff --git a/pkg/detectors/groq/groq_test.go b/pkg/detectors/groq/groq_test.go index 5a836bb8055b..08d78e1885ec 100644 --- a/pkg/detectors/groq/groq_test.go +++ b/pkg/detectors/groq/groq_test.go @@ -35,9 +35,8 @@ func TestGroq_Pattern(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - chunkSpecificDetectors := make(map[ahocorasick.DetectorKey]detectors.Detector, 2) - ahoCorasickCore.PopulateMatchingDetectors(test.input, chunkSpecificDetectors) - if len(chunkSpecificDetectors) == 0 { + detectorMatches := ahoCorasickCore.FindDetectorMatches([]byte(test.input)) + if len(detectorMatches) == 0 { t.Errorf("keywords '%v' not matched by: %s", d.Keywords(), test.input) return } diff --git a/pkg/detectors/intra42/intra42_test.go b/pkg/detectors/intra42/intra42_test.go index b89950ee5755..bbbe6ae44192 100644 --- a/pkg/detectors/intra42/intra42_test.go +++ b/pkg/detectors/intra42/intra42_test.go @@ -11,6 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/engine/ahocorasick" @@ -39,9 +40,8 @@ intra_client_secret = 's-s4t2ud-d91c558a2ba6b47f60f690efc20a33d28c252d5bed840034 for _, test := range tests { t.Run(test.name, func(t *testing.T) { - chunkSpecificDetectors := make(map[ahocorasick.DetectorKey]detectors.Detector, 2) - ahoCorasickCore.PopulateMatchingDetectors(test.input, chunkSpecificDetectors) - if len(chunkSpecificDetectors) == 0 { + detectorMatches := ahoCorasickCore.FindDetectorMatches([]byte(test.input)) + if len(detectorMatches) == 0 { t.Errorf("keywords '%v' not matched by: %s", d.Keywords(), test.input) return } diff --git a/pkg/detectors/openai/openai_test.go b/pkg/detectors/openai/openai_test.go index 6035aa206bdc..db2853377986 100644 --- a/pkg/detectors/openai/openai_test.go +++ b/pkg/detectors/openai/openai_test.go @@ -45,9 +45,8 @@ func TestOpenAI_Pattern(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - chunkSpecificDetectors := make(map[ahocorasick.DetectorKey]detectors.Detector, 2) - ahoCorasickCore.PopulateMatchingDetectors(test.input, chunkSpecificDetectors) - if len(chunkSpecificDetectors) == 0 { + detectorMatches := ahoCorasickCore.FindDetectorMatches([]byte(test.input)) + if len(detectorMatches) == 0 { t.Errorf("keywords '%v' not matched by: %s", d.Keywords(), test.input) return } diff --git a/pkg/detectors/snykkey/snykkey_test.go b/pkg/detectors/snykkey/snykkey_test.go index 296d2e601eca..f239810ee0c6 100644 --- a/pkg/detectors/snykkey/snykkey_test.go +++ b/pkg/detectors/snykkey/snykkey_test.go @@ -48,9 +48,8 @@ set PATH=%PATH%;C:\Program Files\nodejs\;C:\Program Files\Git\cmd`, for _, test := range tests { t.Run(test.name, func(t *testing.T) { - chunkSpecificDetectors := make(map[ahocorasick.DetectorKey]detectors.Detector, 2) - ahoCorasickCore.FindDetectorMatches(test.input, chunkSpecificDetectors) - if len(chunkSpecificDetectors) == 0 { + matches := ahoCorasickCore.FindDetectorMatches([]byte(test.input)) + if len(matches) == 0 { t.Errorf("keywords '%v' not matched by: %s", d.Keywords(), test.input) return } diff --git a/pkg/sources/github/github_integration_test.go b/pkg/sources/github/github_integration_test.go index 2b0cddb98506..3ece02a16224 100644 --- a/pkg/sources/github/github_integration_test.go +++ b/pkg/sources/github/github_integration_test.go @@ -59,7 +59,7 @@ func TestSource_Token(t *testing.T) { memberCache: map[string]struct{}{}, repoInfoCache: newRepoInfoCache(), } - s.filteredRepoCache = s.newFilteredRepoCache(memory.New(), nil, nil) + s.filteredRepoCache = s.newFilteredRepoCache(memory.New[string](), nil, nil) installationClient, err := s.enumerateWithApp(ctx, "https://api.github.com", conn.GetGithubApp()) assert.NoError(t, err)