Skip to content

Find, verify, and analyze leaked credentials

Removed unnecessary keyword (#4258)

Kashif Khandb9b4a927818
diff --git a/pkg/detectors/godaddy/v1/godaddy.go b/pkg/detectors/godaddy/v1/godaddy.go
index 1901f14fd..8e78ad1d2 100644
--- a/pkg/detectors/godaddy/v1/godaddy.go
+++ b/pkg/detectors/godaddy/v1/godaddy.go
@@ -25,9 +25,9 @@ var (
defaultClient = common.SaneHttpClient()
// the key for the GoDaddy OTE environment is a 37-character alphanumeric string that may include underscores.
- keyPattern = regexp.MustCompile(detectors.PrefixRegex([]string{"godaddy", "ote"}) + common.BuildRegex("a-zA-Z0-9", "_", 37))
+ keyPattern = regexp.MustCompile(detectors.PrefixRegex([]string{"godaddy"}) + common.BuildRegex("a-zA-Z0-9", "_", 37))
// the secret for the GoDaddy OTE environment is a 22-character alphanumeric string.
- secretPattern = regexp.MustCompile(detectors.PrefixRegex([]string{"godaddy", "ote"}) + common.BuildRegex("a-zA-Z0-9", "", 22))
+ secretPattern = regexp.MustCompile(detectors.PrefixRegex([]string{"godaddy"}) + common.BuildRegex("a-zA-Z0-9", "", 22))
// ote environment
ote = "api.ote-godaddy.com"
@@ -46,7 +46,7 @@ func (s *Scanner) Version() int { return 1 }
// 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{"godaddy", "ote"}
+ return []string{"godaddy"}
}
func (s Scanner) Description() string {
@@ -88,10 +88,8 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
result.Verified = isVerified
result.SetVerificationError(verificationErr, secret)
- // in case of successful verification add the enviorement name in extradata to let user know which env this secret belong to.
- if isVerified {
- result.ExtraData["Environment"] = "OTE"
- }
+ // add the env name in extradata to let user know which env this secret belong to.
+ result.ExtraData["Environment"] = "OTE"
}
results = append(results, result)
diff --git a/pkg/detectors/godaddy/v2/godaddy.go b/pkg/detectors/godaddy/v2/godaddy.go
index 56e608705..1d23ea1ce 100644
--- a/pkg/detectors/godaddy/v2/godaddy.go
+++ b/pkg/detectors/godaddy/v2/godaddy.go
@@ -2,8 +2,6 @@ package godaddy
import (
"context"
- "fmt"
- "io"
"net/http"
regexp "github.com/wasilibs/go-re2"
@@ -84,15 +82,13 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
}
if verify {
- isVerified, verificationErr := VerifyGoDaddySecret(ctx, s.getClient(), prod, v1.MakeAuthHeaderValue(key, secret))
+ isVerified, verificationErr := v1.VerifyGoDaddySecret(ctx, s.getClient(), prod, v1.MakeAuthHeaderValue(key, secret))
result.Verified = isVerified
result.SetVerificationError(verificationErr, secret)
- // in case of successful verification add the enviorement name in extradata to let user know which env this secret belong to.
- if isVerified {
- result.ExtraData["Environment"] = "Prod"
- }
+ // add the env name in extradata to let user know which env this secret belong to.
+ result.ExtraData["Environment"] = "Prod"
}
results = append(results, result)
@@ -102,35 +98,3 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
return results, nil
}
-
-// VerifyGoDaddySecret make a call to godaddy api with given secret to check if secret is valid or not.
-func VerifyGoDaddySecret(ctx context.Context, client *http.Client, environment, secret string) (bool, error) {
- req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("https://%s/v1/domains/available?domain=example.com", environment), http.NoBody)
- if err != nil {
- return false, err
- }
-
- // set the required auth header
- req.Header.Set("Authorization", secret)
-
- resp, err := client.Do(req)
- if err != nil {
- return false, err
- }
- defer func() {
- _, _ = io.Copy(io.Discard, resp.Body)
- _ = resp.Body.Close()
- }()
-
- switch resp.StatusCode {
- case http.StatusOK:
- return true, nil
- case http.StatusUnauthorized:
- return false, nil
- case http.StatusForbidden:
- // as per documentation in case of 403 the token is actually verified but it does not have access.
- return true, nil
- default:
- return false, fmt.Errorf("unexpected status code: %d", resp.StatusCode)
- }
-}