Skip to content

Find, verify, and analyze leaked credentials

Fix okta detector (#771)

Dustin Deckeraba56523b6c1
diff --git a/pkg/detectors/okta/okta.go b/pkg/detectors/okta/okta.go
index 3b3f9fe3e..9ecdae211 100644
--- a/pkg/detectors/okta/okta.go
+++ b/pkg/detectors/okta/okta.go
@@ -3,8 +3,10 @@ package okta
import (
"context"
"fmt"
+ "io"
"net/http"
"regexp"
+ "strings"
"github.com/trufflesecurity/trufflehog/v3/pkg/common"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors"
@@ -49,7 +51,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
// "https://subdomain.okta.com/api/v1/groups?limit=1"
//
- url := fmt.Sprintf("https://%s/api/v1/groups?limit=1", domain)
+ url := fmt.Sprintf("https://%s/api/v1/users/me", domain)
req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
if err != nil {
return results, err
@@ -64,7 +66,10 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
}
defer resp.Body.Close()
if resp.StatusCode >= 200 && resp.StatusCode < 300 {
- s.Verified = true
+ body, _ := io.ReadAll(resp.Body)
+ if strings.Contains(string(body), "activated") {
+ s.Verified = true
+ }
}
}
diff --git a/pkg/detectors/okta/okta_test.go b/pkg/detectors/okta/okta_test.go
index 3bda4f376..d2280fde0 100644
--- a/pkg/detectors/okta/okta_test.go
+++ b/pkg/detectors/okta/okta_test.go
@@ -18,7 +18,7 @@ import (
func TestOkta_FromChunk(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
- testSecrets, err := common.GetSecret(ctx, "trufflehog-testing", "detectors2")
+ testSecrets, err := common.GetSecret(ctx, "trufflehog-testing", "detectors4")
if err != nil {
t.Fatalf("could not get test secrets from GCP: %s", err)
}