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

[THOG-793] - Return all unverified results #856

Merged
merged 4 commits into from Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -180,6 +180,7 @@ Flags:
--concurrency=1 Number of concurrent workers.
--no-verification Don't verify the results.
--only-verified Only output verified results.
--filter-unverified Only output first unverified result per chunk per detector if there are more than one results.
Copy link
Collaborator

Choose a reason for hiding this comment

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

nitpick: Typo - "more than one results." -> "more than one result."

--print-avg-detector-time Print the average time spent on each detector.
--no-update Don't check for updates.
-i, --include-paths=INCLUDE-PATHS
Expand Down
20 changes: 11 additions & 9 deletions main.go
Expand Up @@ -30,15 +30,16 @@ import (
)

var (
cli = kingpin.New("TruffleHog", "TruffleHog is a tool for finding credentials.")
cmd string
debug = cli.Flag("debug", "Run in debug mode.").Bool()
trace = cli.Flag("trace", "Run in trace mode.").Bool()
jsonOut = cli.Flag("json", "Output in JSON format.").Short('j').Bool()
jsonLegacy = cli.Flag("json-legacy", "Use the pre-v3.0 JSON format. Only works with git, gitlab, and github sources.").Bool()
concurrency = cli.Flag("concurrency", "Number of concurrent workers.").Default(strconv.Itoa(runtime.NumCPU())).Int()
noVerification = cli.Flag("no-verification", "Don't verify the results.").Bool()
onlyVerified = cli.Flag("only-verified", "Only output verified results.").Bool()
cli = kingpin.New("TruffleHog", "TruffleHog is a tool for finding credentials.")
cmd string
debug = cli.Flag("debug", "Run in debug mode.").Bool()
trace = cli.Flag("trace", "Run in trace mode.").Bool()
jsonOut = cli.Flag("json", "Output in JSON format.").Short('j').Bool()
jsonLegacy = cli.Flag("json-legacy", "Use the pre-v3.0 JSON format. Only works with git, gitlab, and github sources.").Bool()
concurrency = cli.Flag("concurrency", "Number of concurrent workers.").Default(strconv.Itoa(runtime.NumCPU())).Int()
noVerification = cli.Flag("no-verification", "Don't verify the results.").Bool()
onlyVerified = cli.Flag("only-verified", "Only output verified results.").Bool()
filterUnverified = cli.Flag("filter-unverified", "Only output first unverified result per chunk per detector if there are more than one results.").Bool()
Copy link
Collaborator

Choose a reason for hiding this comment

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

nitpick: Typo - "more than one results." -> "more than one result."

// rules = cli.Flag("rules", "Path to file with custom rules.").String()
printAvgDetectorTime = cli.Flag("print-avg-detector-time", "Print the average time spent on each detector.").Bool()
noUpdate = cli.Flag("no-update", "Don't check for updates.").Bool()
Expand Down Expand Up @@ -172,6 +173,7 @@ func run(state overseer.State) {
engine.WithConcurrency(*concurrency),
engine.WithDecoders(decoders.DefaultDecoders()...),
engine.WithDetectors(!*noVerification, engine.DefaultDetectors()...),
engine.WithFilterUnverified(*filterUnverified),
)

filter, err := common.FilterFromFiles(*gitScanIncludePaths, *gitScanExcludePaths)
Expand Down
2 changes: 1 addition & 1 deletion pkg/detectors/abbysale/abbysale.go
Expand Up @@ -70,5 +70,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
results = append(results, s1)
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/abstract/abstract.go
Expand Up @@ -70,5 +70,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
results = append(results, s1)
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/abuseipdb/abuseipdb.go
Expand Up @@ -81,5 +81,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
results = append(results, s1)
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/accuweather/accuweather.go
Expand Up @@ -68,5 +68,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
results = append(results, s1)
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/adafruitio/adafruitio.go
Expand Up @@ -68,5 +68,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
results = append(results, s1)
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/adobeio/adobeio.go
Expand Up @@ -80,5 +80,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result

}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/adzuna/adzuna.go
Expand Up @@ -78,5 +78,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
}
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/aeroworkflow/aeroworkflow.go
Expand Up @@ -81,5 +81,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result

}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/agora/agora.go
Expand Up @@ -81,5 +81,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
}
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/aha/aha.go
Expand Up @@ -71,5 +71,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
results = append(results, s1)
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/airbrakeprojectkey/airbrakeprojectkey.go
Expand Up @@ -85,5 +85,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result

}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/airbrakeuserkey/airbrakeuserkey.go
Expand Up @@ -68,5 +68,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
results = append(results, s1)
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/airship/airship.go
Expand Up @@ -71,5 +71,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
results = append(results, s1)
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/airtableapikey/airtableapikey.go
Expand Up @@ -79,5 +79,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
}
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/airvisual/airvisual.go
Expand Up @@ -71,5 +71,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
results = append(results, s1)
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/alconost/alconost.go
Expand Up @@ -74,5 +74,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
results = append(results, s1)
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/alegra/alegra.go
Expand Up @@ -80,5 +80,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
}
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/aletheiaapi/aletheiaapi.go
Expand Up @@ -72,5 +72,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
results = append(results, s1)
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/algoliaadminkey/algoliaadminkey.go
Expand Up @@ -78,5 +78,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
results = append(results, s1)
}
}
return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/alibaba/alibaba.go
Expand Up @@ -128,5 +128,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
}
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/alienvault/alienvault.go
Expand Up @@ -69,5 +69,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
results = append(results, s1)
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/allsports/allsports.go
Expand Up @@ -75,5 +75,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
results = append(results, s1)
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/amadeus/amadeus.go
Expand Up @@ -86,5 +86,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
}
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/ambee/ambee.go
Expand Up @@ -70,5 +70,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
results = append(results, s1)
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/amplitudeapikey/amplitudeapikey.go
Expand Up @@ -79,5 +79,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
}
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/anypoint/anypoint.go
Expand Up @@ -80,5 +80,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
}
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/apacta/apacta.go
Expand Up @@ -69,5 +69,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
results = append(results, s1)
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/api2cart/api2cart.go
Expand Up @@ -80,7 +80,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
results = append(results, s1)
}

