Skip to content

Commit

Permalink
Import 27 new detectors (trufflesecurity#737)
Browse files Browse the repository at this point in the history
  • Loading branch information
dustin-decker authored Aug 26, 2022
1 parent c8ac7c3 commit 2452e93
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 40 deletions.
1 change: 0 additions & 1 deletion pkg/detectors/courier/courier.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
req.Header.Add("Accept", "application/json")
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", resMatch))
res, err := client.Do(req)
fmt.Println(res)
if err == nil {
defer res.Body.Close()
if res.StatusCode >= 200 && res.StatusCode < 300 {
Expand Down
3 changes: 1 addition & 2 deletions pkg/detectors/docparser/docparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result

if verify {
url := fmt.Sprintf("https://api.docparser.com/v1/parsers?api_key=%s", resMatch)
fmt.Println(url)
req, err := http.NewRequestWithContext(ctx, "GET",url, nil)
req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
if err != nil {
continue
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/detectors/honeycomb/honeycomb.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var (
client = common.SaneHttpClient()

// Make sure that your group is surrounded in boundary characters such as below to reduce false positives.
keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"Honeycomb"}) + `\b([0-9Aa-z-A-Z]{22})\b`)
keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"Honeycomb"}) + `\b([0-9a-zA-Z]{22})\b`)
)

// Keywords are used for efficiently pre-filtering chunks.
Expand Down
60 changes: 29 additions & 31 deletions pkg/detectors/kanbantool/kanbantool.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ var (
client = common.SaneHttpClient()

//Make sure that your group is surrounded in boundry characters such as below to reduce false positives
keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"kanbantool"}) + `\b([0-9A-Z]{12})\b`)
keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"kanbantool"}) + `\b([0-9A-Z]{12})\b`)
domainPat = regexp.MustCompile(detectors.PrefixRegex([]string{"kanbantool"}) + `\b([a-z0-9A-Z]{2,22})\b`)

)

// Keywords are used for efficiently pre-filtering chunks.
Expand All @@ -38,47 +37,46 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result

