From 5c2762667cca2c6bc9bce2ff6e2a04eb22fbd453 Mon Sep 17 00:00:00 2001 From: Mustansir Date: Tue, 7 Jul 2026 13:22:29 +0500 Subject: [PATCH] [INS-467] Add IPinfo detector to default detectors list (#4970) * Add feature flags for new detectors * Slight rename, ensure the flags are false by default * Missed a name change * Turn on new detectors for OSS user * Instead of only adding flagged detectors when their flag is enabled, remove them when their flag is disabled * Thank you cursorbot * Excempt the flagged detectors from a test * add datadogapikey detector to defaults.go * gate detector behind feature flag * enable the flag on main * make detector list consistent in alphabetical order * add ipinfo detector to default detectors list * gate behind feature flag * add new Result fields to IgnoreFields in integration test --------- Co-authored-by: Charlie Gunyon Co-authored-by: Charlie Gunyon --- main.go | 1 + pkg/detectors/ipinfo/ipinfo_integration_test.go | 5 ++++- pkg/engine/defaults/defaults.go | 4 ++++ pkg/engine/defaults/defaults_test.go | 8 ++++---- pkg/feature/feature.go | 1 + 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index 468a61448..5d768b3b2 100644 --- a/main.go +++ b/main.go @@ -555,6 +555,7 @@ func run(state overseer.State, logSync func() error) { feature.NewRelicInsightsInsertKeyDetectorEnabled.Store(true) feature.DuffelTokenDetectorEnabled.Store(true) feature.ShippoDetectorEnabled.Store(true) + feature.IPInfoDetectorEnabled.Store(true) conf := &config.Config{} if *configFilename != "" { diff --git a/pkg/detectors/ipinfo/ipinfo_integration_test.go b/pkg/detectors/ipinfo/ipinfo_integration_test.go index 1d1ccda12..19c3d5ab1 100644 --- a/pkg/detectors/ipinfo/ipinfo_integration_test.go +++ b/pkg/detectors/ipinfo/ipinfo_integration_test.go @@ -133,11 +133,14 @@ func TestIpinfo_FromChunk(t *testing.T) { if len(got[i].Raw) == 0 { t.Fatalf("no raw secret present: \n %+v", got[i]) } + if len(got[i].SecretParts) == 0 { + t.Fatalf("no secret parts present: \n %+v", got[i]) + } if (got[i].VerificationError() != nil) != tt.wantVerificationErr { t.Fatalf("wantVerificationError = %v, verification error = %v", tt.wantVerificationErr, got[i].VerificationError()) } } - ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "verificationError") + ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "verificationError", "primarySecret", "SecretParts", "chunkOffset", "chunkOffsetSet") if diff := cmp.Diff(got, tt.want, ignoreOpts); diff != "" { t.Errorf("Ipinfo.FromData() %s diff: (-got +want)\n%s", tt.name, diff) } diff --git a/pkg/engine/defaults/defaults.go b/pkg/engine/defaults/defaults.go index b2c1451b3..8c2a6e88d 100644 --- a/pkg/engine/defaults/defaults.go +++ b/pkg/engine/defaults/defaults.go @@ -404,6 +404,7 @@ import ( "github.com/trufflesecurity/trufflehog/v3/pkg/detectors/ip2location" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors/ipapi" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors/ipgeolocation" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors/ipinfo" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors/ipinfodb" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors/ipquality" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors/ipstack" @@ -1302,6 +1303,7 @@ func buildDetectorList() []detectors.Detector { &ip2location.Scanner{}, &ipapi.Scanner{}, &ipgeolocation.Scanner{}, + &ipinfo.Scanner{}, &ipinfodb.Scanner{}, &ipquality.Scanner{}, &ipstack.Scanner{}, @@ -1832,6 +1834,8 @@ func buildDetectorList() []detectors.Detector { return !feature.DuffelTokenDetectorEnabled.Load() case *shippo.Scanner: return !feature.ShippoDetectorEnabled.Load() + case *ipinfo.Scanner: + return !feature.IPInfoDetectorEnabled.Load() default: return false } diff --git a/pkg/engine/defaults/defaults_test.go b/pkg/engine/defaults/defaults_test.go index afea14e62..52fc8e1f7 100644 --- a/pkg/engine/defaults/defaults_test.go +++ b/pkg/engine/defaults/defaults_test.go @@ -118,10 +118,9 @@ var excludedFromDefaultList = map[detector_typepb.DetectorType]struct{}{ // to buildDetectorList() — discovered by TestAllDetectorTypesAreInDefaultList. // They are not added immediately out of caution for the impact on customers/users. // Remove each entry once its detector has been carefully added. - detector_typepb.DetectorType_Guru: {}, - detector_typepb.DetectorType_IPInfo: {}, - detector_typepb.DetectorType_Lob: {}, - detector_typepb.DetectorType_Tru: {}, + detector_typepb.DetectorType_Guru: {}, + detector_typepb.DetectorType_Lob: {}, + detector_typepb.DetectorType_Tru: {}, // Feature flag gated detectors // These should be removed from this list when we remove the feature flag @@ -142,6 +141,7 @@ var excludedFromDefaultList = map[detector_typepb.DetectorType]struct{}{ detector_typepb.DetectorType_NewRelicInsightsInsertKey: {}, detector_typepb.DetectorType_DuffelToken: {}, detector_typepb.DetectorType_Shippo: {}, + detector_typepb.DetectorType_IPInfo: {}, // Reserved / special types. detector_typepb.DetectorType_CustomRegex: {}, // added dynamically via engine config, not via buildDetectorList() diff --git a/pkg/feature/feature.go b/pkg/feature/feature.go index 2f83afeb0..62f155632 100644 --- a/pkg/feature/feature.go +++ b/pkg/feature/feature.go @@ -34,6 +34,7 @@ var ( NewRelicInsightsInsertKeyDetectorEnabled atomic.Bool DuffelTokenDetectorEnabled atomic.Bool ShippoDetectorEnabled atomic.Bool + IPInfoDetectorEnabled atomic.Bool ) type AtomicString struct {