Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Auth0 #3857

Merged
merged 4 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions pkg/detectors/auth0oauth/auth0oauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb"
)

type Scanner struct{
type Scanner struct {
detectors.DefaultMultiPartCredentialProvider
}

Expand All @@ -37,20 +37,24 @@ func (s Scanner) Keywords() []string {
// FromData will find and optionally verify Auth0oauth secrets in a given set of bytes.
func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) {
dataStr := string(data)

clientIdMatches := clientIdPat.FindAllStringSubmatch(dataStr, -1)
clientSecretMatches := clientSecretPat.FindAllStringSubmatch(dataStr, -1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why isn’t the uniqueness logic applied to both Id and Secret?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, each pattern should be unique

domainMatches := domainPat.FindAllStringSubmatch(dataStr, -1)
uniqueDomainMatches := make(map[string]struct{})
for _, m := range domainMatches {
if len(m) > 1 {
uniqueDomainMatches[strings.TrimSpace(m[1])] = struct{}{}
}
zricethezav marked this conversation as resolved.
Show resolved Hide resolved

}

for _, clientIdMatch := range clientIdMatches {
clientIdRes := strings.TrimSpace(clientIdMatch[1])

for _, clientSecretMatch := range clientSecretMatches {
clientSecretRes := strings.TrimSpace(clientSecretMatch[1])

for _, domainMatch := range domainMatches {
domainRes := strings.TrimSpace(domainMatch[1])

for domainRes := range uniqueDomainMatches {
s1 := detectors.Result{
DetectorType: detectorspb.DetectorType_Auth0oauth,
Redacted: clientIdRes,
Expand Down
3 changes: 2 additions & 1 deletion pkg/engine/defaults/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import (
atlassianv2 "github.com/trufflesecurity/trufflehog/v3/pkg/detectors/atlassian/v2"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/audd"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/auth0managementapitoken"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/auth0oauth"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/autodesk"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/autoklose"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/autopilot"
Expand Down Expand Up @@ -879,7 +880,7 @@ func buildDetectorList() []detectors.Detector {
&atlassianv2.Scanner{},
&audd.Scanner{},
&auth0managementapitoken.Scanner{},
// &auth0oauth.Scanner{},
&auth0oauth.Scanner{},
&autodesk.Scanner{},
&autoklose.Scanner{},
&autopilot.Scanner{},
Expand Down
Loading