matches := keyPat.FindAllStringSubmatch(dataStr, -1)
idMatches := domainPat.FindAllStringSubmatch(dataStr, -1)
fmt.Println(idMatches)
for _, match := range matches {
if len(match) != 2 {
continue
}
resMatch := strings.TrimSpace(match[1])

for _, idMatch := range idMatches {
if len(idMatch) != 2 {
continue
}
resIdMatch := strings.TrimSpace(idMatch[1])
for _, idMatch := range idMatches {
if len(idMatch) != 2 {
continue
}
resIdMatch := strings.TrimSpace(idMatch[1])

s1 := detectors.Result{
DetectorType: detectorspb.DetectorType_Kanbantool,
Raw: []byte(resMatch),
s1 := detectors.Result{
DetectorType: detectorspb.DetectorType_Kanbantool,
Raw: []byte(resMatch),
}
if verify {
url := fmt.Sprintf("https://%s.kanbantool.com/api/v3/users/current.json", resIdMatch)
req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
if err != nil {
continue
}
if verify {
url := fmt.Sprintf("https://%s.kanbantool.com/api/v3/users/current.json",resIdMatch)
req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
if err != nil {
continue
}
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", resMatch))
res, err := client.Do(req)
if err == nil {
defer res.Body.Close()
if res.StatusCode >= 200 && res.StatusCode < 300 {
s1.Verified = true
} else {
//This function will check false positives for common test words, but also it will make sure the key appears 'random' enough to be a real key
if detectors.IsKnownFalsePositive(resMatch, detectors.DefaultFalsePositives, true) {
continue
}
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", resMatch))
res, err := client.Do(req)
if err == nil {
defer res.Body.Close()
if res.StatusCode >= 200 && res.StatusCode < 300 {
s1.Verified = true
} else {
//This function will check false positives for common test words, but also it will make sure the key appears 'random' enough to be a real key
if detectors.IsKnownFalsePositive(resMatch, detectors.DefaultFalsePositives, true) {
continue
}
}
}

results = append(results, s1)
}


results = append(results, s1)
}

}

return detectors.CleanResults(results), nil
Expand Down
3 changes: 1 addition & 2 deletions pkg/detectors/razorpay/razorpay.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Scanner struct{}
// Ensure the Scanner satisfies the interface at compile time.
var _ detectors.Detector = (*Scanner)(nil)

//The (`) character adds secondary encoding to parsed strings by Golang which also allows for escape sequences
// The (`) character adds secondary encoding to parsed strings by Golang which also allows for escape sequences
var (
keyPat = regexp.MustCompile(`(?i)\brzp_\w{2,6}_\w{10,20}\b`)
secretPat = regexp.MustCompile(`(?:razor|secret|rzp|key)[-\w]*[\" :=']*([A-Za-z0-9]{20,50})`)
Expand Down Expand Up @@ -69,7 +69,6 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
//TODO debug with responses. could still be invalid at this stage

s.Verified = true
// fmt.Println(resp)
}
}

Expand Down
3 changes: 0 additions & 3 deletions pkg/detectors/stytch/stytch.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package stytch

import (
"context"
"fmt"
"net/http"
"regexp"
"strings"
Expand Down Expand Up @@ -55,8 +54,6 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
}

if verify {
fmt.Println(userPatMatch)
fmt.Println(tokenPatMatch)
req, err := http.NewRequestWithContext(ctx, "GET", "https://api.stytch.com/v1/users/pending", nil)
if err != nil {
continue
Expand Down
54 changes: 54 additions & 0 deletions pkg/engine/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ import (
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/apiflash"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/apifonica"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/apify"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/apilayer"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/apimatic"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/apiscience"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/apitemplate"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/appcues"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/appfollow"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/appointedd"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/appsynergy"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/apptivo"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/artsy"
Expand Down Expand Up @@ -76,6 +78,7 @@ import (
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/bombbomb"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/boostnote"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/borgbase"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/braintreepayments"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/brandfetch"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/browserstack"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/browshot"
Expand Down Expand Up @@ -131,6 +134,8 @@ import (
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/cloze"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/clustdoc"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/codacy"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/codeclimate"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/codemagic"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/codequiry"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/coinapi"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/coinbase"
Expand Down Expand Up @@ -172,6 +177,7 @@ import (
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/deepai"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/deepgram"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/delighted"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/demio"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/deputy"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/detectify"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/detectlanguage"
Expand All @@ -184,18 +190,21 @@ import (
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/disqus"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/ditto"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/dnscheck"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/docparser"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/documo"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/doppler"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/dotmailer"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/dovico"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/dronahq"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/droneci"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/dropbox"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/duply"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/dwolla"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/dynalist"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/dyspatch"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/eagleeyenetworks"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/easyinsight"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/ecostruxureit"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/edamam"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/edenai"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/eightxeight"
Expand Down Expand Up @@ -228,6 +237,7 @@ import (
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/fleetbase"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/flickr"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/flightapi"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/flightlabs"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/flightstats"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/float"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/flowdash"
Expand All @@ -238,6 +248,7 @@ import (
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/formbucket"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/formcraft"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/formio"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/formsite"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/foursquare"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/frameio"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/freshbooks"
Expand All @@ -257,6 +268,7 @@ import (
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/geoipifi"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/getgeoapi"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/getgist"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/getresponse"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/getsandbox"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/github"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/github_old"
Expand All @@ -272,19 +284,23 @@ import (
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/graphcms"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/graphhopper"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/groovehq"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/gtmetrix"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/guardianapi"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/gumroad"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/gyazo"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/happi"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/happyscribe"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/harvest"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/heatmapapi"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/hellosign"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/helpcrunch"
"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/hiveage"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/holidayapi"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/holistic"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/honeycomb"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/host"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/html2pdf"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/hubspotapikey"
Expand Down Expand Up @@ -318,6 +334,7 @@ import (
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/jumpcloud"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/juro"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/kanban"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/kanbantool"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/karmacrm"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/keenio"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/kickbox"
Expand All @@ -331,6 +348,7 @@ import (
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/lastfm"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/launchdarkly"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/leadfeeder"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/lemlist"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/lendflow"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/lessannoyingcrm"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/lexigram"
Expand Down Expand Up @@ -381,6 +399,7 @@ import (
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/mockaroo"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/moderation"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/monday"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/monkeylearn"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/moonclerck"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/moonclerk"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/moosend"
Expand Down Expand Up @@ -431,6 +450,7 @@ import (
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/paralleldots"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/parsehub"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/parsers"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/parseur"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/partnerstack"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/passbase"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/pastebin"
Expand Down Expand Up @@ -463,6 +483,7 @@ import (
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/postmark"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/powrbot"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/privatekey"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/prodpad"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/prospectcrm"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/prospectio"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/protocolsio"
Expand Down Expand Up @@ -504,10 +525,12 @@ import (
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/salesblink"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/salescookie"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/salesflare"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/salesmate"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/satismeterprojectkey"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/satismeterwritekey"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/saucelabs"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/scalewaykey"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/scalr"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/scrapeowl"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/scraperapi"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/scraperbox"
Expand Down Expand Up @@ -619,14 +642,17 @@ import (
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/timezoneapi"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/tmetric"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/todoist"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/tokeet"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/tomorrowio"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/tomtom"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/tradier"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/transferwise"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/travelpayouts"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/travisci"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/trelloapikey"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/twelvedata"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/twilio"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/twist"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/twitch"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/twitter"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/tyntec"
Expand Down Expand Up @@ -669,6 +695,7 @@ import (
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/webflow"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/webscraper"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/webscraping"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/websitepulse"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/whoxy"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/wistia"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/worksnaps"
Expand Down Expand Up @@ -1417,5 +1444,32 @@ func DefaultDetectors() []detectors.Detector {
postbacks.Scanner{},
collect2.Scanner{},
uclassify.Scanner{},
holistic.Scanner{},
tokeet.Scanner{},
duply.Scanner{},
gtmetrix.Scanner{},
braintreepayments.Scanner{},
docparser.Scanner{},
formsite.Scanner{},
flightlabs.Scanner{},
getresponse.Scanner{},
codeclimate.Scanner{},
apilayer.Scanner{},
monkeylearn.Scanner{},
parseur.Scanner{},
honeycomb.Scanner{},
demio.Scanner{},
kanbantool.Scanner{},
salesmate.Scanner{},
lemlist.Scanner{},
websitepulse.Scanner{},
scalr.Scanner{},
ecostruxureit.Scanner{},
heatmapapi.Scanner{},
appointedd.Scanner{},
twist.Scanner{},
prodpad.Scanner{},
transferwise.Scanner{},
codemagic.Scanner{},
}
}

0 comments on commit 2452e93

Please sign in to comment.