From 907ac64fd42b18dab2ceba2fda39834d3f8ba7e3 Mon Sep 17 00:00:00 2001 From: Shahzad Haider <76992801+shahzadhaider1@users.noreply.github.com> Date: Thu, 17 Jul 2025 11:12:55 +0500 Subject: [PATCH] Salesforce Refresh Token Detector (#4295) * salesforce refresh token init * added pattern tests for salesforce refresh token detector * added integration tests for salesforce refresh token detector * code cleaned --------- Co-authored-by: Kashif Khan <70996046+kashifkhan0771@users.noreply.github.com> --- .../salesforcerefreshtoken.go | 153 ++++++++++++++ ...salesforcerefreshtoken_integration_test.go | 198 ++++++++++++++++++ .../salesforcerefreshtoken_test.go | 131 ++++++++++++ pkg/engine/defaults/defaults.go | 2 + pkg/pb/detectorspb/detectors.pb.go | 17 +- proto/detectors.proto | 1 + 6 files changed, 496 insertions(+), 6 deletions(-) create mode 100644 pkg/detectors/salesforcerefreshtoken/salesforcerefreshtoken.go create mode 100644 pkg/detectors/salesforcerefreshtoken/salesforcerefreshtoken_integration_test.go create mode 100644 pkg/detectors/salesforcerefreshtoken/salesforcerefreshtoken_test.go diff --git a/pkg/detectors/salesforcerefreshtoken/salesforcerefreshtoken.go b/pkg/detectors/salesforcerefreshtoken/salesforcerefreshtoken.go new file mode 100644 index 000000000..47b9278d7 --- /dev/null +++ b/pkg/detectors/salesforcerefreshtoken/salesforcerefreshtoken.go @@ -0,0 +1,153 @@ +package salesforcerefreshtoken + +import ( + "context" + "encoding/json" + "fmt" + "io" + "net/http" + "net/url" + "strings" + + regexp "github.com/wasilibs/go-re2" + + "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 { + client *http.Client +} + +var ( + // Ensure the Scanner satisfies the interface at compile time. + _ detectors.Detector = (*Scanner)(nil) + defaultClient = common.SaneHttpClient() + + // Make sure that your group is surrounded in boundary characters such as below to reduce false positives. + refreshTokenPat = regexp.MustCompile(`(?i)\b(5AEP861[a-zA-Z0-9._=]{80,})\b`) + consumerKeyPat = regexp.MustCompile(`\b(3MVG9[0-9a-zA-Z._+/=]{80,251})`) + consumerSecretPat = regexp.MustCompile(detectors.PrefixRegex([]string{"salesforce", "consumer", "secret"}) + `\b([A-Za-z0-9+/=.]{64}|[0-9]{19})\b`) +) + +// 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{"salesforce", "5AEP861", "3MVG9"} +} + +func (s Scanner) getClient() *http.Client { + if s.client != nil { + return s.client + } + + return defaultClient +} + +func (s Scanner) Type() detectorspb.DetectorType { + return detectorspb.DetectorType_SalesforceRefreshToken +} + +func (s Scanner) Description() string { + return "Salesforce is a customer relationship management (CRM) platform that provides a suite of applications and APIs. OAuth 2.0 refresh tokens are long-lived credentials that allow applications to obtain new access tokens without requiring user interaction. They enable continuous access to an organization's data and must be handled securely." +} + +// FromData will find and optionally verify Salesforceoauth2 refresh token 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) + + uniqueTokenMatches, uniqueKeyMatches, uniqueSecretMatches := make(map[string]struct{}), make(map[string]struct{}), make(map[string]struct{}) + for _, match := range refreshTokenPat.FindAllStringSubmatch(dataStr, -1) { + uniqueTokenMatches[match[1]] = struct{}{} + } + + for _, match := range consumerKeyPat.FindAllStringSubmatch(dataStr, -1) { + uniqueKeyMatches[match[1]] = struct{}{} + } + + for _, match := range consumerSecretPat.FindAllStringSubmatch(dataStr, -1) { + uniqueSecretMatches[match[1]] = struct{}{} + } + + for refreshToken := range uniqueTokenMatches { + for key := range uniqueKeyMatches { + for secret := range uniqueSecretMatches { + s1 := detectors.Result{ + DetectorType: detectorspb.DetectorType_SalesforceRefreshToken, + Raw: []byte(refreshToken), + RawV2: fmt.Appendf([]byte{}, "%s:%s:%s", refreshToken, key, secret), + } + + if verify { + isVerified, verificationErr := s.verifyMatch(ctx, s.getClient(), refreshToken, key, secret) + s1.Verified = isVerified + if verificationErr != nil { + s1.SetVerificationError(verificationErr, secret) + } + } + + results = append(results, s1) + } + } + } + + return +} + +// verifyMatch attempts to validate a Salesforce Refresh Token. +func (s Scanner) verifyMatch(ctx context.Context, client *http.Client, refreshToken, key, secret string) (bool, error) { + form := url.Values{} + form.Set("token", refreshToken) + form.Set("client_id", key) + form.Set("client_secret", secret) + + req, err := http.NewRequestWithContext(ctx, http.MethodPost, "https://login.salesforce.com/services/oauth2/introspect", + strings.NewReader(form.Encode())) + if err != nil { + return false, fmt.Errorf("failed to create request: %w", err) + } + + req.Header.Set("Content-Type", "application/x-www-form-urlencoded") + resp, err := client.Do(req) + if err != nil { + return false, fmt.Errorf("failed to perform request: %w", err) + } + defer func() { + _, _ = io.Copy(io.Discard, resp.Body) + _ = resp.Body.Close() + }() + + switch resp.StatusCode { + case http.StatusOK: + bodyBytes, err := io.ReadAll(resp.Body) + if err != nil { + return false, fmt.Errorf("failed to read error response body: %w", err) + } + var apiResp introspectAPIResponse + if err := json.Unmarshal(bodyBytes, &apiResp); err != nil { + return false, fmt.Errorf("failed to unmarshal error response: %w (body: %s)", err, string(bodyBytes)) + } + + if !apiResp.Active { + return false, nil + } + return true, nil + + case http.StatusBadRequest: + // Salesforce returns a 400 Bad Request if the consumer key/secret are valid, but the refresh token is invalid or missing + return false, nil + + case http.StatusUnauthorized: + // Salesforce returns a 401 Unauthorized if the consumer key/secret are invalid. + // This means that a 401 can also occur when the refresh token is valid but the consumer key or secret is incorrect. + return false, fmt.Errorf("unauthorized: invalid client credentials") + + default: + return false, fmt.Errorf("unexpected status code: %d", resp.StatusCode) + } +} + +type introspectAPIResponse struct { + Active bool `json:"active"` +} diff --git a/pkg/detectors/salesforcerefreshtoken/salesforcerefreshtoken_integration_test.go b/pkg/detectors/salesforcerefreshtoken/salesforcerefreshtoken_integration_test.go new file mode 100644 index 000000000..87c51e33b --- /dev/null +++ b/pkg/detectors/salesforcerefreshtoken/salesforcerefreshtoken_integration_test.go @@ -0,0 +1,198 @@ +//go:build detectors +// +build detectors + +package salesforcerefreshtoken + +import ( + "context" + "fmt" + "testing" + "time" + + "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/pb/detectorspb" +) + +func TestSalesforcerefreshtoken_FromChunk(t *testing.T) { + ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) + defer cancel() + + testSecrets, err := common.GetSecret(ctx, "trufflehog-testing", "detectors6") + if err != nil { + t.Fatalf("could not get test secrets from GCP: %s", err) + } + refreshToken := testSecrets.MustGetField("SALESFORCE_REFRESH_TOKEN") + consumerKey := testSecrets.MustGetField("SALESFORCE_REFRESH_TOKEN_KEY") + consumerSecret := testSecrets.MustGetField("SALESFORCE_REFRESH_TOKEN_SECRET") + inactiveSecret := testSecrets.MustGetField("SALESFORCE_REFRESH_TOKEN_INACTIVE_SECRET") + + type args struct { + ctx context.Context + data []byte + verify bool + } + tests := []struct { + name string + s Scanner + args args + want []detectors.Result + wantErr bool + wantVerificationErr bool + }{ + { + name: "found one valid trio, verified", + s: Scanner{}, + args: args{ + ctx: context.Background(), + data: []byte(fmt.Sprintf("refresh_token: %s, key: %s, secret: %s", refreshToken, consumerKey, consumerSecret)), + verify: true, + }, + want: []detectors.Result{ + { + DetectorType: detectorspb.DetectorType_SalesforceRefreshToken, + Verified: true, + }, + }, + wantErr: false, + wantVerificationErr: false, + }, + { + name: "found one invalid trio, unverified", + s: Scanner{}, + args: args{ + ctx: context.Background(), + data: []byte(fmt.Sprintf("refresh_token: %s, key: %s, secret: %s", refreshToken, consumerKey, inactiveSecret)), + verify: true, + }, + want: []detectors.Result{ + { + DetectorType: detectorspb.DetectorType_SalesforceRefreshToken, + Verified: false, + }, + }, + wantErr: false, + wantVerificationErr: true, // Verification fails because the credentials are invalid and we can't verify the refresh token. + }, + { + name: "multiple findings, one verified", + s: Scanner{}, + args: args{ + ctx: context.Background(), + data: []byte(fmt.Sprintf(` + refresh_token: %s, key: %s, valid_secret: %s, + invalid_refresh_token: 5Aep861eN26Sp9j0R5QPjh0AAAABBBBCCCCjcNqfo5kVBplkpP5tzyWXyVGAivx26AAAABBBBjYE133BBBBAAAA`, + refreshToken, consumerKey, consumerSecret)), + verify: true, + }, + want: []detectors.Result{ + { + DetectorType: detectorspb.DetectorType_SalesforceRefreshToken, + Verified: true, // The valid refresh token combination + }, + { + DetectorType: detectorspb.DetectorType_SalesforceRefreshToken, + Verified: false, // The invalid refresh token combination + }, + }, + wantErr: false, + wantVerificationErr: false, + }, + { + name: "not found (missing a component)", + s: Scanner{}, + args: args{ + ctx: context.Background(), + data: []byte(fmt.Sprintf("key: %s, secret: %s", consumerKey, consumerSecret)), // No refresh token + verify: true, + }, + want: nil, + wantErr: false, + wantVerificationErr: false, + }, + { + name: "found, would be verified if not for timeout", + s: Scanner{client: common.SaneHttpClientTimeOut(1 * time.Microsecond)}, + args: args{ + ctx: context.Background(), + data: []byte(fmt.Sprintf("refresh_token: %s, key: %s, secret: %s", refreshToken, consumerKey, consumerSecret)), + verify: true, + }, + want: []detectors.Result{ + { + DetectorType: detectorspb.DetectorType_SalesforceRefreshToken, + Verified: false, + }, + }, + wantErr: false, + wantVerificationErr: true, + }, + { + name: "found, unexpected api response", + s: Scanner{client: common.ConstantResponseHttpClient(404, "")}, + args: args{ + ctx: context.Background(), + data: []byte(fmt.Sprintf("refresh_token: %s, key: %s, secret: %s", refreshToken, consumerKey, consumerSecret)), + verify: true, + }, + want: []detectors.Result{ + { + DetectorType: detectorspb.DetectorType_SalesforceRefreshToken, + Verified: false, + }, + }, + wantErr: false, + wantVerificationErr: true, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := tt.s.FromData(tt.args.ctx, tt.args.verify, tt.args.data) + if (err != nil) != tt.wantErr { + t.Errorf("FromData() error = %v, wantErr %v", err, tt.wantErr) + return + } + + // Since the order of results can vary with maps, we use a more robust comparison. + // This checks that for every `want` result, there is a matching `got` result. + opts := []cmp.Option{ + cmpopts.IgnoreFields(detectors.Result{}, "Raw", "RawV2", "verificationError", "ExtraData", "VerificationFromCache", "primarySecret"), + cmpopts.SortSlices(func(a, b detectors.Result) bool { return a.Verified }), + } + if diff := cmp.Diff(tt.want, got, opts...); diff != "" { + t.Errorf("FromData() results mismatch (-want +got):\n%s", diff) + } + + // Also check that verification errors match expectations across all results. + var gotErr bool + for _, r := range got { + if r.VerificationError() != nil { + gotErr = true + break + } + } + if gotErr != tt.wantVerificationErr { + t.Errorf("wantVerificationErr = %v, but got an error state of %v", tt.wantVerificationErr, gotErr) + } + }) + } +} + +func BenchmarkFromData(benchmark *testing.B) { + ctx := context.Background() + s := Scanner{} + for name, data := range detectors.MustGetBenchmarkData() { + benchmark.Run(name, func(b *testing.B) { + b.ResetTimer() + for n := 0; n < b.N; n++ { + _, err := s.FromData(ctx, false, data) + if err != nil { + b.Fatal(err) + } + } + }) + } +} diff --git a/pkg/detectors/salesforcerefreshtoken/salesforcerefreshtoken_test.go b/pkg/detectors/salesforcerefreshtoken/salesforcerefreshtoken_test.go new file mode 100644 index 000000000..629a154ed --- /dev/null +++ b/pkg/detectors/salesforcerefreshtoken/salesforcerefreshtoken_test.go @@ -0,0 +1,131 @@ +package salesforcerefreshtoken + +import ( + "context" + "testing" + + "github.com/google/go-cmp/cmp" + + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" + "github.com/trufflesecurity/trufflehog/v3/pkg/engine/ahocorasick" +) + +func TestSalesforcerefreshtoken_Pattern(t *testing.T) { + d := Scanner{} + ahoCorasickCore := ahocorasick.NewAhoCorasickCore([]detectors.Detector{d}) + + tests := []struct { + name string + input string + want []string + }{ + { + name: "simple case: one of each component", + input: ` + salesforce_refresh_token = "5Aep861eN26Sp9j0R5QPjh0AAAABBBBCCCCjcNqfo5kVBplkpP5tzyWXyVGAivx26AAAABBBBjYE133BBBBAAAA" + salesforce_key = "3MVG9dBDux2v1sLoreCoilvmnP337XNeiV01JFJ8uAAVVyH5qX0NPaa0d54El.Wkce6JTB1LmsxhzVaaa.VZ7" + salesforce_secret = "A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2" + `, + want: []string{ + "5Aep861eN26Sp9j0R5QPjh0AAAABBBBCCCCjcNqfo5kVBplkpP5tzyWXyVGAivx26AAAABBBBjYE133BBBBAAAA:3MVG9dBDux2v1sLoreCoilvmnP337XNeiV01JFJ8uAAVVyH5qX0NPaa0d54El.Wkce6JTB1LmsxhzVaaa.VZ7:A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2", + }, + }, + { + name: "combinatorial test: multiple keys, one refresh token and secret", + input: ` + salesforce_refresh_token = "5Aep861eN26Sp9j0R5QPjh0AAAABBBBCCCCjcNqfo5kVBplkpP5tzyWXyVGAivx26AAAABBBBjYE133BBBBAAAA" + salesforce_key1 = "3MVG9dBDux2v1sLoreCoilvmnP337XNeiV01JFJ8uAAVVyH5qX0NPaa0d54El.Wkce6JTB1LmsxhzVaaa.VZ7" + salesforce_key2 = "3MVG9dBDux2v1sLoreCoilvmnP337XNeiV01JFJ8uAAVVyH5qX0NPaa0d54ElfWkce6JTB1LmsxhzVaaaaVZ8" + salesforce_secret = "A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2" + `, + want: []string{ + "5Aep861eN26Sp9j0R5QPjh0AAAABBBBCCCCjcNqfo5kVBplkpP5tzyWXyVGAivx26AAAABBBBjYE133BBBBAAAA:3MVG9dBDux2v1sLoreCoilvmnP337XNeiV01JFJ8uAAVVyH5qX0NPaa0d54El.Wkce6JTB1LmsxhzVaaa.VZ7:A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2", + "5Aep861eN26Sp9j0R5QPjh0AAAABBBBCCCCjcNqfo5kVBplkpP5tzyWXyVGAivx26AAAABBBBjYE133BBBBAAAA:3MVG9dBDux2v1sLoreCoilvmnP337XNeiV01JFJ8uAAVVyH5qX0NPaa0d54ElfWkce6JTB1LmsxhzVaaaaVZ8:A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2", + }, + }, + { + name: "combinatorial test: two refresh tokens, two keys, one secret", + input: ` + salesforce_refresh_token1 = "5Aep861eN26Sp9j0R5QPjh0AAAABBBBCCCCjcNqfo5kVBplkpP5tzyWXyVGAivx26AAAABBBBjYE133BBBBDDDD" + salesforce_refresh_token2 = "5Aep861eN26Sp9j0R5QPjh0AAAABBBBCCCCjcNqfo5kVBplkpP5tzyWXyVGAivx26AAAABBBBjYE133BBBBEEEE" + salesforce_key1 = "3MVG9dBDux2v1sLoreCoilvmnP337XNeiV01JFJ8uAAVVyH5qX0NPaa0d54El.Wkce6JTB1LmsxhzVaaa.VZ7" + salesforce_key2 = "3MVG9dBDux2v1sLoreCoilvmnP337XNeiV01JFJ8uAAVVyH5qX0NPaa0d54ElfWkce6JTB1LmsxhzVaaaaVZ8" + salesforce_secret = "A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2" + `, + want: []string{ + "5Aep861eN26Sp9j0R5QPjh0AAAABBBBCCCCjcNqfo5kVBplkpP5tzyWXyVGAivx26AAAABBBBjYE133BBBBDDDD:3MVG9dBDux2v1sLoreCoilvmnP337XNeiV01JFJ8uAAVVyH5qX0NPaa0d54El.Wkce6JTB1LmsxhzVaaa.VZ7:A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2", + "5Aep861eN26Sp9j0R5QPjh0AAAABBBBCCCCjcNqfo5kVBplkpP5tzyWXyVGAivx26AAAABBBBjYE133BBBBDDDD:3MVG9dBDux2v1sLoreCoilvmnP337XNeiV01JFJ8uAAVVyH5qX0NPaa0d54ElfWkce6JTB1LmsxhzVaaaaVZ8:A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2", + "5Aep861eN26Sp9j0R5QPjh0AAAABBBBCCCCjcNqfo5kVBplkpP5tzyWXyVGAivx26AAAABBBBjYE133BBBBEEEE:3MVG9dBDux2v1sLoreCoilvmnP337XNeiV01JFJ8uAAVVyH5qX0NPaa0d54El.Wkce6JTB1LmsxhzVaaa.VZ7:A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2", + "5Aep861eN26Sp9j0R5QPjh0AAAABBBBCCCCjcNqfo5kVBplkpP5tzyWXyVGAivx26AAAABBBBjYE133BBBBEEEE:3MVG9dBDux2v1sLoreCoilvmnP337XNeiV01JFJ8uAAVVyH5qX0NPaa0d54ElfWkce6JTB1LmsxhzVaaaaVZ8:A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2", + }, + }, + { + name: "negative case: invalid refresh token component", + input: `salesforce_refresh_token = "5Aep86111", salesforce_key = "3MVG9dBDux2v1sLoreCoilvmnP337XNeiV01JFJ8uAAVVyH5qX0NPaa0d54El.Wkce6JTB1LmsxhzVaaa.VZ7"`, + want: []string{}, + }, + { + name: "negative case: missing refresh token component", + input: `salesforce_key = "3MVG9dBDux2v1sLoreCoilvmnP337XNeiV01JFJ8uAAVVyH5qX0NPaa0d54El.Wkce6JTB1LmsxhzVaaa.VZ7"`, + want: []string{}, + }, + { + name: "negative case: missing secret component", + input: `salesforce_refresh_token = "5Aep861eN26Sp9j0R5QPjh0AAAABBBBCCCCjcNqfo5kVBplkpP5tzyWXyVGAivx26AAAABBBBjYE133BBBBEEEE", salesforce_key = "3MVG9dBDux2v1sLoreCoilvmnP337XNeiV01JFJ8uAAVVyH5qX0NPaa0d54El.Wkce6JTB1LmsxhzVaaa.VZ7"`, + want: []string{}, + }, + { + name: "negative case: invalid key format", + input: `salesforce_refresh_token = "5Aep861eN26Sp9j0R5QPjh0AAAABBBBCCCCjcNqfo5kVBplkpP5tzyWXyVGAivx26AAAABBBBjYE133BBBBEEEE", salesforce_key = "invalid-key-format", salesforce_secret = "A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2C3D4E5F6A1B2"`, + want: []string{}, + }, + { + name: "negative case: invalid secret format (too short)", + input: `salesforce_refresh_token = "5Aep861eN26Sp9j0R5QPjh0AAAABBBBCCCCjcNqfo5kVBplkpP5tzyWXyVGAivx26AAAABBBBjYE133BBBBEEEE", salesforce_key = "3MVG9dBDux2v1sLoreCoilvmnP337XNeiV01JFJ8uAAVVyH5qX0NPaa0d54El.Wkce6JTB1LmsxhzVaaa.VZ7", salesforce_secret = "ABCDEFG"`, + want: []string{}, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + matchedDetectors := ahoCorasickCore.FindDetectorMatches([]byte(test.input)) + if len(matchedDetectors) == 0 { + t.Errorf("keywords '%v' not matched by: %s", d.Keywords(), test.input) + return + } + + results, err := d.FromData(context.Background(), false, []byte(test.input)) + if err != nil { + t.Errorf("error = %v", err) + return + } + + if len(results) != len(test.want) { + if len(results) == 0 { + t.Errorf("did not receive result") + } else { + t.Errorf("expected %d results, only received %d", len(test.want), len(results)) + } + return + } + + actual := make(map[string]struct{}, len(results)) + for _, r := range results { + if len(r.RawV2) > 0 { + actual[string(r.RawV2)] = struct{}{} + } else { + actual[string(r.Raw)] = struct{}{} + } + } + + expected := make(map[string]struct{}, len(test.want)) + for _, v := range test.want { + expected[v] = struct{}{} + } + + if diff := cmp.Diff(expected, actual); diff != "" { + t.Errorf("%s diff: (-want +got)\n%s", test.name, diff) + } + }) + } +} diff --git a/pkg/engine/defaults/defaults.go b/pkg/engine/defaults/defaults.go index e32c7555b..99e8114ac 100644 --- a/pkg/engine/defaults/defaults.go +++ b/pkg/engine/defaults/defaults.go @@ -623,6 +623,7 @@ import ( "github.com/trufflesecurity/trufflehog/v3/pkg/detectors/salesflare" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors/salesforce" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors/salesforceoauth2" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors/salesforcerefreshtoken" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors/salesmate" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors/sanity" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors/satismeterprojectkey" @@ -1491,6 +1492,7 @@ func buildDetectorList() []detectors.Detector { &salesflare.Scanner{}, &salesforce.Scanner{}, &salesforceoauth2.Scanner{}, + &salesforcerefreshtoken.Scanner{}, &salesmate.Scanner{}, &sanity.Scanner{}, &satismeterprojectkey.Scanner{}, diff --git a/pkg/pb/detectorspb/detectors.pb.go b/pkg/pb/detectorspb/detectors.pb.go index 015788c21..3bb674f57 100644 --- a/pkg/pb/detectorspb/detectors.pb.go +++ b/pkg/pb/detectorspb/detectors.pb.go @@ -1137,6 +1137,7 @@ const ( DetectorType_LangSmith DetectorType = 1028 DetectorType_BitbucketAppPassword DetectorType = 1029 DetectorType_Hasura DetectorType = 1030 + DetectorType_SalesforceRefreshToken DetectorType = 1031 ) // Enum value maps for DetectorType. @@ -2169,6 +2170,7 @@ var ( 1028: "LangSmith", 1029: "BitbucketAppPassword", 1030: "Hasura", + 1031: "SalesforceRefreshToken", } DetectorType_value = map[string]int32{ "Alibaba": 0, @@ -3198,6 +3200,7 @@ var ( "LangSmith": 1028, "BitbucketAppPassword": 1029, "Hasura": 1030, + "SalesforceRefreshToken": 1031, } ) @@ -3651,7 +3654,7 @@ var file_detectors_proto_rawDesc = []byte{ 0x4c, 0x41, 0x49, 0x4e, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x42, 0x41, 0x53, 0x45, 0x36, 0x34, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x55, 0x54, 0x46, 0x31, 0x36, 0x10, 0x03, 0x12, 0x13, 0x0a, 0x0f, 0x45, 0x53, 0x43, 0x41, 0x50, 0x45, 0x44, 0x5f, 0x55, 0x4e, 0x49, 0x43, 0x4f, 0x44, 0x45, - 0x10, 0x04, 0x2a, 0x8a, 0x85, 0x01, 0x0a, 0x0c, 0x44, 0x65, 0x74, 0x65, 0x63, 0x74, 0x6f, 0x72, + 0x10, 0x04, 0x2a, 0xa7, 0x85, 0x01, 0x0a, 0x0c, 0x44, 0x65, 0x74, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x41, 0x6c, 0x69, 0x62, 0x61, 0x62, 0x61, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x41, 0x4d, 0x51, 0x50, 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x57, 0x53, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x7a, 0x75, 0x72, 0x65, 0x10, 0x03, 0x12, @@ -4716,11 +4719,13 @@ var file_detectors_proto_rawDesc = []byte{ 0x53, 0x6d, 0x69, 0x74, 0x68, 0x10, 0x84, 0x08, 0x12, 0x19, 0x0a, 0x14, 0x42, 0x69, 0x74, 0x62, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x41, 0x70, 0x70, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x10, 0x85, 0x08, 0x12, 0x0b, 0x0a, 0x06, 0x48, 0x61, 0x73, 0x75, 0x72, 0x61, 0x10, 0x86, 0x08, - 0x42, 0x3d, 0x5a, 0x3b, 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, 0x70, 0x62, 0x2f, 0x64, 0x65, 0x74, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x73, 0x70, 0x62, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x12, 0x1b, 0x0a, 0x16, 0x53, 0x61, 0x6c, 0x65, 0x73, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x52, 0x65, + 0x66, 0x72, 0x65, 0x73, 0x68, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x10, 0x87, 0x08, 0x42, 0x3d, 0x5a, + 0x3b, 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, 0x70, 0x62, + 0x2f, 0x64, 0x65, 0x74, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x73, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/proto/detectors.proto b/proto/detectors.proto index 615c3c455..bc170ea0e 100644 --- a/proto/detectors.proto +++ b/proto/detectors.proto @@ -1040,6 +1040,7 @@ enum DetectorType { LangSmith = 1028; BitbucketAppPassword = 1029; Hasura = 1030; + SalesforceRefreshToken = 1031; } message Result {