diff --git a/pkg/detectors/airbrakeprojectkey/airbrakeprojectkey.go b/pkg/detectors/airbrakeprojectkey/airbrakeprojectkey.go index ac9eeeb5f..97342081c 100644 --- a/pkg/detectors/airbrakeprojectkey/airbrakeprojectkey.go +++ b/pkg/detectors/airbrakeprojectkey/airbrakeprojectkey.go @@ -55,6 +55,9 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result Raw: []byte(resMatch), RawV2: []byte(resMatch + resIdMatch), } + s1.ExtraData = map[string]string{ + "rotation_guide": "https://howtorotate.com/docs/tutorials/airbrake/", + } if verify { payload := strings.NewReader(`{"environment":"production","username":"john","email":"john@smith.com","repository":"https://github.com/airbrake/airbrake","revision":"38748467ea579e7ae64f7815452307c9d05e05c5","version":"v2.0"}`) diff --git a/pkg/detectors/airbrakeuserkey/airbrakeuserkey.go b/pkg/detectors/airbrakeuserkey/airbrakeuserkey.go index 8718b311a..06e260696 100644 --- a/pkg/detectors/airbrakeuserkey/airbrakeuserkey.go +++ b/pkg/detectors/airbrakeuserkey/airbrakeuserkey.go @@ -45,6 +45,9 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result DetectorType: detectorspb.DetectorType_AirbrakeUserKey, Raw: []byte(resMatch), } + s1.ExtraData = map[string]string{ + "rotation_guide": "https://howtorotate.com/docs/tutorials/airbrake/", + } if verify { req, err := http.NewRequestWithContext(ctx, "GET", "https://api.airbrake.io/api/v4/projects?key="+resMatch, nil) diff --git a/pkg/detectors/aws/aws.go b/pkg/detectors/aws/aws.go index ab0a3a93a..0047f7611 100644 --- a/pkg/detectors/aws/aws.go +++ b/pkg/detectors/aws/aws.go @@ -206,6 +206,10 @@ func (s scanner) verifyMatch(ctx context.Context, resIDMatch, resSecretMatch str client = defaultVerificationClient } + extraData := map[string]string{ + "rotation_guide": "https://howtorotate.com/docs/tutorials/aws/", + } + res, err := client.Do(req) if err == nil { defer res.Body.Close() @@ -213,11 +217,9 @@ func (s scanner) verifyMatch(ctx context.Context, resIDMatch, resSecretMatch str identityInfo := identityRes{} err := json.NewDecoder(res.Body).Decode(&identityInfo) if err == nil { - extraData := map[string]string{ - "account": identityInfo.GetCallerIdentityResponse.GetCallerIdentityResult.Account, - "user_id": identityInfo.GetCallerIdentityResponse.GetCallerIdentityResult.UserID, - "arn": identityInfo.GetCallerIdentityResponse.GetCallerIdentityResult.Arn, - } + extraData["account"] = identityInfo.GetCallerIdentityResponse.GetCallerIdentityResult.Account + extraData["user_id"] = identityInfo.GetCallerIdentityResponse.GetCallerIdentityResult.UserID + extraData["arn"] = identityInfo.GetCallerIdentityResponse.GetCallerIdentityResult.Arn return true, extraData, nil } else { return false, nil, err diff --git a/pkg/detectors/azure/azure.go b/pkg/detectors/azure/azure.go index 57868cb5e..67a54e371 100644 --- a/pkg/detectors/azure/azure.go +++ b/pkg/detectors/azure/azure.go @@ -57,6 +57,10 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result RawV2: []byte(clientID[2] + clientSecret[2] + tenantID[2]), Redacted: clientID[2], } + // Set the RotationGuideURL in the ExtraData + s.ExtraData = map[string]string{ + "rotation_guide": "https://howtorotate.com/docs/tutorials/azure/", + } if verify { cred := auth.NewClientCredentialsConfig(clientID[2], clientSecret[2], tenantID[2]) diff --git a/pkg/detectors/gcp/gcp.go b/pkg/detectors/gcp/gcp.go index 5ec70a943..8771fc252 100644 --- a/pkg/detectors/gcp/gcp.go +++ b/pkg/detectors/gcp/gcp.go @@ -87,6 +87,11 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result RawV2: credBytes, Redacted: creds.ClientEmail, } + // Set the RotationGuideURL in the ExtraData + s.ExtraData = map[string]string{ + "rotation_guide": "https://howtorotate.com/docs/tutorials/gcp/", + "project": creds.ProjectID, + } if verify { credentials, err := google.CredentialsFromJSON(ctx, credBytes, "https://www.googleapis.com/auth/cloud-platform") diff --git a/pkg/detectors/github/github.go b/pkg/detectors/github/github.go index 82036681f..804f90c1b 100644 --- a/pkg/detectors/github/github.go +++ b/pkg/detectors/github/github.go @@ -68,6 +68,9 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result s1 := detectors.Result{ DetectorType: detectorspb.DetectorType_Github, Raw: []byte(token), + ExtraData: map[string]string{ + "rotation_guide": "https://howtorotate.com/docs/tutorials/github/", + }, } if verify { @@ -88,14 +91,12 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result res.Body.Close() if err == nil { s1.Verified = true - s1.ExtraData = map[string]string{ - "username": userResponse.Login, - "url": userResponse.UserURL, - "account_type": userResponse.Type, - "site_admin": fmt.Sprintf("%t", userResponse.SiteAdmin), - "name": userResponse.Name, - "company": userResponse.Company, - } + s1.ExtraData["username"] = userResponse.Login + s1.ExtraData["url"] = userResponse.UserURL + s1.ExtraData["account_type"] = userResponse.Type + s1.ExtraData["site_admin"] = fmt.Sprintf("%t", userResponse.SiteAdmin) + s1.ExtraData["name"] = userResponse.Name + s1.ExtraData["company"] = userResponse.Company } } } diff --git a/pkg/detectors/github_oauth2/github_oauth2.go b/pkg/detectors/github_oauth2/github_oauth2.go index 6cd6f27eb..a3678a397 100644 --- a/pkg/detectors/github_oauth2/github_oauth2.go +++ b/pkg/detectors/github_oauth2/github_oauth2.go @@ -54,6 +54,9 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result Raw: []byte(idMatch[1]), RawV2: []byte(idMatch[1] + secretMatch[1]), } + s1.ExtraData = map[string]string{ + "rotation_guide": "https://howtorotate.com/docs/tutorials/github/", + } config := &clientcredentials.Config{ ClientID: idMatch[1], diff --git a/pkg/detectors/github_old/github_old.go b/pkg/detectors/github_old/github_old.go index 21a4d0409..57dbeae7a 100644 --- a/pkg/detectors/github_old/github_old.go +++ b/pkg/detectors/github_old/github_old.go @@ -69,6 +69,9 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result DetectorType: detectorspb.DetectorType_Github, Raw: []byte(token), } + s1.ExtraData = map[string]string{ + "rotation_guide": "https://howtorotate.com/docs/tutorials/github/", + } if verify { client := common.SaneHttpClient() diff --git a/pkg/detectors/githubapp/githubapp.go b/pkg/detectors/githubapp/githubapp.go index b99bd91ae..ec1c07588 100644 --- a/pkg/detectors/githubapp/githubapp.go +++ b/pkg/detectors/githubapp/githubapp.go @@ -57,6 +57,9 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result DetectorType: detectorspb.DetectorType_GitHubApp, Raw: []byte(resMatch), } + s1.ExtraData = map[string]string{ + "rotation_guide": "https://howtorotate.com/docs/tutorials/github/", + } if verify { signKey, err := jwt.ParseRSAPrivateKeyFromPEM([]byte(resMatch)) diff --git a/pkg/detectors/gitlab/gitlab.go b/pkg/detectors/gitlab/gitlab.go index bf2aac0aa..1188f3df4 100644 --- a/pkg/detectors/gitlab/gitlab.go +++ b/pkg/detectors/gitlab/gitlab.go @@ -55,6 +55,9 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result DetectorType: detectorspb.DetectorType_Gitlab, Raw: []byte(resMatch), } + s1.ExtraData = map[string]string{ + "rotation_guide": "https://howtorotate.com/docs/tutorials/gitlab/", + } if verify { isVerified, verificationErr := s.verifyGitlab(ctx, resMatch) diff --git a/pkg/detectors/gitlabv2/gitlab_v2.go b/pkg/detectors/gitlabv2/gitlab_v2.go index dc8b237be..3084efa62 100644 --- a/pkg/detectors/gitlabv2/gitlab_v2.go +++ b/pkg/detectors/gitlabv2/gitlab_v2.go @@ -51,6 +51,9 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result DetectorType: detectorspb.DetectorType_Gitlab, Raw: []byte(resMatch), } + s1.ExtraData = map[string]string{ + "rotation_guide": "https://howtorotate.com/docs/tutorials/gitlab/", + } if verify { isVerified, verificationErr := s.verifyGitlab(ctx, resMatch) diff --git a/pkg/detectors/jiratoken/jiratoken.go b/pkg/detectors/jiratoken/jiratoken.go index 4c5472514..3e495773c 100644 --- a/pkg/detectors/jiratoken/jiratoken.go +++ b/pkg/detectors/jiratoken/jiratoken.go @@ -73,6 +73,9 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result Raw: []byte(resToken), RawV2: []byte(fmt.Sprintf("%s:%s:%s", resEmail, resToken, resDomain)), } + s1.ExtraData = map[string]string{ + "rotation_guide": "https://howtorotate.com/docs/tutorials/atlassian/", + } if verify { client := s.getClient() diff --git a/pkg/detectors/mailchimp/mailchimp.go b/pkg/detectors/mailchimp/mailchimp.go index 2535a15b2..a206b070a 100644 --- a/pkg/detectors/mailchimp/mailchimp.go +++ b/pkg/detectors/mailchimp/mailchimp.go @@ -42,6 +42,9 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result DetectorType: detectorspb.DetectorType_Mailchimp, Raw: []byte(match), } + s.ExtraData = map[string]string{ + "rotation_guide": "https://howtorotate.com/docs/tutorials/mailchimp/", + } if verify { datacenter := strings.Split(match, "-")[1] diff --git a/pkg/detectors/microsoftteamswebhook/microsoftteamswebhook.go b/pkg/detectors/microsoftteamswebhook/microsoftteamswebhook.go index d9deb9f9e..5047d0bb0 100644 --- a/pkg/detectors/microsoftteamswebhook/microsoftteamswebhook.go +++ b/pkg/detectors/microsoftteamswebhook/microsoftteamswebhook.go @@ -50,6 +50,9 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result DetectorType: detectorspb.DetectorType_MicrosoftTeamsWebhook, Raw: []byte(resMatch), } + s1.ExtraData = map[string]string{ + "rotation_guide": "https://howtorotate.com/docs/tutorials/microsoftteams/", + } if verify { client := s.client diff --git a/pkg/detectors/mongodb/mongodb.go b/pkg/detectors/mongodb/mongodb.go index a9832123e..a98d4dbfe 100644 --- a/pkg/detectors/mongodb/mongodb.go +++ b/pkg/detectors/mongodb/mongodb.go @@ -2,8 +2,6 @@ package mongodb import ( "context" - "go.mongodb.org/mongo-driver/x/mongo/driver/auth" - "go.mongodb.org/mongo-driver/x/mongo/driver/topology" "regexp" "strings" "time" @@ -11,6 +9,8 @@ import ( "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/mongo/readpref" + "go.mongodb.org/mongo-driver/x/mongo/driver/auth" + "go.mongodb.org/mongo-driver/x/mongo/driver/topology" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" @@ -49,6 +49,9 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result DetectorType: detectorspb.DetectorType_MongoDB, Raw: []byte(resMatch), } + s1.ExtraData = map[string]string{ + "rotation_guide": "https://howtorotate.com/docs/tutorials/mongo/", + } if verify { timeout := s.timeout diff --git a/pkg/detectors/netlify/netlify.go b/pkg/detectors/netlify/netlify.go index 7530501f3..a0c75a465 100644 --- a/pkg/detectors/netlify/netlify.go +++ b/pkg/detectors/netlify/netlify.go @@ -45,6 +45,9 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result DetectorType: detectorspb.DetectorType_Netlify, Raw: []byte(resMatch), } + s1.ExtraData = map[string]string{ + "rotation_guide": "https://howtorotate.com/docs/tutorials/netlify/", + } if verify { req, err := http.NewRequestWithContext(ctx, "GET", "https://api.netlify.com/api/v1/sites", nil) diff --git a/pkg/detectors/npmtoken/npmtoken.go b/pkg/detectors/npmtoken/npmtoken.go index 12bcad23f..2a624045f 100644 --- a/pkg/detectors/npmtoken/npmtoken.go +++ b/pkg/detectors/npmtoken/npmtoken.go @@ -47,6 +47,9 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result DetectorType: detectorspb.DetectorType_NpmToken, Raw: []byte(resMatch), } + s1.ExtraData = map[string]string{ + "rotation_guide": "https://howtorotate.com/docs/tutorials/npm/", + } if verify { req, err := http.NewRequestWithContext(ctx, "GET", "https://registry.npmjs.org/-/whoami", nil) diff --git a/pkg/detectors/npmtokenv2/npmtokenv2.go b/pkg/detectors/npmtokenv2/npmtokenv2.go index 40e2fdf6a..56b2ef036 100644 --- a/pkg/detectors/npmtokenv2/npmtokenv2.go +++ b/pkg/detectors/npmtokenv2/npmtokenv2.go @@ -48,6 +48,9 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result DetectorType: detectorspb.DetectorType_NpmToken, Raw: []byte(resMatch), } + s1.ExtraData = map[string]string{ + "rotation_guide": "https://howtorotate.com/docs/tutorials/npm/", + } if verify { req, err := http.NewRequestWithContext(ctx, "GET", "https://registry.npmjs.org/-/whoami", nil) diff --git a/pkg/detectors/sendbird/sendbird.go b/pkg/detectors/sendbird/sendbird.go index 4963469c4..f632083a6 100644 --- a/pkg/detectors/sendbird/sendbird.go +++ b/pkg/detectors/sendbird/sendbird.go @@ -61,6 +61,9 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result DetectorType: detectorspb.DetectorType_Sendbird, Raw: []byte(resMatch), } + s1.ExtraData = map[string]string{ + "rotation_guide": "https://howtorotate.com/docs/tutorials/sendbird/", + } if verify { req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("https://api-%s.sendbird.com/v3/users", resAppIdMatch), nil) diff --git a/pkg/detectors/sendgrid/sendgrid.go b/pkg/detectors/sendgrid/sendgrid.go index 0a4045b7b..9760cffec 100644 --- a/pkg/detectors/sendgrid/sendgrid.go +++ b/pkg/detectors/sendgrid/sendgrid.go @@ -48,6 +48,9 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result DetectorType: detectorspb.DetectorType_SendGrid, Raw: []byte(res), } + s1.ExtraData = map[string]string{ + "rotation_guide": "https://howtorotate.com/docs/tutorials/sendgrid/", + } if verify { // there are a few endpoints we can check, but templates seems the least sensitive. diff --git a/pkg/detectors/slack/slack.go b/pkg/detectors/slack/slack.go index 2f03cc353..9e105bb86 100644 --- a/pkg/detectors/slack/slack.go +++ b/pkg/detectors/slack/slack.go @@ -60,6 +60,9 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result DetectorType: detectorspb.DetectorType_Slack, Raw: []byte(token), } + s1.ExtraData = map[string]string{ + "rotation_guide": "https://howtorotate.com/docs/tutorials/slack/", + } if verify { client := s.client if s.client == nil { diff --git a/pkg/detectors/slackwebhook/slackwebhook.go b/pkg/detectors/slackwebhook/slackwebhook.go index ed05c6d15..16bf24f0f 100644 --- a/pkg/detectors/slackwebhook/slackwebhook.go +++ b/pkg/detectors/slackwebhook/slackwebhook.go @@ -49,6 +49,9 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result DetectorType: detectorspb.DetectorType_SlackWebhook, Raw: []byte(resMatch), } + s1.ExtraData = map[string]string{ + "rotation_guide": "https://howtorotate.com/docs/tutorials/slack-webhook/", + } if verify { diff --git a/pkg/detectors/square/square.go b/pkg/detectors/square/square.go index f1ca436a0..481ddb9ff 100644 --- a/pkg/detectors/square/square.go +++ b/pkg/detectors/square/square.go @@ -49,6 +49,9 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result DetectorType: detectorspb.DetectorType_Square, Raw: []byte(res), } + s.ExtraData = map[string]string{ + "rotation_guide": "https://howtorotate.com/docs/tutorials/square/", + } if verify { // there are a few endpoints we can check, but templates seems the least sensitive. diff --git a/pkg/detectors/stripe/stripe.go b/pkg/detectors/stripe/stripe.go index 753ffad54..98c3a7682 100644 --- a/pkg/detectors/stripe/stripe.go +++ b/pkg/detectors/stripe/stripe.go @@ -40,6 +40,9 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result DetectorType: detectorspb.DetectorType_Stripe, Raw: []byte(match), } + s.ExtraData = map[string]string{ + "rotation_guide": "https://howtorotate.com/docs/tutorials/stripe/", + } if verify { diff --git a/pkg/detectors/twilio/twilio.go b/pkg/detectors/twilio/twilio.go index 062364935..7a18c6780 100644 --- a/pkg/detectors/twilio/twilio.go +++ b/pkg/detectors/twilio/twilio.go @@ -54,6 +54,10 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result Redacted: sid, } + s1.ExtraData = map[string]string{ + "rotation_guide": "https://howtorotate.com/docs/tutorials/twilio/", + } + if verify { client = s.client if client == nil {