Files
trufflehog/pkg/feature/feature.go
meredith 4b7d1d3a68 Low-memory Git Scanning (#5257)
* Refactor gitparse for reduced peak memory use

Instead of one single `git log` that grows huge, get a commit list with
"log" then request `git show` groups of those commits.

This is currently slightly slower than main, and parallelizing this part
further doesn't improve things because of the diffChan consumer in the
caller.  It does pipeline just enough that one git show can run while
scanning consumes the prior set of diffs.

* Group commits while reading instead of slurp and split

* Make the low-memory scan mode a non-default option
2026-09-10 12:18:33 -05:00

82 lines
3.2 KiB
Go

package feature
import (
"sync/atomic"
)
var (
ForceSkipBinaries atomic.Bool
ForceSkipArchives atomic.Bool
GitCloneTimeoutDuration atomic.Int64
SkipAdditionalRefs atomic.Bool
EnableAPKHandler atomic.Bool
UserAgentSuffix AtomicString
UseSimplifiedGitlabEnumeration atomic.Bool
UseGitMirror atomic.Bool
UseGitLowMemoryScan atomic.Bool
GitlabProjectsPerPage atomic.Int64
UseGithubGraphQLAPI atomic.Bool // use github graphql api to fetch issues, pr's and comments
HTMLDecoderEnabled atomic.Bool
PineconeDetectorEnabled atomic.Bool
CloudinaryDetectorEnabled atomic.Bool
GitLabOAuthDetectorEnabled atomic.Bool
SonarCloudV2DetectorEnabled atomic.Bool
EnigmaDetectorEnabled atomic.Bool
DatadogApiKeyDetectorEnabled atomic.Bool
TlyDetectorEnabled atomic.Bool
WitDetectorEnabled atomic.Bool
RevDetectorEnabled atomic.Bool
UserDetectorEnabled atomic.Bool
BraintrustDetectorEnabled atomic.Bool
PgAnalyzeReadKeyDetectorEnabled atomic.Bool
RedHatPyxisDetectorEnabled atomic.Bool
OctopusDeployDetectorEnabled atomic.Bool
DropUnverifiedJWTResults atomic.Bool
OpenRouterDetectorEnabled atomic.Bool
NewRelicInsightsInsertKeyDetectorEnabled atomic.Bool
DuffelTokenDetectorEnabled atomic.Bool
ShippoDetectorEnabled atomic.Bool
IPInfoDetectorEnabled atomic.Bool
LobDetectorEnabled atomic.Bool
HashiCorpVaultBatchTokenDetectorEnabled atomic.Bool
HashiCorpVaultTokenDetectorEnabled atomic.Bool
CloudflareApiTokenV2DetectorEnabled atomic.Bool
CloudflareGlobalApiKeyV2DetectorEnabled atomic.Bool
DuoDetectorEnabled atomic.Bool
FigmaV3DetectorEnabled atomic.Bool
NewRelicLicenseKeyDetectorEnabled atomic.Bool
NewRelicBrowserKeyDetectorEnabled atomic.Bool
NewRelicUserKeyDetectorEnabled atomic.Bool
NewRelicInsightsQueryKeyDetectorEnabled atomic.Bool
NewRelicMobileAppTokenDetectorEnabled atomic.Bool
MSTeamsWebhookV2DetectorEnabled atomic.Bool
SolarwindsDetectorEnabled atomic.Bool
ResendDetectorEnabled atomic.Bool
WeightsAndBiasesV2DetectorEnabled atomic.Bool
HumioAPITokenDetectorEnabled atomic.Bool
)
type AtomicString struct {
value atomic.Value
}
// Load returns the current value of the atomic string
func (as *AtomicString) Load() string {
if v := as.value.Load(); v != nil {
return v.(string)
}
return ""
}
// Store sets the value of the atomic string
func (as *AtomicString) Store(newValue string) {
as.value.Store(newValue)
}
// Swap atomically swaps the current string with a new one and returns the old value
func (as *AtomicString) Swap(newValue string) string {
oldValue := as.Load()
as.Store(newValue)
return oldValue
}