Skip to content

Find, verify, and analyze leaked credentials

remove old detector (#1474)

Zachary Riced4972313fff6
diff --git a/pkg/detectors/midise/midise.go b/pkg/detectors/midise/midise.go
deleted file mode 100644
index 03cc4dda0..000000000
--- a/pkg/detectors/midise/midise.go
+++ /dev/null
@@ -1,77 +0,0 @@
-package midise
-
-import (
- "context"
- "fmt"
- "net/http"
- "regexp"
-
- "github.com/trufflesecurity/trufflehog/v3/pkg/common"
- "github.com/trufflesecurity/trufflehog/v3/pkg/detectors"
- "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb"
-)
-
-type Scanner struct{}
-
-// Ensure the Scanner satisfies the interface at compile time.
-var _ detectors.Detector = (*Scanner)(nil)
-
-var (
- secretKey = regexp.MustCompile(`midi-662b69edd2[a-zA-Z0-9]{54}`)
-)
-
-// Keywords are used for efficiently pre-filtering chunks.
-// Use identifiers in the secret preferably, or the provider name.
-func (s Scanner) Keywords() []string {
- return []string{"midi-662b69edd2"}
-}
-
-// FromData will find and optionally verify Midise secrets in a given set of bytes.
-func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) {
-
- dataStr := string(data)
-
- matches := secretKey.FindAllString(dataStr, -1)
-
- for _, match := range matches {
-
- s := detectors.Result{
- DetectorType: detectorspb.DetectorType_Midise,
- Raw: []byte(match),
- }
-
- if verify {
-
- baseURL := "https://hooks.zapier.com/hooks/catch/11693304/bssgr3k"
-
- client := common.SaneHttpClient()
-
- req, err := http.NewRequestWithContext(ctx, "GET", baseURL, nil)
- if err != nil {
- continue
- }
- req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", match))
- req.Header.Add("Content-Type", "application/json")
- res, err := client.Do(req)
- if err == nil {
- res.Body.Close() // The request body is unused.
-
- if res.StatusCode == http.StatusOK {
- s.Verified = true
- }
- }
- }
-
- if !s.Verified && detectors.IsKnownFalsePositive(string(s.Raw), detectors.DefaultFalsePositives, true) {
- continue
- }
-
- results = append(results, s)
- }
-
- return
-}
-
-func (s Scanner) Type() detectorspb.DetectorType {
- return detectorspb.DetectorType_Midise
-}
diff --git a/pkg/detectors/midise/midise_test.go b/pkg/detectors/midise/midise_test.go
deleted file mode 100644
index fd072ed64..000000000
--- a/pkg/detectors/midise/midise_test.go
+++ /dev/null
@@ -1,73 +0,0 @@
-//go:build detectors
-// +build detectors
-
-package midise
-
-import (
- "context"
- "testing"
-
- "github.com/kylelemons/godebug/pretty"
- "github.com/trufflesecurity/trufflehog/v3/pkg/detectors"
-)
-
-func TestTruffle_FromChunk(t *testing.T) {
- type args struct {
- ctx context.Context
- data []byte
- verify bool
- }
- tests := []struct {
- name string
- s Scanner
- args args
- want []detectors.Result
- wantErr bool
- }{
- {
- name: "not found",
- s: Scanner{},
- args: args{
- ctx: context.Background(),
- data: []byte("You cannot find the secret within"),
- verify: true,
- },
- want: nil,
- wantErr: false,
- },
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- s := Scanner{}
- got, err := s.FromData(tt.args.ctx, tt.args.verify, tt.args.data)
- if (err != nil) != tt.wantErr {
- t.Errorf("Midise.FromData() error = %v, wantErr %v", err, tt.wantErr)
- return
- }
- for i := range got {
- if len(got[i].Raw) == 0 {
- t.Fatal("no raw secret present")
- }
- got[i].Raw = nil
- }
- if diff := pretty.Compare(got, tt.want); diff != "" {
- t.Errorf("Midise.FromData() %s diff: (-got +want)\n%s", tt.name, diff)
- }
- })
- }
-}
-
-func BenchmarkFromData(benchmark *testing.B) {
- ctx := context.Background()
- s := Scanner{}
- for name, data := range detectors.MustGetBenchmarkData() {
- benchmark.Run(name, func(b *testing.B) {
- for n := 0; n < b.N; n++ {
- _, err := s.FromData(ctx, false, data)
- if err != nil {
- b.Fatal(err)
- }
- }
- })
- }
-}
diff --git a/pkg/engine/defaults.go b/pkg/engine/defaults.go
index 82f1c7a61..04ee89ca1 100644
--- a/pkg/engine/defaults.go
+++ b/pkg/engine/defaults.go
@@ -404,7 +404,6 @@ import (
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/metaapi"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/metrilo"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/microsoftteamswebhook"
- "github.com/trufflesecurity/trufflehog/v3/pkg/detectors/midise"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/mindmeister"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/miro"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/mite"
@@ -1384,7 +1383,6 @@ func DefaultDetectors() []detectors.Detector {
sendbirdorganizationapi.Scanner{},
chatfule.Scanner{},
convier.Scanner{},
- midise.Scanner{},
loadmill.Scanner{},
magicbell.Scanner{},
glitterlyapi.Scanner{},