mirror of
https://github.com/trufflesecurity/trufflehog.git
synced 2026-05-16 13:20:35 +00:00
0fa069c12f
* enable errcheck and staticcheck for golangci-lint v2 and resolve all issues * skip lint on intentional reference of deprecated DetectorType values
checksecretparts
Static analysis check that finds detector packages which construct
detectors.Result values without populating the SecretParts field.
What it checks
For each directory under pkg/detectors/ (recursing into subpackages):
- Find every composite literal of the form
detectors.Result{...}or&detectors.Result{...}in non-test.gofiles. - If the package does not mention
SecretPartsanywhere, emit a warning for each construction site.
Running locally
# Warning mode (default): prints findings, always exits 0 unless scanning fails.
go run ./hack/checksecretparts
# Scan specific directories instead of ./pkg/detectors.
go run ./hack/checksecretparts ./pkg/detectors/aws ./pkg/detectors/github
# Fail mode: exit 1 if any findings are reported. Use this once every detector
# has been migrated to populate SecretParts.
go run ./hack/checksecretparts -fail
Flipping warning → fail
Once every detector populates SecretParts, make this check gating:
- In
.github/workflows/lint.yml, dropcontinue-on-error: truefrom thechecksecretpartsjob and change the run step to pass-fail. - Land any remaining migrations in the same PR as the flip.
Scope limits
- It is a syntactic check. It matches
detectors.Resultby selector-expr name; packages that rename the import (d "...detectors") would not be caught. No such rename exists in the current codebase.