Fix okta detector (#771)
Lint / lint (push) Waiting to run
Release / Release (push) Waiting to run
Scan for secrets / test (push) Waiting to run
Snifftest / Run Snifftest (push) Waiting to run
Test / test (push) Waiting to run
Test / test-detectors (push) Waiting to run

This commit is contained in:
Dustin Decker
2022-09-01 20:05:06 -07:00
committed by GitHub
parent 90da460fa1
commit aba56523b6
2 changed files with 8 additions and 3 deletions
+7 -2
View File
@@ -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
}
}
}
+1 -1
View File
@@ -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)
}