Skip to content

Commit

Permalink
address detector issues (trufflesecurity#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
dustin-decker committed Apr 2, 2022
1 parent 78b344d commit a1dfcde
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
15 changes: 10 additions & 5 deletions pkg/detectors/uri/uri.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,15 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
}
}

token := match[0]
urlMatch := match[0]
password := match[1]

parsedURL, err := url.Parse(token)
// Skip findings where the password starts with a `$` - it's almost certainly a variable.
if strings.HasPrefix(password, "$") {
continue
}

parsedURL, err := url.Parse(urlMatch)
if err != nil {
continue
}
Expand All @@ -83,11 +88,11 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
continue
}

redact := strings.TrimSpace(strings.Replace(token, password, strings.Repeat("*", len(password)), -1))
redact := strings.TrimSpace(strings.Replace(urlMatch, password, strings.Repeat("*", len(password)), -1))

s := detectors.Result{
DetectorType: detectorspb.DetectorType_URI,
Raw: []byte(token),
Raw: []byte(urlMatch),
Redacted: redact,
}

Expand All @@ -96,7 +101,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
// whitelist protocols

// Assume a 200 response is a valid credential
postValues := map[string]string{"protocol": parsedURL.Scheme, "credentialed_uri": token}
postValues := map[string]string{"protocol": parsedURL.Scheme, "credentialed_uri": urlMatch}
jsonValue, _ := json.Marshal(postValues)
req, err := http.NewRequestWithContext(ctx, "POST", ssrfProtectorURL, bytes.NewBuffer(jsonValue))
if err != nil {
Expand Down
6 changes: 2 additions & 4 deletions pkg/engine/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ import (
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/helpscout"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/hereapi"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/heroku"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/hive"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/hiveage"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/holidayapi"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/host"
Expand Down Expand Up @@ -504,7 +503,6 @@ import (
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/splunkobservabilitytoken"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/spoonacular"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/sportsmonk"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/spotifykey"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/square"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/squareapp"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/squarespace"
Expand Down Expand Up @@ -709,7 +707,7 @@ func DefaultDetectors() []detectors.Detector {
&sentrytoken.Scanner{},
&githubapp.Scanner{},
&slackwebhook.Scanner{},
&spotifykey.Scanner{},
// &spotifykey.Scanner{},
&discordwebhook.Scanner{},
// &zapierwebhook.Scanner{},
&pubnubsubscriptionkey.Scanner{},
Expand Down Expand Up @@ -1087,7 +1085,7 @@ func DefaultDetectors() []detectors.Detector {
zenscrape.Scanner{},
// dailyco.Scanner{},
nicereply.Scanner{},
hive.Scanner{},
// hive.Scanner{},
clustdoc.Scanner{},
scrapingant.Scanner{},
kickbox.Scanner{},
Expand Down

0 comments on commit a1dfcde

Please sign in to comment.