Skip to content

Commit a1dfcde

Browse files
address detector issues (#123)
1 parent 78b344d commit a1dfcde

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

pkg/detectors/uri/uri.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,15 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
6969
}
7070
}
7171

72-
token := match[0]
72+
urlMatch := match[0]
7373
password := match[1]
7474

75-
parsedURL, err := url.Parse(token)
75+
// Skip findings where the password starts with a `$` - it's almost certainly a variable.
76+
if strings.HasPrefix(password, "$") {
77+
continue
78+
}
79+
80+
parsedURL, err := url.Parse(urlMatch)
7681
if err != nil {
7782
continue
7883
}
@@ -83,11 +88,11 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
8388
continue
8489
}
8590

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

8893
s := detectors.Result{
8994
DetectorType: detectorspb.DetectorType_URI,
90-
Raw: []byte(token),
95+
Raw: []byte(urlMatch),
9196
Redacted: redact,
9297
}
9398

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

98103
// Assume a 200 response is a valid credential
99-
postValues := map[string]string{"protocol": parsedURL.Scheme, "credentialed_uri": token}
104+
postValues := map[string]string{"protocol": parsedURL.Scheme, "credentialed_uri": urlMatch}
100105
jsonValue, _ := json.Marshal(postValues)
101106
req, err := http.NewRequestWithContext(ctx, "POST", ssrfProtectorURL, bytes.NewBuffer(jsonValue))
102107
if err != nil {

pkg/engine/defaults.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ import (
255255
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/helpscout"
256256
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/hereapi"
257257
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/heroku"
258-
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/hive"
259258
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/hiveage"
260259
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/holidayapi"
261260
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/host"
@@ -504,7 +503,6 @@ import (
504503
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/splunkobservabilitytoken"
505504
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/spoonacular"
506505
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/sportsmonk"
507-
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/spotifykey"
508506
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/square"
509507
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/squareapp"
510508
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/squarespace"
@@ -709,7 +707,7 @@ func DefaultDetectors() []detectors.Detector {
709707
&sentrytoken.Scanner{},
710708
&githubapp.Scanner{},
711709
&slackwebhook.Scanner{},
712-
&spotifykey.Scanner{},
710+
// &spotifykey.Scanner{},
713711
&discordwebhook.Scanner{},
714712
// &zapierwebhook.Scanner{},
715713
&pubnubsubscriptionkey.Scanner{},
@@ -1087,7 +1085,7 @@ func DefaultDetectors() []detectors.Detector {
10871085
zenscrape.Scanner{},
10881086
// dailyco.Scanner{},
10891087
nicereply.Scanner{},
1090-
hive.Scanner{},
1088+
// hive.Scanner{},
10911089
clustdoc.Scanner{},
10921090
scrapingant.Scanner{},
10931091
kickbox.Scanner{},

0 commit comments

Comments
 (0)