Find, verify, and analyze leaked credentials
Go credentialsdevsecopsdynamic-analysisprecommitscanningsecretsecret-managementsecretssecuritysecurity-toolstrufflehogverification
added response body check in okta verification (#4180)
Nabeel Alam542efee97363
diff --git a/pkg/detectors/okta/okta.go b/pkg/detectors/okta/okta.goindex ec82cc5db..50899e6f8 100644--- a/pkg/detectors/okta/okta.go+++ b/pkg/detectors/okta/okta.go@@ -3,7 +3,9 @@ package oktaimport ("context""fmt"+ "io""net/http"+ "strings"regexp "github.com/wasilibs/go-re2"@@ -72,7 +74,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (resultreturn}-func verifyOktaToken(ctx context.Context, client *http.Client, domain string, token string) (bool, error) {+func verifyOktaToken(ctx context.Context, client *http.Client, domain, token string) (bool, error) {// curl -v -X GET \// -H "Accept: application/json" \// -H "Content-Type: application/json" \@@ -96,8 +98,9 @@ func verifyOktaToken(ctx context.Context, client *http.Client, domain string, toswitch resp.StatusCode {case http.StatusOK:- return true, nil- case http.StatusUnauthorized, http.StatusForbidden:+ body, _ := io.ReadAll(resp.Body)+ return strings.Contains(string(body), "\"activated\":"), nil+ case http.StatusUnauthorized:return false, nildefault:return false, fmt.Errorf("unexpected status code: %d", resp.StatusCode)