From 5f5acdbfa5f4d0b589d2fb52d7022700f68e844b Mon Sep 17 00:00:00 2001 From: ktranSC <167803002+ktranSC@users.noreply.github.com> Date: Wed, 2 Oct 2024 15:15:56 -0700 Subject: [PATCH 1/2] Update main.go --- main.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/main.go b/main.go index 0dbf1f8d11e8..8b0258935139 100644 --- a/main.go +++ b/main.go @@ -30,6 +30,7 @@ import ( "github.com/trufflesecurity/trufflehog/v3/pkg/handlers" "github.com/trufflesecurity/trufflehog/v3/pkg/log" "github.com/trufflesecurity/trufflehog/v3/pkg/output" + "github.com/trufflesecurity/trufflehog/v3/pkg/feature" "github.com/trufflesecurity/trufflehog/v3/pkg/sources" "github.com/trufflesecurity/trufflehog/v3/pkg/tui" "github.com/trufflesecurity/trufflehog/v3/pkg/updater" @@ -70,6 +71,12 @@ var ( excludeDetectors = cli.Flag("exclude-detectors", "Comma separated list of detector types to exclude. Protobuf name or IDs may be used, as well as ranges. IDs defined here take precedence over the include list.").String() jobReportFile = cli.Flag("output-report", "Write a scan report to the provided path.").Hidden().OpenFile(os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666) + // Add feature flags + forceSkipBinaries = cli.Flag("force-skip-binaries", "Force skipping binaries.").Bool() + forceSkipArchives = cli.Flag("force-skip-archives", "Force skipping archives.").Bool() + skipAdditionalRefs = cli.Flag("skip-additional-refs", "Skip additional references.").Bool() + userAgentSuffix = cli.Flag("user-agent-suffix", "Suffix to add to User-Agent.").String() + gitScan = cli.Command("git", "Find credentials in git repositories.") gitScanURI = gitScan.Arg("uri", "Git repository URL. https://, file://, or ssh:// schema expected.").Required().String() gitScanIncludePaths = gitScan.Flag("include-paths", "Path to file with newline separated regexes for files to include in scan.").Short('i').String() @@ -368,6 +375,23 @@ func run(state overseer.State) { }() } + // Set feature configurations from CLI flags + if *forceSkipBinaries { + feature.ForceSkipBinaries.Store(true) + } + + if *forceSkipArchives { + feature.ForceSkipArchives.Store(true) + } + + if *skipAdditionalRefs { + feature.SkipAdditionalRefs.Store(true) + } + + if *userAgentSuffix != "" { + feature.UserAgentSuffix.Store(*userAgentSuffix) + } + conf := &config.Config{} if *configFilename != "" { var err error From 9d489020f7658bf033f7edde7a76eea3e11d35b8 Mon Sep 17 00:00:00 2001 From: ktranSC <167803002+ktranSC@users.noreply.github.com> Date: Wed, 2 Oct 2024 15:19:15 -0700 Subject: [PATCH 2/2] Update main.go --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 8b0258935139..fc2888bdcc94 100644 --- a/main.go +++ b/main.go @@ -375,7 +375,7 @@ func run(state overseer.State) { }() } - // Set feature configurations from CLI flags + // Set feature configurations from CLI flags if *forceSkipBinaries { feature.ForceSkipBinaries.Store(true) }