Skip to content

Find, verify, and analyze leaked credentials

feat: add --no-ignore-tag to report secrets on trufflehog:ignore lines (#5293)

thiswillnevermatch1a3fbcf4d86f
diff --git a/docs/man/trufflehog.1 b/docs/man/trufflehog.1
index b417a7041..a47a467ad 100644
--- a/docs/man/trufflehog.1
+++ b/docs/man/trufflehog.1
@@ -59,6 +59,9 @@ Allow verification of similar credentials across detectors
\fB--filter-unverified\fR
Only output first unverified result per chunk per detector if there are more than one results.
.TP
+\fB--no-ignore-tag\fR
+Do not suppress results on lines containing a 'trufflehog:ignore' comment.
+.TP
\fB--filter-entropy=FILTER-ENTROPY\fR
Filter unverified results with Shannon entropy. Start with 3.0.
.TP
diff --git a/main.go b/main.go
index 0527f72a4..1fd6a1696 100644
--- a/main.go
+++ b/main.go
@@ -65,6 +65,7 @@ var (
allowVerificationOverlap = cli.Flag("allow-verification-overlap", "Allow verification of similar credentials across detectors").Bool()
filterUnverified = cli.Flag("filter-unverified", "Only output first unverified result per chunk per detector if there are more than one results.").Bool()
+ noIgnoreTag = cli.Flag("no-ignore-tag", "Do not suppress results on lines containing a 'trufflehog:ignore' comment.").Bool()
filterEntropy = cli.Flag("filter-entropy", "Filter unverified results with Shannon entropy. Start with 3.0.").Float64()
noIgnoreTag = cli.Flag("no-ignore-tag", "Report results even if the line has a 'trufflehog:ignore' comment.").Bool()
scanEntireChunk = cli.Flag("scan-entire-chunk", "Scan the entire chunk for secrets.").Hidden().Default("false").Bool()
@@ -660,6 +661,7 @@ func run(state overseer.State, logSync func() error) {
VerifierEndpoints: *verifiers,
Dispatcher: engine.NewPrinterDispatcher(printer),
FilterUnverified: *filterUnverified,
+ NoIgnoreTag: *noIgnoreTag,
FilterEntropy: *filterEntropy,
NoIgnoreTag: *noIgnoreTag,
VerificationOverlap: *allowVerificationOverlap,
diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go
index de5c412e2..bc6167f1d 100644
--- a/pkg/engine/engine.go
+++ b/pkg/engine/engine.go
@@ -123,7 +123,10 @@ type Config struct {
FilterEntropy float64
// FilterUnverified sets the filterUnverified flag on the engine. If set to
// true, the engine will only return the first unverified result for a chunk for a detector.
- FilterUnverified bool
+ FilterUnverified bool
+ // NoIgnoreTag, when true, disables the default behavior of dropping results
+ // whose line contains a "trufflehog:ignore" comment.
+ NoIgnoreTag bool
ShouldScanEntireChunk bool
// NoIgnoreTag disables the "trufflehog:ignore" tag. If set to true, results are
@@ -188,6 +191,9 @@ type Engine struct {
// If there are multiple unverified results for the same chunk for the same detector,
// only the first one will be kept.
filterUnverified bool
+ // noIgnoreTag disables suppression of results on lines containing the
+ // "trufflehog:ignore" comment tag.
+ noIgnoreTag bool
// entropyFilter is used to filter out unverified results using Shannon entropy.
filterEntropy float64
notifyVerifiedResults bool
@@ -259,6 +265,7 @@ func NewEngine(ctx context.Context, cfg *Config) (*Engine, error) {
dispatcher: cfg.Dispatcher,
verify: cfg.Verify,
filterUnverified: cfg.FilterUnverified,
+ noIgnoreTag: cfg.NoIgnoreTag,
filterEntropy: cfg.FilterEntropy,
printAvgDetectorTime: cfg.PrintAvgDetectorTime,
retainFalsePositives: cfg.LogFilteredUnverified,