Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] Add test to check all versioned detectors are non-zero #2272

Merged
merged 1 commit into from
Jan 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions pkg/engine/defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,20 @@ func TestDefaultDetectorTypesImplementing(t *testing.T) {
)
}
}

func TestDefaultVersionerDetectorsHaveNonZeroVersions(t *testing.T) {
// Loop through all our default detectors and find the ones that
// implement Versioner. Of those, check each version is not zero.
// This is required due to an implementation detail of filtering detectors.
// See: https://github.com/trufflesecurity/trufflehog/blob/v3.63.7/main.go#L624-L638
for _, detector := range DefaultDetectors() {
v, ok := detector.(detectors.Versioner)
if !ok || v.Version() != 0 {
continue
}
t.Errorf(
"detector %q implements Versioner that returns a zero version",
detectorspb.DetectorType_name[int32(detector.Type())],
)
}
}
Loading