Add a static check for detectors that don't set SecretParts#4913
Merged
Conversation
Mechanical rename of the detectors.Result.AnalysisInfo field to SecretParts to prepare for its replacement for Raw.
Introduces a small Go tool under hack/checksecretparts that finds detector packages which construct detectors.Result without populating the new SecretParts field. The check runs in CI as warning-only (continue-on-error) so the ~900 unmigrated detectors don't block unrelated PRs while they're being migrated; it can be flipped to a hard failure by dropping continue-on-error and passing -fail once all detectors populate the field. Covers composite and pointer literals, ignores test files on both sides (construction and reference), and suppresses findings for any package that mentions SecretParts anywhere in its non-test source so that detectors setting the field via later assignment (x.SecretParts = ...) are not flagged.
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 9843976. Configure here.
The summary was reporting len(findings) as the number of packages, but
findings contain one entry per construction site; a single package with
multiple detectors.Result{} literals produces multiple entries. Count
distinct packages from Finding.Package and include both totals in the
output.
4 tasks
rosecodym
approved these changes
Apr 24, 2026
rosecodym
left a comment
Contributor
There was a problem hiding this comment.
I only barely skimmed the new check itself, but I like the approach and the test suite.
kashifkhan0771
approved these changes
Apr 24, 2026
trufflesteeeve
approved these changes
Apr 24, 2026
2 tasks
MuneebUllahKhan222
pushed a commit
that referenced
this pull request
May 29, 2026
* Rename AnalysisInfo field to SecretParts on detectors.Result
Mechanical rename of the detectors.Result.AnalysisInfo field to
SecretParts to prepare for its replacement for Raw.
* Add checksecretparts static analysis for detectors.Result
Introduces a small Go tool under hack/checksecretparts that finds
detector packages which construct detectors.Result without populating
the new SecretParts field.
The check runs in CI as warning-only (continue-on-error) so the ~900
unmigrated detectors don't block unrelated PRs while they're being
migrated; it can be flipped to a hard failure by dropping
continue-on-error and passing -fail once all detectors populate the
field.
Covers composite and pointer literals, ignores test files on both
sides (construction and reference), and suppresses findings for any
package that mentions SecretParts anywhere in its non-test source so
that detectors setting the field via later assignment (x.SecretParts
= ...) are not flagged.
* checksecretparts: count distinct packages in summary
The summary was reporting len(findings) as the number of packages, but
findings contain one entry per construction site; a single package with
multiple detectors.Result{} literals produces multiple entries. Count
distinct packages from Finding.Package and include both totals in the
output.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Adds a small static-analysis tool under
hack/checksecretparts/that scanspkg/detectors/and warns about detector packages that constructdetectors.Resultvalues without ever populating the newSecretPartsfield.It's wired into the
Lintworkflow as warning-only (continue-on-error: true): findings show up in CI but don't block merges. The intent is to land the check before every detector is migrated to aid in migrating the packages.Stacked on #4911 (the rename that introduces
SecretParts); that needs to land first.Why
SecretPartsreplaces the oldAnalysisInfofield and is expected to be populated by every detector going forward. Today only ~11 detectors set it. Rather than wait for a big-bang migration, this PR adds the enforcement mechanism first so each incremental migration PR gets immediate feedback, and so the flip from warning to hard-fail becomes a one-line workflow change once the migration is complete.What it does
pkg/detectors/, finds composite literals of the formdetectors.Result{...}or&detectors.Result{...}in non-test.gofiles.SecretPartsin any non-test source (neither in the literal nor in a laterx.SecretParts = ...assignment), emits one warning per construction site._test.gofiles on both sides — some tests zero the field for cmp comparisons (e.g.pkg/detectors/gitlab/v1/gitlab_integration_test.go) and those references would otherwise mask real findings.No new module dependencies — just
go/astandgo/parser.How to run
Full instructions for flipping warning → hard-fail are in
hack/checksecretparts/README.md.Verification
go test ./hack/checksecretparts/— 8 cases covering missing-field, literal-populated, later-assigned, pointer literal, multiple sites, test-file-only references (must not suppress), and no-op packages.SecretParts(postmark, databricks, figma, ngrok, monday, airbrake, digitalocean, datadog, tableau) is correctly exempted.go vet ./...andgo build ./...are clean.Out of scope
SecretPartson any real detector — that's a separate migration.Note
Low Risk
Low risk: adds a new warning-only CI/static-analysis tool and tests without changing runtime detector behavior; main impact is additional lint workflow time/output.
Overview
Adds
hack/checksecretparts, a small Go AST-based scanner that reports (and optionally fails on) detector packages that builddetectors.Result{}/&detectors.Result{}without any non-test reference toSecretParts, plus unit tests and documentation.Wires the scanner into
.github/workflows/lint.ymlas a warning-onlychecksecretpartsjob (continue-on-error: true) to surface unmigrated detectors in CI without blocking merges.Reviewed by Cursor Bugbot for commit fc9bdaa. Bugbot is set up for automated code reviews on this repo. Configure here.