Skip to content

Commit

Permalink
add custom regex name to detector key
Browse files Browse the repository at this point in the history
  • Loading branch information
rosecodym committed Oct 30, 2023
1 parent 99928ac commit 24b5baf
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions pkg/engine/ahocorasickcore.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"strings"

ahocorasick "github.com/BobuSumisu/aho-corasick"

"github.com/trufflesecurity/trufflehog/v3/pkg/custom_detectors"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors"
"github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb"
)
Expand All @@ -13,8 +13,9 @@ import (
// Multiple detectors can have the same detector type but different versions.
// This allows us to identify a detector by its type and version.
type detectorKey struct {
detectorType detectorspb.DetectorType
version int
detectorType detectorspb.DetectorType
version int
customDetectorName string
}

// AhoCorasickCore encapsulates the operations and data structures used for keyword matching via the
Expand Down Expand Up @@ -85,5 +86,9 @@ func createDetectorKey(d detectors.Detector) detectorKey {
if v, ok := d.(detectors.Versioner); ok {
version = v.Version()
}
return detectorKey{detectorType: detectorType, version: version}
var customDetectorName string
if r, ok := d.(*custom_detectors.CustomRegexWebhook); ok {
customDetectorName = r.GetName()
}
return detectorKey{detectorType: detectorType, version: version, customDetectorName: customDetectorName}
}

0 comments on commit 24b5baf

Please sign in to comment.