Skip to content

Find, verify, and analyze leaked credentials

Use sane http client instead of retryable

Dustin Deckeree90ab344f88
diff --git a/pkg/detectors/circleci/circleci.go b/pkg/detectors/circleci/circleci.go
index 5fb9da4ad..865a1d598 100644
--- a/pkg/detectors/circleci/circleci.go
+++ b/pkg/detectors/circleci/circleci.go
@@ -42,7 +42,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
}
if verify {
- client := common.RetryableHttpClient()
+ client := common.SaneHttpClient()
// https://circleci.com/docs/api/#authentication
req, _ := http.NewRequestWithContext(ctx, "GET", "https://circleci.com/api/v2/me", nil)
req.Header.Add("Accept", "application/json;")
diff --git a/pkg/detectors/dropbox/dropbox.go b/pkg/detectors/dropbox/dropbox.go
index d3b5f6c00..922cdf77e 100644
--- a/pkg/detectors/dropbox/dropbox.go
+++ b/pkg/detectors/dropbox/dropbox.go
@@ -45,7 +45,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
baseURL := "https://api.dropboxapi.com/2/users/get_current_account"
- client := common.RetryableHttpClient()
+ client := common.SaneHttpClient()
req, _ := http.NewRequest("POST", baseURL, nil)
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", match[1]))
diff --git a/pkg/detectors/github/github.go b/pkg/detectors/github/github.go
index 45ebf9f9b..f30a6d64e 100644
--- a/pkg/detectors/github/github.go
+++ b/pkg/detectors/github/github.go
@@ -64,7 +64,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
}
if verify {
- client := common.RetryableHttpClient()
+ client := common.SaneHttpClient()
// https://developer.github.com/v3/users/#get-the-authenticated-user
req, _ := http.NewRequestWithContext(ctx, "GET", "https://api.github.com/user", nil)
req.Header.Add("Content-Type", "application/json; charset=utf-8")
diff --git a/pkg/detectors/github_old/github_old.go b/pkg/detectors/github_old/github_old.go
index 5abdf41ce..1bbc9a6fc 100644
--- a/pkg/detectors/github_old/github_old.go
+++ b/pkg/detectors/github_old/github_old.go
@@ -66,7 +66,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
}
if verify {
- client := common.RetryableHttpClient()
+ client := common.SaneHttpClient()
// https://developer.github.com/v3/users/#get-the-authenticated-user
req, _ := http.NewRequestWithContext(ctx, "GET", "https://api.github.com/user", nil)
req.Header.Add("Content-Type", "application/json; charset=utf-8")
diff --git a/pkg/detectors/gitlab/gitlab.go b/pkg/detectors/gitlab/gitlab.go
index 9e232eb38..cea05d9b0 100644
--- a/pkg/detectors/gitlab/gitlab.go
+++ b/pkg/detectors/gitlab/gitlab.go
@@ -50,7 +50,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
// of them contain data, we know we have a valid key, but if they all fail, we don't
baseURL := "https://gitlab.com/api/v4"
- client := common.RetryableHttpClient()
+ client := common.SaneHttpClient()
// test `read_user` scope
req, _ := http.NewRequest("GET", baseURL+"/user", nil)
diff --git a/pkg/detectors/gitlabv2/gitlab.go b/pkg/detectors/gitlabv2/gitlab.go
index 265c4bf73..c7b69a583 100644
--- a/pkg/detectors/gitlabv2/gitlab.go
+++ b/pkg/detectors/gitlabv2/gitlab.go
@@ -50,7 +50,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
// of them contain data, we know we have a valid key, but if they all fail, we don't
baseURL := "https://gitlab.com/api/v4"
- client := common.RetryableHttpClient()
+ client := common.SaneHttpClient()
// test `read_user` scope
req, _ := http.NewRequest("GET", baseURL+"/user", nil)
diff --git a/pkg/detectors/jdbc/jdbc.go b/pkg/detectors/jdbc/jdbc.go
index d9be8e8d1..385bb8b50 100644
--- a/pkg/detectors/jdbc/jdbc.go
+++ b/pkg/detectors/jdbc/jdbc.go
@@ -48,7 +48,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
if verify {
//TODO can this be verified? Possibly. Could triage verification to other DBMS strings
s.Verified = false
- // client := common.RetryableHttpClient()
+ // client := common.SaneHttpClient()
// req, _ := http.NewRequestWithContext(ctx, "GET", "https://jdbcci.com/api/v2/me", nil)
// req.Header.Add("Accept", "application/json;")
// req.Header.Add("Jdbc-Token", token)
diff --git a/pkg/detectors/mailboxlayer/mailboxlayer.go b/pkg/detectors/mailboxlayer/mailboxlayer.go
index 829fed70b..48f1c2744 100644
--- a/pkg/detectors/mailboxlayer/mailboxlayer.go
+++ b/pkg/detectors/mailboxlayer/mailboxlayer.go
@@ -21,7 +21,7 @@ type Scanner struct{}
var _ detectors.Detector = (*Scanner)(nil)
var (
- client = common.RetryableHttpClient()
+ client = common.SaneHttpClient()
//Make sure that your group is surrounded in boundry characters such as below to reduce false positives
keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"mailboxlayer"}) + `\b([a-z0-9]{32})\b`)
diff --git a/pkg/detectors/mailchimp/mailchimp.go b/pkg/detectors/mailchimp/mailchimp.go
index 2e1ec6131..9eca6f3d9 100644
--- a/pkg/detectors/mailchimp/mailchimp.go
+++ b/pkg/detectors/mailchimp/mailchimp.go
@@ -46,7 +46,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
if verify {
datacenter := strings.Split(match, "-")[1]
- client := common.RetryableHttpClient()
+ client := common.SaneHttpClient()
// https://mailchimp.com/developer/guides/marketing-api-conventions/
req, _ := http.NewRequest("GET", fmt.Sprintf("https://%s.api.mailchimp.com/3.0/", datacenter), nil)
req.SetBasicAuth("anystring", match)
diff --git a/pkg/detectors/okta/okta.go b/pkg/detectors/okta/okta.go
index 625592b95..f0270fbf3 100644
--- a/pkg/detectors/okta/okta.go
+++ b/pkg/detectors/okta/okta.go
@@ -58,7 +58,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", fmt.Sprintf("SSWS %s", token))
- resp, err := common.RetryableHttpClient().Do(req)
+ resp, err := common.SaneHttpClient().Do(req)
if err != nil {
return results, err
}
diff --git a/pkg/detectors/pivotaltracker/pivotaltracker.go b/pkg/detectors/pivotaltracker/pivotaltracker.go
index 6a86c268f..2de51bed1 100644
--- a/pkg/detectors/pivotaltracker/pivotaltracker.go
+++ b/pkg/detectors/pivotaltracker/pivotaltracker.go
@@ -48,7 +48,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
}
if verify {
- client := common.RetryableHttpClient()
+ client := common.SaneHttpClient()
// https://www.pivotaltracker.com/help/api/rest/v5#top
req, _ := http.NewRequestWithContext(ctx, "GET", "https://www.pivotaltracker.com/services/v5/me", nil)
req.Header.Add("Content-Type", "application/json; charset=utf-8")
diff --git a/pkg/detectors/sendgrid/sendgrid.go b/pkg/detectors/sendgrid/sendgrid.go
index 5c112b1bb..486afa887 100644
--- a/pkg/detectors/sendgrid/sendgrid.go
+++ b/pkg/detectors/sendgrid/sendgrid.go
@@ -19,7 +19,7 @@ type Scanner struct{}
var _ detectors.Detector = (*Scanner)(nil)
var (
- client = common.RetryableHttpClient()
+ client = common.SaneHttpClient()
keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"sendgrid"}) + `(SG\.[\w\-_]{20,24}\.[\w\-_]{39,50})\b`)
)
diff --git a/pkg/detectors/slack/slack.go b/pkg/detectors/slack/slack.go
index 4556ffb97..3565adb26 100644
--- a/pkg/detectors/slack/slack.go
+++ b/pkg/detectors/slack/slack.go
@@ -58,7 +58,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
Raw: []byte(token),
}
if verify {
- client := common.RetryableHttpClient()
+ client := common.SaneHttpClient()
req, _ := http.NewRequest("POST", verifyURL, nil)
req.Header.Add("Content-Type", "application/json; charset=utf-8")
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", token))
diff --git a/pkg/detectors/splunkobservabilitytoken/splunkobservabilitytoken.go b/pkg/detectors/splunkobservabilitytoken/splunkobservabilitytoken.go
index 8629054e3..0b68551ab 100644
--- a/pkg/detectors/splunkobservabilitytoken/splunkobservabilitytoken.go
+++ b/pkg/detectors/splunkobservabilitytoken/splunkobservabilitytoken.go
@@ -20,7 +20,7 @@ type Scanner struct{}
var _ detectors.Detector = (*Scanner)(nil)
var (
- client = common.RetryableHttpClient()
+ client = common.SaneHttpClient()
//Make sure that your group is surrounded in boundry characters such as below to reduce false positives
keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"splunk"}) + `\b([a-z0-9A-Z]{22})\b`)
diff --git a/pkg/detectors/square/square.go b/pkg/detectors/square/square.go
index e2f215f14..9e560ffef 100644
--- a/pkg/detectors/square/square.go
+++ b/pkg/detectors/square/square.go
@@ -55,7 +55,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
// 403 will be issued if the scope is wrong but the key is correct
baseURL := "https://connect.squareupsandbox.com/v2/merchants"
- client := common.RetryableHttpClient()
+ client := common.SaneHttpClient()
// test `merchants` scope - its commonly allowed and low sensitivity
req, _ := http.NewRequestWithContext(ctx, "GET", baseURL, nil)
diff --git a/pkg/detectors/squareapp/squareapp.go b/pkg/detectors/squareapp/squareapp.go
index fe2caedca..c4fb21777 100644
--- a/pkg/detectors/squareapp/squareapp.go
+++ b/pkg/detectors/squareapp/squareapp.go
@@ -56,7 +56,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
if verify {
baseURL := "https://connect.squareupsandbox.com/oauth2/revoke"
- client := common.RetryableHttpClient()
+ client := common.SaneHttpClient()
reqData, err := json.Marshal(map[string]string{
"client_id": match,
"access_token": "fakeTruffleHogAccessTokenForVerification",
diff --git a/pkg/detectors/stripe/stripe.go b/pkg/detectors/stripe/stripe.go
index af9c6b1af..afff43b02 100644
--- a/pkg/detectors/stripe/stripe.go
+++ b/pkg/detectors/stripe/stripe.go
@@ -46,7 +46,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
baseURL := "https://api.stripe.com/v1/charges"
- client := common.RetryableHttpClient()
+ client := common.SaneHttpClient()
// test `read_user` scope
req, _ := http.NewRequestWithContext(ctx, "GET", baseURL, nil)
diff --git a/pkg/detectors/twilio/twilio.go b/pkg/detectors/twilio/twilio.go
index 403f02db0..5abc71f61 100644
--- a/pkg/detectors/twilio/twilio.go
+++ b/pkg/detectors/twilio/twilio.go
@@ -52,7 +52,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
}
if verify {
- client := common.RetryableHttpClient()
+ client := common.SaneHttpClient()
for _, key := range keyMatches {
form := url.Values{}
diff --git a/pkg/detectors/zeplin/zeplin.go b/pkg/detectors/zeplin/zeplin.go
index 992836911..fbd28af00 100644
--- a/pkg/detectors/zeplin/zeplin.go
+++ b/pkg/detectors/zeplin/zeplin.go
@@ -21,7 +21,7 @@ type Scanner struct{}
var _ detectors.Detector = (*Scanner)(nil)
var (
- client = common.RetryableHttpClient()
+ client = common.SaneHttpClient()
//Make sure that your group is surrounded in boundry characters such as below to reduce false positives
keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"zeplin"}) + `\b([a-zA-Z0-9-.]{350,400})\b`)