return detectors.CleanResults(results), nil
return results, nil
}

type Response struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/detectors/apideck/apideck.go
Expand Up @@ -82,5 +82,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result

}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/apiflash/apiflash.go
Expand Up @@ -78,5 +78,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
}
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/apifonica/apifonica.go
Expand Up @@ -81,5 +81,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
}
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/apify/apify.go
Expand Up @@ -68,5 +68,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
results = append(results, s1)
}

return detectors.CleanResults(results), nil
return results, nil
}
12 changes: 6 additions & 6 deletions pkg/detectors/apilayer/apilayer.go
Expand Up @@ -2,12 +2,12 @@ package apilayer

import (
"context"
"net/http"
"regexp"
"strings"
"github.com/trufflesecurity/trufflehog/v3/pkg/common"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors"
"github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb"
"net/http"
"regexp"
"strings"
)

type Scanner struct{}
Expand All @@ -18,7 +18,7 @@ var _ detectors.Detector = (*Scanner)(nil)
var (
client = common.SaneHttpClient()

//Make sure that your group is surrounded in boundry characters such as below to reduce false positives
// Make sure that your group is surrounded in boundry characters such as below to reduce false positives
keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"apilayer"}) + `\b([a-zA-Z0-9]{32})\b`)
)

Expand Down Expand Up @@ -57,7 +57,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
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
// 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
}
Expand All @@ -68,5 +68,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
results = append(results, s1)
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/apimatic/apimatic.go
Expand Up @@ -82,5 +82,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
results = append(results, s1)
}
}
return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/apiscience/apiscience.go
Expand Up @@ -70,5 +70,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
results = append(results, s1)
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/apitemplate/apitemplate.go
Expand Up @@ -70,5 +70,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
results = append(results, s1)
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/apollo/apollo.go
Expand Up @@ -69,5 +69,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
results = append(results, s1)
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/appcues/appcues.go
Expand Up @@ -90,5 +90,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
}
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/appfollow/appfollow.go
Expand Up @@ -73,5 +73,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
results = append(results, s1)
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/appointedd/appointedd.go
Expand Up @@ -74,5 +74,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
results = append(results, s1)
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/appsynergy/appsynergy.go
Expand Up @@ -70,5 +70,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
results = append(results, s1)
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/apptivo/apptivo.go
Expand Up @@ -89,5 +89,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
}
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/artifactory/artifactory.go
Expand Up @@ -81,5 +81,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
results = append(results, s1)
}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/artsy/artsy.go
Expand Up @@ -80,5 +80,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result

}

return detectors.CleanResults(results), nil
return results, nil
}
2 changes: 1 addition & 1 deletion pkg/detectors/asanaoauth/asanaoauth.go
Expand Up @@ -70,5 +70,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
results = append(results, s1)
}

return detectors.CleanResults(results), nil
return results, nil
}
Expand Up @@ -69,5 +69,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
results = append(results, s1)
}

return detectors.CleanResults(results), nil
return results, nil
}