From abecab0d8fb9fb3e79366abc3909825488e9bb40 Mon Sep 17 00:00:00 2001 From: Bill Rich Date: Mon, 21 Oct 2024 17:16:26 -0700 Subject: [PATCH] Remove proto (#3489) Only used for tracking analyzer types --- pkg/analyzer/analyzers/airbrake/airbrake.go | 3 +- pkg/analyzer/analyzers/analyzers.go | 106 ++++++--- pkg/analyzer/analyzers/asana/asana.go | 3 +- pkg/analyzer/analyzers/bitbucket/bitbucket.go | 5 +- pkg/analyzer/analyzers/github/github.go | 3 +- pkg/analyzer/analyzers/gitlab/gitlab.go | 3 +- .../analyzers/huggingface/huggingface.go | 5 +- pkg/analyzer/analyzers/mailchimp/mailchimp.go | 5 +- pkg/analyzer/analyzers/mailgun/mailgun.go | 5 +- pkg/analyzer/analyzers/mysql/mysql.go | 5 +- pkg/analyzer/analyzers/openai/openai.go | 3 +- pkg/analyzer/analyzers/opsgenie/opsgenie.go | 5 +- pkg/analyzer/analyzers/postgres/postgres.go | 5 +- pkg/analyzer/analyzers/postman/postman.go | 5 +- pkg/analyzer/analyzers/sendgrid/sendgrid.go | 5 +- pkg/analyzer/analyzers/shopify/shopify.go | 5 +- pkg/analyzer/analyzers/slack/slack.go | 5 +- .../analyzers/sourcegraph/sourcegraph.go | 5 +- pkg/analyzer/analyzers/square/square.go | 5 +- pkg/analyzer/analyzers/stripe/stripe.go | 5 +- pkg/analyzer/analyzers/twilio/twilio.go | 7 +- pkg/analyzer/cli.go | 6 +- pkg/analyzer/pb/analyzerpb/analyzer.pb.go | 203 ------------------ .../pb/analyzerpb/analyzer.pb.validate.go | 36 ---- pkg/analyzer/proto/analyzer.proto | 29 --- pkg/analyzer/tui/form.go | 2 +- pkg/analyzer/tui/keytype.go | 4 +- pkg/analyzer/tui/tui.go | 2 +- 28 files changed, 122 insertions(+), 358 deletions(-) delete mode 100644 pkg/analyzer/pb/analyzerpb/analyzer.pb.go delete mode 100644 pkg/analyzer/pb/analyzerpb/analyzer.pb.validate.go delete mode 100644 pkg/analyzer/proto/analyzer.proto diff --git a/pkg/analyzer/analyzers/airbrake/airbrake.go b/pkg/analyzer/analyzers/airbrake/airbrake.go index 5575541e16cc..e02d40e93c85 100644 --- a/pkg/analyzer/analyzers/airbrake/airbrake.go +++ b/pkg/analyzer/analyzers/airbrake/airbrake.go @@ -11,7 +11,6 @@ import ( "github.com/jedib0t/go-pretty/table" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/analyzers" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/config" - "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/pb/analyzerpb" "github.com/trufflesecurity/trufflehog/v3/pkg/context" ) @@ -21,7 +20,7 @@ type Analyzer struct { Cfg *config.Config } -func (Analyzer) Type() analyzerpb.AnalyzerType { return analyzerpb.AnalyzerType_Airbrake } +func (Analyzer) Type() analyzers.AnalyzerType { return analyzers.AnalyzerTypeAirbrake } func (a Analyzer) Analyze(_ context.Context, credInfo map[string]string) (*analyzers.AnalyzerResult, error) { info, err := AnalyzePermissions(a.Cfg, credInfo["key"]) diff --git a/pkg/analyzer/analyzers/analyzers.go b/pkg/analyzer/analyzers/analyzers.go index f897f4fe2c7a..06eea241f192 100644 --- a/pkg/analyzer/analyzers/analyzers.go +++ b/pkg/analyzer/analyzers/analyzers.go @@ -5,21 +5,23 @@ import ( "encoding/json" "io" "net/http" + "sort" "github.com/fatih/color" - "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/pb/analyzerpb" "github.com/trufflesecurity/trufflehog/v3/pkg/context" ) type ( Analyzer interface { - Type() analyzerpb.AnalyzerType + Type() AnalyzerType Analyze(ctx context.Context, credentialInfo map[string]string) (*AnalyzerResult, error) } + AnalyzerType int + // AnalyzerResult is the output of analysis. AnalyzerResult struct { - AnalyzerType analyzerpb.AnalyzerType + AnalyzerType AnalyzerType Bindings []Binding UnboundedResources []Resource Metadata map[string]any @@ -56,30 +58,80 @@ const ( FullAccess string = "full_access" ) -// Sorted list of all available analyzers. Used for valid sub-commands and TUI -// selection. TODO: Change slice type to Analyzer interface when all available -// analyzers implement it. -var AvailableAnalyzers = []string{ - "Airbrake", - "Asana", - "Bitbucket", - "GitHub", - "GitLab", - "HuggingFace", - "Mailchimp", - "Mailgun", - "MySQL", - "OpenAI", - "Opsgenie", - "Postgres", - "Postman", - "Sendgrid", - "Shopify", - "Slack", - "Sourcegraph", - "Square", - "Stripe", - "Twilio", +const ( + AnalyzerTypeInvalid AnalyzerType = iota + AnalyzerTypeAirbrake + AnalyzerTypeAsana + AnalyzerTypeBitbucket + AnalyzerTypeGitHub + AnalyzerTypeGitLab + AnalyzerTypeHuggingFace + AnalyzerTypeMailchimp + AnalyzerTypeMailgun + AnalyzerTypeMySQL + AnalyzerTypeOpenAI + AnalyzerTypeOpsgenie + AnalyzerTypePostgres + AnalyzerTypePostman + AnalyzerTypeSendgrid + AnalyzerTypeShopify + AnalyzerTypeSlack + AnalyzerTypeSourcegraph + AnalyzerTypeSquare + AnalyzerTypeStripe + AnalyzerTypeTwilio + // Add new items here with AnalyzerType prefix +) + +// analyzerTypeStrings maps the enum to its string representation. +var analyzerTypeStrings = map[AnalyzerType]string{ + AnalyzerTypeInvalid: "Invalid", + AnalyzerTypeAirbrake: "Airbrake", + AnalyzerTypeAsana: "Asana", + AnalyzerTypeBitbucket: "Bitbucket", + AnalyzerTypeGitHub: "GitHub", + AnalyzerTypeGitLab: "GitLab", + AnalyzerTypeHuggingFace: "HuggingFace", + AnalyzerTypeMailchimp: "Mailchimp", + AnalyzerTypeMailgun: "Mailgun", + AnalyzerTypeMySQL: "MySQL", + AnalyzerTypeOpenAI: "OpenAI", + AnalyzerTypeOpsgenie: "Opsgenie", + AnalyzerTypePostgres: "Postgres", + AnalyzerTypePostman: "Postman", + AnalyzerTypeSendgrid: "Sendgrid", + AnalyzerTypeShopify: "Shopify", + AnalyzerTypeSlack: "Slack", + AnalyzerTypeSourcegraph: "Sourcegraph", + AnalyzerTypeSquare: "Square", + AnalyzerTypeStripe: "Stripe", + AnalyzerTypeTwilio: "Twilio", + // Add new mappings here +} + +// String method to get the string representation of an AnalyzerType. +func (a AnalyzerType) String() string { + if str, ok := analyzerTypeStrings[a]; ok { + return str + } + return "Unknown" +} + +// GetSortedAnalyzerTypes returns a sorted slice of AnalyzerType strings, skipping "Invalid". +func AvailableAnalyzers() []string { + var analyzerStrings []string + + // Iterate through the map to collect all string values except "Invalid". + for typ, str := range analyzerTypeStrings { + if typ != AnalyzerTypeInvalid { + analyzerStrings = append(analyzerStrings, str) + } + } + + // Sort the slice alphabetically. + sort.Strings(analyzerStrings) + + return analyzerStrings } type PermissionStatus struct { diff --git a/pkg/analyzer/analyzers/asana/asana.go b/pkg/analyzer/analyzers/asana/asana.go index 2b6f9b3a6b41..0df9e9735728 100644 --- a/pkg/analyzer/analyzers/asana/asana.go +++ b/pkg/analyzer/analyzers/asana/asana.go @@ -14,7 +14,6 @@ import ( "github.com/jedib0t/go-pretty/table" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/analyzers" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/config" - "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/pb/analyzerpb" "github.com/trufflesecurity/trufflehog/v3/pkg/context" ) @@ -24,7 +23,7 @@ type Analyzer struct { Cfg *config.Config } -func (Analyzer) Type() analyzerpb.AnalyzerType { return analyzerpb.AnalyzerType_Asana } +func (Analyzer) Type() analyzers.AnalyzerType { return analyzers.AnalyzerTypeAsana } func (a Analyzer) Analyze(_ context.Context, credInfo map[string]string) (*analyzers.AnalyzerResult, error) { key, ok := credInfo["key"] diff --git a/pkg/analyzer/analyzers/bitbucket/bitbucket.go b/pkg/analyzer/analyzers/bitbucket/bitbucket.go index 7bc4c5cd533d..e146564c2fe6 100644 --- a/pkg/analyzer/analyzers/bitbucket/bitbucket.go +++ b/pkg/analyzer/analyzers/bitbucket/bitbucket.go @@ -13,7 +13,6 @@ import ( "github.com/jedib0t/go-pretty/table" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/analyzers" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/config" - "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/pb/analyzerpb" "github.com/trufflesecurity/trufflehog/v3/pkg/context" ) @@ -59,7 +58,7 @@ type Analyzer struct { Cfg *config.Config } -func (Analyzer) Type() analyzerpb.AnalyzerType { return analyzerpb.AnalyzerType_Bitbucket } +func (Analyzer) Type() analyzers.AnalyzerType { return analyzers.AnalyzerTypeBitbucket } func (a Analyzer) Analyze(_ context.Context, credInfo map[string]string) (*analyzers.AnalyzerResult, error) { key, ok := credInfo["key"] @@ -79,7 +78,7 @@ func secretInfoToAnalyzerResult(info *SecretInfo) *analyzers.AnalyzerResult { } result := analyzers.AnalyzerResult{ - AnalyzerType: analyzerpb.AnalyzerType_Bitbucket, + AnalyzerType: analyzers.AnalyzerTypeBitbucket, } // add unbounded resources diff --git a/pkg/analyzer/analyzers/github/github.go b/pkg/analyzer/analyzers/github/github.go index d8b3e9c3d8aa..40a4a7b5dd8b 100644 --- a/pkg/analyzer/analyzers/github/github.go +++ b/pkg/analyzer/analyzers/github/github.go @@ -13,7 +13,6 @@ import ( "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/analyzers/github/common" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/analyzers/github/finegrained" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/config" - "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/pb/analyzerpb" "github.com/trufflesecurity/trufflehog/v3/pkg/context" ) @@ -23,7 +22,7 @@ type Analyzer struct { Cfg *config.Config } -func (Analyzer) Type() analyzerpb.AnalyzerType { return analyzerpb.AnalyzerType_GitHub } +func (Analyzer) Type() analyzers.AnalyzerType { return analyzers.AnalyzerTypeGitHub } func (a Analyzer) Analyze(_ context.Context, credInfo map[string]string) (*analyzers.AnalyzerResult, error) { info, err := AnalyzePermissions(a.Cfg, credInfo["key"]) diff --git a/pkg/analyzer/analyzers/gitlab/gitlab.go b/pkg/analyzer/analyzers/gitlab/gitlab.go index d7563ad53d21..7975d232d64c 100644 --- a/pkg/analyzer/analyzers/gitlab/gitlab.go +++ b/pkg/analyzer/analyzers/gitlab/gitlab.go @@ -13,7 +13,6 @@ import ( "github.com/jedib0t/go-pretty/table" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/analyzers" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/config" - "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/pb/analyzerpb" "github.com/trufflesecurity/trufflehog/v3/pkg/context" ) @@ -23,7 +22,7 @@ type Analyzer struct { Cfg *config.Config } -func (Analyzer) Type() analyzerpb.AnalyzerType { return analyzerpb.AnalyzerType_GitLab } +func (Analyzer) Type() analyzers.AnalyzerType { return analyzers.AnalyzerTypeGitLab } func (a Analyzer) Analyze(_ context.Context, credInfo map[string]string) (*analyzers.AnalyzerResult, error) { _, err := AnalyzePermissions(a.Cfg, credInfo["key"]) diff --git a/pkg/analyzer/analyzers/huggingface/huggingface.go b/pkg/analyzer/analyzers/huggingface/huggingface.go index 6de5d70d2d7b..6cc06f9817d5 100644 --- a/pkg/analyzer/analyzers/huggingface/huggingface.go +++ b/pkg/analyzer/analyzers/huggingface/huggingface.go @@ -13,7 +13,6 @@ import ( "github.com/jedib0t/go-pretty/table" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/analyzers" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/config" - "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/pb/analyzerpb" "github.com/trufflesecurity/trufflehog/v3/pkg/context" ) @@ -29,7 +28,7 @@ type Analyzer struct { Cfg *config.Config } -func (Analyzer) Type() analyzerpb.AnalyzerType { return analyzerpb.AnalyzerType_HuggingFace } +func (Analyzer) Type() analyzers.AnalyzerType { return analyzers.AnalyzerTypeHuggingFace } func (a Analyzer) Analyze(_ context.Context, credInfo map[string]string) (*analyzers.AnalyzerResult, error) { key, ok := credInfo["key"] @@ -239,7 +238,7 @@ func secretInfoToAnalyzerResult(info *SecretInfo) *analyzers.AnalyzerResult { } result := analyzers.AnalyzerResult{ - AnalyzerType: analyzerpb.AnalyzerType_HuggingFace, + AnalyzerType: analyzers.AnalyzerTypeHuggingFace, Metadata: map[string]interface{}{ "username": info.Token.Username, "name": info.Token.Name, diff --git a/pkg/analyzer/analyzers/mailchimp/mailchimp.go b/pkg/analyzer/analyzers/mailchimp/mailchimp.go index bc13fc6ca243..390167fd6cfa 100644 --- a/pkg/analyzer/analyzers/mailchimp/mailchimp.go +++ b/pkg/analyzer/analyzers/mailchimp/mailchimp.go @@ -13,7 +13,6 @@ import ( "github.com/jedib0t/go-pretty/table" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/analyzers" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/config" - "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/pb/analyzerpb" "github.com/trufflesecurity/trufflehog/v3/pkg/context" ) @@ -25,7 +24,7 @@ type Analyzer struct { Cfg *config.Config } -func (Analyzer) Type() analyzerpb.AnalyzerType { return analyzerpb.AnalyzerType_Mailchimp } +func (Analyzer) Type() analyzers.AnalyzerType { return analyzers.AnalyzerTypeMailchimp } func (a Analyzer) Analyze(_ context.Context, credInfo map[string]string) (*analyzers.AnalyzerResult, error) { key, ok := credInfo["key"] @@ -45,7 +44,7 @@ func secretInfoToAnalyzerResult(info *SecretInfo) *analyzers.AnalyzerResult { return nil } result := analyzers.AnalyzerResult{ - AnalyzerType: analyzerpb.AnalyzerType_Mailchimp, + AnalyzerType: analyzers.AnalyzerTypeMailchimp, Bindings: make([]analyzers.Binding, 0, len(StringToPermission)), UnboundedResources: make([]analyzers.Resource, 0, len(info.Domains.Domains)), } diff --git a/pkg/analyzer/analyzers/mailgun/mailgun.go b/pkg/analyzer/analyzers/mailgun/mailgun.go index 62dcabf42438..2c499000fd60 100644 --- a/pkg/analyzer/analyzers/mailgun/mailgun.go +++ b/pkg/analyzer/analyzers/mailgun/mailgun.go @@ -13,7 +13,6 @@ import ( "github.com/jedib0t/go-pretty/table" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/analyzers" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/config" - "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/pb/analyzerpb" "github.com/trufflesecurity/trufflehog/v3/pkg/context" ) @@ -23,7 +22,7 @@ type Analyzer struct { Cfg *config.Config } -func (Analyzer) Type() analyzerpb.AnalyzerType { return analyzerpb.AnalyzerType_Mailgun } +func (Analyzer) Type() analyzers.AnalyzerType { return analyzers.AnalyzerTypeMailgun } func (a Analyzer) Analyze(_ context.Context, credInfo map[string]string) (*analyzers.AnalyzerResult, error) { key, ok := credInfo["key"] @@ -43,7 +42,7 @@ func secretInfoToAnalyzerResult(info *DomainsJSON) *analyzers.AnalyzerResult { return nil } result := analyzers.AnalyzerResult{ - AnalyzerType: analyzerpb.AnalyzerType_Mailgun, + AnalyzerType: analyzers.AnalyzerTypeMailgun, Bindings: make([]analyzers.Binding, len(info.Items)), } diff --git a/pkg/analyzer/analyzers/mysql/mysql.go b/pkg/analyzer/analyzers/mysql/mysql.go index 81870af0ace3..173cb4305ae1 100644 --- a/pkg/analyzer/analyzers/mysql/mysql.go +++ b/pkg/analyzer/analyzers/mysql/mysql.go @@ -19,7 +19,6 @@ import ( "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/analyzers" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/config" - "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/pb/analyzerpb" "github.com/trufflesecurity/trufflehog/v3/pkg/context" ) @@ -29,7 +28,7 @@ type Analyzer struct { Cfg *config.Config } -func (Analyzer) Type() analyzerpb.AnalyzerType { return analyzerpb.AnalyzerType_MySQL } +func (Analyzer) Type() analyzers.AnalyzerType { return analyzers.AnalyzerTypeMySQL } func (a Analyzer) Analyze(_ context.Context, credInfo map[string]string) (*analyzers.AnalyzerResult, error) { uri, ok := credInfo["connection_string"] @@ -48,7 +47,7 @@ func secretInfoToAnalyzerResult(info *SecretInfo) *analyzers.AnalyzerResult { return nil } result := analyzers.AnalyzerResult{ - AnalyzerType: analyzerpb.AnalyzerType_MySQL, + AnalyzerType: analyzers.AnalyzerTypeMySQL, Metadata: nil, Bindings: []analyzers.Binding{}, } diff --git a/pkg/analyzer/analyzers/openai/openai.go b/pkg/analyzer/analyzers/openai/openai.go index 1cd40f2b52f5..041c2950fa34 100644 --- a/pkg/analyzer/analyzers/openai/openai.go +++ b/pkg/analyzer/analyzers/openai/openai.go @@ -16,7 +16,6 @@ import ( "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/analyzers" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/config" - "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/pb/analyzerpb" "github.com/trufflesecurity/trufflehog/v3/pkg/context" ) @@ -26,7 +25,7 @@ type Analyzer struct { Cfg *config.Config } -func (Analyzer) Type() analyzerpb.AnalyzerType { return analyzerpb.AnalyzerType_OpenAI } +func (Analyzer) Type() analyzers.AnalyzerType { return analyzers.AnalyzerTypeOpenAI } func (a Analyzer) Analyze(_ context.Context, credInfo map[string]string) (*analyzers.AnalyzerResult, error) { info, err := AnalyzePermissions(a.Cfg, credInfo["key"]) diff --git a/pkg/analyzer/analyzers/opsgenie/opsgenie.go b/pkg/analyzer/analyzers/opsgenie/opsgenie.go index f308383ef81d..f63efd4408ce 100644 --- a/pkg/analyzer/analyzers/opsgenie/opsgenie.go +++ b/pkg/analyzer/analyzers/opsgenie/opsgenie.go @@ -16,7 +16,6 @@ import ( "github.com/jedib0t/go-pretty/table" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/analyzers" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/config" - "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/pb/analyzerpb" "github.com/trufflesecurity/trufflehog/v3/pkg/context" ) @@ -26,7 +25,7 @@ type Analyzer struct { Cfg *config.Config } -func (Analyzer) Type() analyzerpb.AnalyzerType { return analyzerpb.AnalyzerType_Opsgenie } +func (Analyzer) Type() analyzers.AnalyzerType { return analyzers.AnalyzerTypeOpsgenie } func (a Analyzer) Analyze(_ context.Context, credInfo map[string]string) (*analyzers.AnalyzerResult, error) { key, ok := credInfo["key"] @@ -45,7 +44,7 @@ func secretInfoToAnalyzerResult(info *SecretInfo) *analyzers.AnalyzerResult { return nil } result := analyzers.AnalyzerResult{ - AnalyzerType: analyzerpb.AnalyzerType_Opsgenie, + AnalyzerType: analyzers.AnalyzerTypeOpsgenie, Metadata: nil, Bindings: make([]analyzers.Binding, len(info.Permissions)), UnboundedResources: make([]analyzers.Resource, len(info.Users)), diff --git a/pkg/analyzer/analyzers/postgres/postgres.go b/pkg/analyzer/analyzers/postgres/postgres.go index 1eae6047d426..ca4a74e20357 100644 --- a/pkg/analyzer/analyzers/postgres/postgres.go +++ b/pkg/analyzer/analyzers/postgres/postgres.go @@ -16,7 +16,6 @@ import ( "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/analyzers" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/config" - "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/pb/analyzerpb" "github.com/trufflesecurity/trufflehog/v3/pkg/context" ) @@ -26,7 +25,7 @@ type Analyzer struct { Cfg *config.Config } -func (Analyzer) Type() analyzerpb.AnalyzerType { return analyzerpb.AnalyzerType_Postgres } +func (Analyzer) Type() analyzers.AnalyzerType { return analyzers.AnalyzerTypePostgres } func (a Analyzer) Analyze(_ context.Context, credInfo map[string]string) (*analyzers.AnalyzerResult, error) { uri, ok := credInfo["connection_string"] @@ -46,7 +45,7 @@ func secretInfoToAnalyzerResult(info *SecretInfo) *analyzers.AnalyzerResult { return nil } result := analyzers.AnalyzerResult{ - AnalyzerType: analyzerpb.AnalyzerType_Postgres, + AnalyzerType: analyzers.AnalyzerTypePostgres, Metadata: nil, Bindings: []analyzers.Binding{}, } diff --git a/pkg/analyzer/analyzers/postman/postman.go b/pkg/analyzer/analyzers/postman/postman.go index 98d088e0f7ff..8eecd5a9b257 100644 --- a/pkg/analyzer/analyzers/postman/postman.go +++ b/pkg/analyzer/analyzers/postman/postman.go @@ -12,7 +12,6 @@ import ( "github.com/jedib0t/go-pretty/table" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/analyzers" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/config" - "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/pb/analyzerpb" "github.com/trufflesecurity/trufflehog/v3/pkg/context" ) @@ -22,7 +21,7 @@ type Analyzer struct { Cfg *config.Config } -func (Analyzer) Type() analyzerpb.AnalyzerType { return analyzerpb.AnalyzerType_Postman } +func (Analyzer) Type() analyzers.AnalyzerType { return analyzers.AnalyzerTypePostman } func (a Analyzer) Analyze(_ context.Context, credInfo map[string]string) (*analyzers.AnalyzerResult, error) { key, ok := credInfo["key"] @@ -42,7 +41,7 @@ func secretInfoToAnalyzerResult(info *SecretInfo) *analyzers.AnalyzerResult { } result := analyzers.AnalyzerResult{ - AnalyzerType: analyzerpb.AnalyzerType_Postman, + AnalyzerType: analyzers.AnalyzerTypePostman, Metadata: nil, UnboundedResources: []analyzers.Resource{}, } diff --git a/pkg/analyzer/analyzers/sendgrid/sendgrid.go b/pkg/analyzer/analyzers/sendgrid/sendgrid.go index f924d0d68e0b..01f53254e81e 100644 --- a/pkg/analyzer/analyzers/sendgrid/sendgrid.go +++ b/pkg/analyzer/analyzers/sendgrid/sendgrid.go @@ -15,7 +15,6 @@ import ( "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/analyzers" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/config" - "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/pb/analyzerpb" "github.com/trufflesecurity/trufflehog/v3/pkg/context" ) @@ -25,7 +24,7 @@ type Analyzer struct { Cfg *config.Config } -func (Analyzer) Type() analyzerpb.AnalyzerType { return analyzerpb.AnalyzerType_Sendgrid } +func (Analyzer) Type() analyzers.AnalyzerType { return analyzers.AnalyzerTypeSendgrid } func (a Analyzer) Analyze(_ context.Context, credInfo map[string]string) (*analyzers.AnalyzerResult, error) { key, ok := credInfo["key"] @@ -54,7 +53,7 @@ func secretInfoToAnalyzerResult(info *SecretInfo) *analyzers.AnalyzerResult { } result := analyzers.AnalyzerResult{ - AnalyzerType: analyzerpb.AnalyzerType_Sendgrid, + AnalyzerType: analyzers.AnalyzerTypeSendgrid, Metadata: map[string]any{ "key_type": keyType, "2fa_required": slices.Contains(info.RawScopes, "2fa_required"), diff --git a/pkg/analyzer/analyzers/shopify/shopify.go b/pkg/analyzer/analyzers/shopify/shopify.go index 3711baae2bc6..b69569fe8df4 100644 --- a/pkg/analyzer/analyzers/shopify/shopify.go +++ b/pkg/analyzer/analyzers/shopify/shopify.go @@ -15,7 +15,6 @@ import ( "github.com/jedib0t/go-pretty/table" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/analyzers" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/config" - "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/pb/analyzerpb" "github.com/trufflesecurity/trufflehog/v3/pkg/context" ) @@ -30,7 +29,7 @@ var ( categoryOrder = []string{"Analytics", "Applications", "Assigned fulfillment orders", "Browsing behavior", "Custom pixels", "Customers", "Discounts", "Discovery", "Draft orders", "Files", "Fulfillment services", "Gift cards", "Inventory", "Legal policies", "Locations", "Marketing events", "Merchant-managed fulfillment orders", "Metaobject definitions", "Metaobject entries", "Online Store navigation", "Online Store pages", "Order editing", "Orders", "Packing slip management", "Payment customizations", "Payment terms", "Pixels", "Price rules", "Product feeds", "Product listings", "Products", "Publications", "Purchase options", "Reports", "Resource feedback", "Returns", "Sales channels", "Script tags", "Shipping", "Shop locales", "Shopify Markets", "Shopify Payments accounts", "Shopify Payments bank accounts", "Shopify Payments disputes", "Shopify Payments payouts", "Store content", "Store credit account transactions", "Store credit accounts", "Themes", "Third-party fulfillment orders", "Translations", "all_cart_transforms", "all_checkout_completion_target_customizations", "cart_transforms", "cash_tracking", "companies", "custom_fulfillment_services", "customer_data_erasure", "customer_merge", "delivery_customizations", "delivery_option_generators", "discounts_allocator_functions", "fulfillment_constraint_rules", "gates", "order_submission_rules", "privacy_settings", "shopify_payments_provider_accounts_sensitive", "validations"} ) -func (Analyzer) Type() analyzerpb.AnalyzerType { return analyzerpb.AnalyzerType_Shopify } +func (Analyzer) Type() analyzers.AnalyzerType { return analyzers.AnalyzerTypeShopify } func (a Analyzer) Analyze(_ context.Context, credInfo map[string]string) (*analyzers.AnalyzerResult, error) { key, ok := credInfo["key"] @@ -55,7 +54,7 @@ func secretInfoToAnalyzerResult(info *SecretInfo) *analyzers.AnalyzerResult { return nil } result := analyzers.AnalyzerResult{ - AnalyzerType: analyzerpb.AnalyzerType_Shopify, + AnalyzerType: analyzers.AnalyzerTypeShopify, Metadata: map[string]any{ "status_code": info.StatusCode, }, diff --git a/pkg/analyzer/analyzers/slack/slack.go b/pkg/analyzer/analyzers/slack/slack.go index 9190925b6bb1..46cde734ba2a 100644 --- a/pkg/analyzer/analyzers/slack/slack.go +++ b/pkg/analyzer/analyzers/slack/slack.go @@ -15,7 +15,6 @@ import ( "github.com/jedib0t/go-pretty/table" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/analyzers" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/config" - "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/pb/analyzerpb" "github.com/trufflesecurity/trufflehog/v3/pkg/context" ) @@ -25,7 +24,7 @@ type Analyzer struct { Cfg *config.Config } -func (Analyzer) Type() analyzerpb.AnalyzerType { return analyzerpb.AnalyzerType_Slack } +func (Analyzer) Type() analyzers.AnalyzerType { return analyzers.AnalyzerTypeSlack } func (a Analyzer) Analyze(_ context.Context, credInfo map[string]string) (*analyzers.AnalyzerResult, error) { key, ok := credInfo["key"] @@ -45,7 +44,7 @@ func secretInfoToAnalyzerResult(info *SecretInfo) *analyzers.AnalyzerResult { return nil } result := analyzers.AnalyzerResult{ - AnalyzerType: analyzerpb.AnalyzerType_Slack, + AnalyzerType: analyzers.AnalyzerTypeSlack, Metadata: nil, } diff --git a/pkg/analyzer/analyzers/sourcegraph/sourcegraph.go b/pkg/analyzer/analyzers/sourcegraph/sourcegraph.go index 71f3d05afd9d..d9e4f95b745a 100644 --- a/pkg/analyzer/analyzers/sourcegraph/sourcegraph.go +++ b/pkg/analyzer/analyzers/sourcegraph/sourcegraph.go @@ -12,7 +12,6 @@ import ( "github.com/fatih/color" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/analyzers" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/config" - "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/pb/analyzerpb" "github.com/trufflesecurity/trufflehog/v3/pkg/context" ) @@ -22,7 +21,7 @@ type Analyzer struct { Cfg *config.Config } -func (Analyzer) Type() analyzerpb.AnalyzerType { return analyzerpb.AnalyzerType_Sourcegraph } +func (Analyzer) Type() analyzers.AnalyzerType { return analyzers.AnalyzerTypeSourcegraph } func (a Analyzer) Analyze(_ context.Context, credInfo map[string]string) (*analyzers.AnalyzerResult, error) { key, ok := credInfo["key"] @@ -46,7 +45,7 @@ func secretInfoToAnalyzerResult(info *SecretInfo) *analyzers.AnalyzerResult { permission = PermissionStrings[SiteAdminFull] } result := analyzers.AnalyzerResult{ - AnalyzerType: analyzerpb.AnalyzerType_Sourcegraph, + AnalyzerType: analyzers.AnalyzerTypeSourcegraph, Metadata: nil, Bindings: []analyzers.Binding{ { diff --git a/pkg/analyzer/analyzers/square/square.go b/pkg/analyzer/analyzers/square/square.go index 1f72e1969477..8fc237e88f91 100644 --- a/pkg/analyzer/analyzers/square/square.go +++ b/pkg/analyzer/analyzers/square/square.go @@ -14,7 +14,6 @@ import ( "github.com/jedib0t/go-pretty/table" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/analyzers" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/config" - "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/pb/analyzerpb" "github.com/trufflesecurity/trufflehog/v3/pkg/context" ) @@ -24,7 +23,7 @@ type Analyzer struct { Cfg *config.Config } -func (Analyzer) Type() analyzerpb.AnalyzerType { return analyzerpb.AnalyzerType_Square } +func (Analyzer) Type() analyzers.AnalyzerType { return analyzers.AnalyzerTypeSquare } func (a Analyzer) Analyze(_ context.Context, credInfo map[string]string) (*analyzers.AnalyzerResult, error) { key, ok := credInfo["key"] @@ -43,7 +42,7 @@ func secretInfoToAnalyzerResult(info *SecretInfo) *analyzers.AnalyzerResult { return nil } result := analyzers.AnalyzerResult{ - AnalyzerType: analyzerpb.AnalyzerType_Square, + AnalyzerType: analyzers.AnalyzerTypeSquare, UnboundedResources: []analyzers.Resource{}, Metadata: map[string]any{ "expires_at": info.Permissions.ExpiresAt, diff --git a/pkg/analyzer/analyzers/stripe/stripe.go b/pkg/analyzer/analyzers/stripe/stripe.go index ba83dc49d68b..5fae0a64922c 100644 --- a/pkg/analyzer/analyzers/stripe/stripe.go +++ b/pkg/analyzer/analyzers/stripe/stripe.go @@ -18,7 +18,6 @@ import ( "github.com/jedib0t/go-pretty/table" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/analyzers" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/config" - "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/pb/analyzerpb" "github.com/trufflesecurity/trufflehog/v3/pkg/context" "gopkg.in/yaml.v2" ) @@ -29,7 +28,7 @@ type Analyzer struct { Cfg *config.Config } -func (Analyzer) Type() analyzerpb.AnalyzerType { return analyzerpb.AnalyzerType_Stripe } +func (Analyzer) Type() analyzers.AnalyzerType { return analyzers.AnalyzerTypeStripe } func (a Analyzer) Analyze(_ context.Context, credInfo map[string]string) (*analyzers.AnalyzerResult, error) { key, ok := credInfo["key"] @@ -49,7 +48,7 @@ func secretInfoToAnalyzerResult(info *SecretInfo) *analyzers.AnalyzerResult { return nil } result := &analyzers.AnalyzerResult{ - AnalyzerType: analyzerpb.AnalyzerType_Stripe, + AnalyzerType: analyzers.AnalyzerTypeStripe, Metadata: map[string]any{ "key_type": info.KeyType, "key_env": info.KeyEnv, diff --git a/pkg/analyzer/analyzers/twilio/twilio.go b/pkg/analyzer/analyzers/twilio/twilio.go index 4270b861d0f6..33a49cb14278 100644 --- a/pkg/analyzer/analyzers/twilio/twilio.go +++ b/pkg/analyzer/analyzers/twilio/twilio.go @@ -11,7 +11,6 @@ import ( "github.com/fatih/color" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/analyzers" "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/config" - "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/pb/analyzerpb" "github.com/trufflesecurity/trufflehog/v3/pkg/context" ) @@ -19,8 +18,8 @@ type Analyzer struct { Cfg *config.Config } -func (a *Analyzer) Type() analyzerpb.AnalyzerType { - return analyzerpb.AnalyzerType_Twilio +func (a *Analyzer) Type() analyzers.AnalyzerType { + return analyzers.AnalyzerTypeTwilio } func (a *Analyzer) Analyze(ctx context.Context, credentialInfo map[string]string) (*analyzers.AnalyzerResult, error) { @@ -118,7 +117,7 @@ func (a *Analyzer) Analyze(ctx context.Context, credentialInfo map[string]string } return &analyzers.AnalyzerResult{ - AnalyzerType: analyzerpb.AnalyzerType_Twilio, + AnalyzerType: analyzers.AnalyzerTypeTwilio, Bindings: bindings, }, nil } diff --git a/pkg/analyzer/cli.go b/pkg/analyzer/cli.go index 677dbc6f1f47..d3f8004e4a47 100644 --- a/pkg/analyzer/cli.go +++ b/pkg/analyzer/cli.go @@ -40,11 +40,11 @@ func Command(app *kingpin.Application) *kingpin.CmdClause { keyTypeHelp := fmt.Sprintf( "Type of key to analyze. Omit to interactively choose. Available key types: %s", - strings.Join(analyzers.AvailableAnalyzers, ", "), + strings.Join(analyzers.AvailableAnalyzers(), ", "), ) // Lowercase the available analyzers. - availableAnalyzers := make([]string, len(analyzers.AvailableAnalyzers)) - for i, a := range analyzers.AvailableAnalyzers { + availableAnalyzers := make([]string, len(analyzers.AvailableAnalyzers())) + for i, a := range analyzers.AvailableAnalyzers() { availableAnalyzers[i] = strings.ToLower(a) } analyzeKeyType = cli.Arg("key-type", keyTypeHelp).Enum(availableAnalyzers...) diff --git a/pkg/analyzer/pb/analyzerpb/analyzer.pb.go b/pkg/analyzer/pb/analyzerpb/analyzer.pb.go deleted file mode 100644 index 3e73341be6eb..000000000000 --- a/pkg/analyzer/pb/analyzerpb/analyzer.pb.go +++ /dev/null @@ -1,203 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.33.0 -// protoc v4.25.3 -// source: analyzer.proto - -package analyzerpb - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type AnalyzerType int32 - -const ( - AnalyzerType_Invalid AnalyzerType = 0 - AnalyzerType_Airbrake AnalyzerType = 1 - AnalyzerType_Asana AnalyzerType = 2 - AnalyzerType_Bitbucket AnalyzerType = 3 - AnalyzerType_GitHub AnalyzerType = 4 - AnalyzerType_GitLab AnalyzerType = 5 - AnalyzerType_HuggingFace AnalyzerType = 6 - AnalyzerType_Mailchimp AnalyzerType = 7 - AnalyzerType_Mailgun AnalyzerType = 8 - AnalyzerType_MySQL AnalyzerType = 9 - AnalyzerType_OpenAI AnalyzerType = 10 - AnalyzerType_Opsgenie AnalyzerType = 11 - AnalyzerType_Postgres AnalyzerType = 12 - AnalyzerType_Postman AnalyzerType = 13 - AnalyzerType_Sendgrid AnalyzerType = 14 - AnalyzerType_Shopify AnalyzerType = 15 - AnalyzerType_Slack AnalyzerType = 16 - AnalyzerType_Sourcegraph AnalyzerType = 17 - AnalyzerType_Square AnalyzerType = 18 - AnalyzerType_Stripe AnalyzerType = 19 - AnalyzerType_Twilio AnalyzerType = 20 -) - -// Enum value maps for AnalyzerType. -var ( - AnalyzerType_name = map[int32]string{ - 0: "Invalid", - 1: "Airbrake", - 2: "Asana", - 3: "Bitbucket", - 4: "GitHub", - 5: "GitLab", - 6: "HuggingFace", - 7: "Mailchimp", - 8: "Mailgun", - 9: "MySQL", - 10: "OpenAI", - 11: "Opsgenie", - 12: "Postgres", - 13: "Postman", - 14: "Sendgrid", - 15: "Shopify", - 16: "Slack", - 17: "Sourcegraph", - 18: "Square", - 19: "Stripe", - 20: "Twilio", - } - AnalyzerType_value = map[string]int32{ - "Invalid": 0, - "Airbrake": 1, - "Asana": 2, - "Bitbucket": 3, - "GitHub": 4, - "GitLab": 5, - "HuggingFace": 6, - "Mailchimp": 7, - "Mailgun": 8, - "MySQL": 9, - "OpenAI": 10, - "Opsgenie": 11, - "Postgres": 12, - "Postman": 13, - "Sendgrid": 14, - "Shopify": 15, - "Slack": 16, - "Sourcegraph": 17, - "Square": 18, - "Stripe": 19, - "Twilio": 20, - } -) - -func (x AnalyzerType) Enum() *AnalyzerType { - p := new(AnalyzerType) - *p = x - return p -} - -func (x AnalyzerType) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (AnalyzerType) Descriptor() protoreflect.EnumDescriptor { - return file_analyzer_proto_enumTypes[0].Descriptor() -} - -func (AnalyzerType) Type() protoreflect.EnumType { - return &file_analyzer_proto_enumTypes[0] -} - -func (x AnalyzerType) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use AnalyzerType.Descriptor instead. -func (AnalyzerType) EnumDescriptor() ([]byte, []int) { - return file_analyzer_proto_rawDescGZIP(), []int{0} -} - -var File_analyzer_proto protoreflect.FileDescriptor - -var file_analyzer_proto_rawDesc = []byte{ - 0x0a, 0x0e, 0x61, 0x6e, 0x61, 0x6c, 0x79, 0x7a, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x12, 0x08, 0x61, 0x6e, 0x61, 0x6c, 0x79, 0x7a, 0x65, 0x72, 0x2a, 0xa3, 0x02, 0x0a, 0x0c, 0x41, - 0x6e, 0x61, 0x6c, 0x79, 0x7a, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x49, - 0x6e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x41, 0x69, 0x72, 0x62, - 0x72, 0x61, 0x6b, 0x65, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x73, 0x61, 0x6e, 0x61, 0x10, - 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x42, 0x69, 0x74, 0x62, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x10, 0x03, - 0x12, 0x0a, 0x0a, 0x06, 0x47, 0x69, 0x74, 0x48, 0x75, 0x62, 0x10, 0x04, 0x12, 0x0a, 0x0a, 0x06, - 0x47, 0x69, 0x74, 0x4c, 0x61, 0x62, 0x10, 0x05, 0x12, 0x0f, 0x0a, 0x0b, 0x48, 0x75, 0x67, 0x67, - 0x69, 0x6e, 0x67, 0x46, 0x61, 0x63, 0x65, 0x10, 0x06, 0x12, 0x0d, 0x0a, 0x09, 0x4d, 0x61, 0x69, - 0x6c, 0x63, 0x68, 0x69, 0x6d, 0x70, 0x10, 0x07, 0x12, 0x0b, 0x0a, 0x07, 0x4d, 0x61, 0x69, 0x6c, - 0x67, 0x75, 0x6e, 0x10, 0x08, 0x12, 0x09, 0x0a, 0x05, 0x4d, 0x79, 0x53, 0x51, 0x4c, 0x10, 0x09, - 0x12, 0x0a, 0x0a, 0x06, 0x4f, 0x70, 0x65, 0x6e, 0x41, 0x49, 0x10, 0x0a, 0x12, 0x0c, 0x0a, 0x08, - 0x4f, 0x70, 0x73, 0x67, 0x65, 0x6e, 0x69, 0x65, 0x10, 0x0b, 0x12, 0x0c, 0x0a, 0x08, 0x50, 0x6f, - 0x73, 0x74, 0x67, 0x72, 0x65, 0x73, 0x10, 0x0c, 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x6f, 0x73, 0x74, - 0x6d, 0x61, 0x6e, 0x10, 0x0d, 0x12, 0x0c, 0x0a, 0x08, 0x53, 0x65, 0x6e, 0x64, 0x67, 0x72, 0x69, - 0x64, 0x10, 0x0e, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x68, 0x6f, 0x70, 0x69, 0x66, 0x79, 0x10, 0x0f, - 0x12, 0x09, 0x0a, 0x05, 0x53, 0x6c, 0x61, 0x63, 0x6b, 0x10, 0x10, 0x12, 0x0f, 0x0a, 0x0b, 0x53, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x67, 0x72, 0x61, 0x70, 0x68, 0x10, 0x11, 0x12, 0x0a, 0x0a, 0x06, - 0x53, 0x71, 0x75, 0x61, 0x72, 0x65, 0x10, 0x12, 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x74, 0x72, 0x69, - 0x70, 0x65, 0x10, 0x13, 0x12, 0x0a, 0x0a, 0x06, 0x54, 0x77, 0x69, 0x6c, 0x69, 0x6f, 0x10, 0x14, - 0x42, 0x45, 0x5a, 0x43, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, - 0x72, 0x75, 0x66, 0x66, 0x6c, 0x65, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x2f, 0x74, - 0x72, 0x75, 0x66, 0x66, 0x6c, 0x65, 0x68, 0x6f, 0x67, 0x2f, 0x76, 0x33, 0x2f, 0x70, 0x6b, 0x67, - 0x2f, 0x61, 0x6e, 0x61, 0x6c, 0x79, 0x7a, 0x65, 0x72, 0x2f, 0x70, 0x62, 0x2f, 0x61, 0x6e, 0x61, - 0x6c, 0x79, 0x7a, 0x65, 0x72, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_analyzer_proto_rawDescOnce sync.Once - file_analyzer_proto_rawDescData = file_analyzer_proto_rawDesc -) - -func file_analyzer_proto_rawDescGZIP() []byte { - file_analyzer_proto_rawDescOnce.Do(func() { - file_analyzer_proto_rawDescData = protoimpl.X.CompressGZIP(file_analyzer_proto_rawDescData) - }) - return file_analyzer_proto_rawDescData -} - -var file_analyzer_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_analyzer_proto_goTypes = []interface{}{ - (AnalyzerType)(0), // 0: analyzer.AnalyzerType -} -var file_analyzer_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_analyzer_proto_init() } -func file_analyzer_proto_init() { - if File_analyzer_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_analyzer_proto_rawDesc, - NumEnums: 1, - NumMessages: 0, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_analyzer_proto_goTypes, - DependencyIndexes: file_analyzer_proto_depIdxs, - EnumInfos: file_analyzer_proto_enumTypes, - }.Build() - File_analyzer_proto = out.File - file_analyzer_proto_rawDesc = nil - file_analyzer_proto_goTypes = nil - file_analyzer_proto_depIdxs = nil -} diff --git a/pkg/analyzer/pb/analyzerpb/analyzer.pb.validate.go b/pkg/analyzer/pb/analyzerpb/analyzer.pb.validate.go deleted file mode 100644 index c0327c9fa488..000000000000 --- a/pkg/analyzer/pb/analyzerpb/analyzer.pb.validate.go +++ /dev/null @@ -1,36 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: analyzer.proto - -package analyzerpb - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) diff --git a/pkg/analyzer/proto/analyzer.proto b/pkg/analyzer/proto/analyzer.proto deleted file mode 100644 index 31e32c489338..000000000000 --- a/pkg/analyzer/proto/analyzer.proto +++ /dev/null @@ -1,29 +0,0 @@ -syntax = "proto3"; - -package analyzer; - -option go_package = "github.com/trufflesecurity/trufflehog/v3/pkg/analyzer/pb/analyzerpb"; - -enum AnalyzerType { - Invalid = 0; - Airbrake = 1; - Asana = 2; - Bitbucket = 3; - GitHub = 4; - GitLab = 5; - HuggingFace = 6; - Mailchimp = 7; - Mailgun = 8; - MySQL = 9; - OpenAI = 10; - Opsgenie = 11; - Postgres = 12; - Postman = 13; - Sendgrid = 14; - Shopify = 15; - Slack = 16; - Sourcegraph = 17; - Square = 18; - Stripe = 19; - Twilio = 20; -} diff --git a/pkg/analyzer/tui/form.go b/pkg/analyzer/tui/form.go index 0c71c4ffd202..d335e5c19b8e 100644 --- a/pkg/analyzer/tui/form.go +++ b/pkg/analyzer/tui/form.go @@ -112,7 +112,7 @@ func (ui FormPage) View() string { func (ui FormPage) PrevPage() (tea.Model, tea.Cmd) { page := NewKeyTypePage(ui.Common) // Select what was previously selected. - index, ok := slices.BinarySearch(analyzers.AvailableAnalyzers, ui.KeyType) + index, ok := slices.BinarySearch(analyzers.AvailableAnalyzers(), ui.KeyType) if !ok { // Should be impossible. index = 0 diff --git a/pkg/analyzer/tui/keytype.go b/pkg/analyzer/tui/keytype.go index daf840545d63..485df873496d 100644 --- a/pkg/analyzer/tui/keytype.go +++ b/pkg/analyzer/tui/keytype.go @@ -34,8 +34,8 @@ func (ui KeyTypePage) Init() tea.Cmd { } func NewKeyTypePage(c *common.Common) KeyTypePage { - items := make([]list.Item, len(analyzers.AvailableAnalyzers)) - for i, analyzerType := range analyzers.AvailableAnalyzers { + items := make([]list.Item, len(analyzers.AvailableAnalyzers())) + for i, analyzerType := range analyzers.AvailableAnalyzers() { items[i] = KeyTypeItem(analyzerType) } delegate := list.NewDefaultDelegate() diff --git a/pkg/analyzer/tui/tui.go b/pkg/analyzer/tui/tui.go index c06f6411ac92..66954124b14d 100644 --- a/pkg/analyzer/tui/tui.go +++ b/pkg/analyzer/tui/tui.go @@ -32,7 +32,7 @@ func Run(keyType string) (string, *SecretInfo, error) { // If a keyType is provided, make sure it's in the list of AvailableAnalyzers. if keyType != "" { var found bool - for _, a := range analyzers.AvailableAnalyzers { + for _, a := range analyzers.AvailableAnalyzers() { if strings.EqualFold(a, keyType) { keyType = a found = true