Find, verify, and analyze leaked credentials
Go credentialsdevsecopsdynamic-analysisprecommitscanningsecretsecret-managementsecretssecuritysecurity-toolstrufflehogverification
fix(twitch): Update Twitch detector to handle new RawV2 field and adjust test expectations (#4150)
Amaan Ullah64e04492ecd6
diff --git a/pkg/detectors/twitch/twitch.go b/pkg/detectors/twitch/twitch.goindex 7d5423fc7..e8171beff 100644--- a/pkg/detectors/twitch/twitch.go+++ b/pkg/detectors/twitch/twitch.go@@ -63,6 +63,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results1 := detectors.Result{DetectorType: detectorspb.DetectorType_Twitch,Raw: []byte(id),+ RawV2: []byte(id + ":" + secret),}if verify {diff --git a/pkg/detectors/twitch/twitch_integration_test.go b/pkg/detectors/twitch/twitch_integration_test.goindex 72408bdfd..ea8b39b71 100644--- a/pkg/detectors/twitch/twitch_integration_test.go+++ b/pkg/detectors/twitch/twitch_integration_test.go@@ -153,7 +153,7 @@ func TestTwitch_FromChunk(t *testing.T) {t.Errorf("Twitch.FromData() verificationError = %v, wantVerificationErr %v", got[i].VerificationError(), tt.wantVerificationErr)}}- ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "verificationError")+ ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "RawV2", "verificationError")if diff := cmp.Diff(got, tt.want, ignoreOpts); diff != "" {t.Errorf("Twitch.FromData() %s diff: (-got +want)\n%s", tt.name, diff)}diff --git a/pkg/detectors/twitch/twitch_test.go b/pkg/detectors/twitch/twitch_test.goindex 4879fb782..29f0bd9dd 100644--- a/pkg/detectors/twitch/twitch_test.go+++ b/pkg/detectors/twitch/twitch_test.go@@ -30,7 +30,7 @@ func TestTwitch_Pattern(t *testing.T) {{name: "valid pattern - with keyword twitch",input: fmt.Sprintf("%s token - '%s'\n%s token - '%s'\n", keyword, validKey, keyword, validId),- want: []string{validKey, validId},+ want: []string{validId + ":" + validKey, validKey + ":" + validId},},{name: "invalid pattern",