diff --git a/pkg/common/byteconv.go b/pkg/common/byteconv.go new file mode 100644 index 000000000000..e6f422c70259 --- /dev/null +++ b/pkg/common/byteconv.go @@ -0,0 +1,8 @@ +package common + +import "unsafe" + +// BytesToString converts a byte slice to a string without allocating. +func BytesToString(b []byte) string { + return unsafe.String(unsafe.SliceData(b), len(b)) +} diff --git a/pkg/common/byteconv_test.go b/pkg/common/byteconv_test.go new file mode 100644 index 000000000000..4d15d1016982 --- /dev/null +++ b/pkg/common/byteconv_test.go @@ -0,0 +1,77 @@ +package common + +import ( + "math/rand" + "reflect" + "testing" + "testing/quick" + "time" + + "github.com/stretchr/testify/assert" +) + +func TestBytesToString_IdentityProperty(t *testing.T) { + identityProperty := func(b []byte) bool { + return BytesToString(b) == string(b) + } + + genRandBytes := func(size int) []byte { + b := make([]byte, size) + + r := rand.New(rand.NewSource(time.Now().UnixNano())) + for i := 0; i < size; i++ { + b[i] = byte(r.Intn(256)) + } + + return b + } + + cfg := &quick.Config{ + Values: func(values []reflect.Value, rand *rand.Rand) { + // 2% chance to return a nil slice. + if rand.Intn(2) == 0 { + values[0] = reflect.Zero(reflect.TypeOf([]byte{})) + return + } + values[0] = reflect.ValueOf(genRandBytes(rand.Intn(100_000))) + }, + } + + assert.NoError(t, quick.Check(identityProperty, cfg)) +} + +func TestBytesToString_LengthProperty(t *testing.T) { + lengthProperty := func(b []byte) bool { + return len(BytesToString(b)) == len(b) + } + + assert.NoError(t, quick.Check(lengthProperty, nil)) +} + +// TestBytesToString_SharedDataConsistency checks if mutating the input byte slice +// after conversion affects the string output from BytesToString, testing that the +// underlying data sharing between the slice and the string is handled correctly. +func TestBytesToString_SharedDataConsistency(t *testing.T) { + immutabilityProperty := func(b []byte) bool { + if len(b) == 0 { + return BytesToString(b) == string(b) + } + s := BytesToString(b) + b[0] = 0 // modify byte slice + return s == BytesToString(b) + } + + assert.NoError(t, quick.Check(immutabilityProperty, nil)) +} + +// TestBytesToString_ConsistencyProperty checks if BytesToString returns consistent +// results for the same byte slice input, ensuring deterministic behavior. +func TestBytesToString_ConsistencyProperty(t *testing.T) { + consistencyProperty := func(b []byte) bool { + s1 := BytesToString(b) + s2 := BytesToString(b) + return s1 == s2 + } + + assert.NoError(t, quick.Check(consistencyProperty, nil)) +} diff --git a/pkg/custom_detectors/custom_detectors.go b/pkg/custom_detectors/custom_detectors.go index 4e6b8feea396..acf66828f5ba 100644 --- a/pkg/custom_detectors/custom_detectors.go +++ b/pkg/custom_detectors/custom_detectors.go @@ -8,11 +8,12 @@ import ( "regexp" "strings" + "golang.org/x/sync/errgroup" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/custom_detectorspb" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" - "golang.org/x/sync/errgroup" ) // The maximum number of matches from one chunk. This const is used when @@ -58,7 +59,7 @@ func NewWebhookCustomRegex(pb *custom_detectorspb.CustomRegex) (*CustomRegexWebh var httpClient = common.SaneHttpClient() func (c *CustomRegexWebhook) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) regexMatches := make(map[string][][]string, len(c.GetRegex())) // Find all submatches for each regex. diff --git a/pkg/detectors/abbysale/abbysale.go b/pkg/detectors/abbysale/abbysale.go index f71dfd76bb37..c5d7e1547967 100644 --- a/pkg/detectors/abbysale/abbysale.go +++ b/pkg/detectors/abbysale/abbysale.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Abbysale secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/abbysale/abbysale_test.go b/pkg/detectors/abbysale/abbysale_test.go index d45feadd4db4..78fd895d28ad 100644 --- a/pkg/detectors/abbysale/abbysale_test.go +++ b/pkg/detectors/abbysale/abbysale_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/abstract/abstract.go b/pkg/detectors/abstract/abstract.go index 5cdba22bba06..1d19829d8ea2 100644 --- a/pkg/detectors/abstract/abstract.go +++ b/pkg/detectors/abstract/abstract.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Abstract secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/abuseipdb/abuseipdb.go b/pkg/detectors/abuseipdb/abuseipdb.go index bcfda4826c62..412cd1873bc6 100644 --- a/pkg/detectors/abuseipdb/abuseipdb.go +++ b/pkg/detectors/abuseipdb/abuseipdb.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify AbuseIPDB secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/abuseipdb/abuseipdb_test.go b/pkg/detectors/abuseipdb/abuseipdb_test.go index 1f83936a6739..f51bbbb15f9b 100644 --- a/pkg/detectors/abuseipdb/abuseipdb_test.go +++ b/pkg/detectors/abuseipdb/abuseipdb_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/accuweather/accuweather.go b/pkg/detectors/accuweather/accuweather.go index bf15c6d12475..b3a0c51cc478 100644 --- a/pkg/detectors/accuweather/accuweather.go +++ b/pkg/detectors/accuweather/accuweather.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Accuweather secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/accuweather/accuweather_test.go b/pkg/detectors/accuweather/accuweather_test.go index 8b8d87330ebb..a9931ebad22d 100644 --- a/pkg/detectors/accuweather/accuweather_test.go +++ b/pkg/detectors/accuweather/accuweather_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/adafruitio/adafruitio.go b/pkg/detectors/adafruitio/adafruitio.go index f0c3271b353e..3beadc008f23 100644 --- a/pkg/detectors/adafruitio/adafruitio.go +++ b/pkg/detectors/adafruitio/adafruitio.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify AdafruitIO secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/adobeio/adobeio.go b/pkg/detectors/adobeio/adobeio.go index 2d9e24f1c3cc..b9c8a153b749 100644 --- a/pkg/detectors/adobeio/adobeio.go +++ b/pkg/detectors/adobeio/adobeio.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify AdobeIO secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/adobeio/adobeio_test.go b/pkg/detectors/adobeio/adobeio_test.go index a65d0035f229..be8e5792980d 100644 --- a/pkg/detectors/adobeio/adobeio_test.go +++ b/pkg/detectors/adobeio/adobeio_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/adzuna/adzuna.go b/pkg/detectors/adzuna/adzuna.go index b95862fc6200..76801cd6ef5e 100644 --- a/pkg/detectors/adzuna/adzuna.go +++ b/pkg/detectors/adzuna/adzuna.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Adzuna secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/adzuna/adzuna_test.go b/pkg/detectors/adzuna/adzuna_test.go index 6a804fc7b22b..153980a9dbeb 100644 --- a/pkg/detectors/adzuna/adzuna_test.go +++ b/pkg/detectors/adzuna/adzuna_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/aeroworkflow/aeroworkflow.go b/pkg/detectors/aeroworkflow/aeroworkflow.go index 7b905d7601b4..cd130ea3fba3 100644 --- a/pkg/detectors/aeroworkflow/aeroworkflow.go +++ b/pkg/detectors/aeroworkflow/aeroworkflow.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Aeroworkflow secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idmatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/agora/agora.go b/pkg/detectors/agora/agora.go index 07bb106e66c2..af1b65e9c16e 100644 --- a/pkg/detectors/agora/agora.go +++ b/pkg/detectors/agora/agora.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Agora secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) secretMatches := secretPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/agora/agora_test.go b/pkg/detectors/agora/agora_test.go index 2e8329aed4f0..2b3abd5cede7 100644 --- a/pkg/detectors/agora/agora_test.go +++ b/pkg/detectors/agora/agora_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/aha/aha.go b/pkg/detectors/aha/aha.go index 3007853d18b4..0ed3d57d0473 100644 --- a/pkg/detectors/aha/aha.go +++ b/pkg/detectors/aha/aha.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Aha secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/airbrakeprojectkey/airbrakeprojectkey.go b/pkg/detectors/airbrakeprojectkey/airbrakeprojectkey.go index 97342081ce45..228d6a8c682a 100644 --- a/pkg/detectors/airbrakeprojectkey/airbrakeprojectkey.go +++ b/pkg/detectors/airbrakeprojectkey/airbrakeprojectkey.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify AirbrakeProjectKey secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/airbrakeprojectkey/airbrakeprojectkey_test.go b/pkg/detectors/airbrakeprojectkey/airbrakeprojectkey_test.go index 3ce173571fcf..c43c72a71655 100644 --- a/pkg/detectors/airbrakeprojectkey/airbrakeprojectkey_test.go +++ b/pkg/detectors/airbrakeprojectkey/airbrakeprojectkey_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/airbrakeuserkey/airbrakeuserkey.go b/pkg/detectors/airbrakeuserkey/airbrakeuserkey.go index 06e260696788..8d0679329a08 100644 --- a/pkg/detectors/airbrakeuserkey/airbrakeuserkey.go +++ b/pkg/detectors/airbrakeuserkey/airbrakeuserkey.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify AirbrakeUserKey secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/airbrakeuserkey/airbrakeuserkey_test.go b/pkg/detectors/airbrakeuserkey/airbrakeuserkey_test.go index 462603268098..c1eaa350c0e4 100644 --- a/pkg/detectors/airbrakeuserkey/airbrakeuserkey_test.go +++ b/pkg/detectors/airbrakeuserkey/airbrakeuserkey_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/airship/airship.go b/pkg/detectors/airship/airship.go index 4ee0d00b17b5..2b1e93c1e9ec 100644 --- a/pkg/detectors/airship/airship.go +++ b/pkg/detectors/airship/airship.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Airship secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/airship/airship_test.go b/pkg/detectors/airship/airship_test.go index 75f3263db08d..8d1e74e5223c 100644 --- a/pkg/detectors/airship/airship_test.go +++ b/pkg/detectors/airship/airship_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/airtableapikey/airtableapikey.go b/pkg/detectors/airtableapikey/airtableapikey.go index fea0d844c39d..5d4c583b87cd 100644 --- a/pkg/detectors/airtableapikey/airtableapikey.go +++ b/pkg/detectors/airtableapikey/airtableapikey.go @@ -41,7 +41,7 @@ type response struct { // FromData will find and optionally verify AirtableApiKey secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) appMatches := appPat.FindAllStringSubmatch(dataStr, -1) keyMatches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/airtableapikey/airtableapikey_test.go b/pkg/detectors/airtableapikey/airtableapikey_test.go index cef78a00d24f..f8d14f5c7c74 100644 --- a/pkg/detectors/airtableapikey/airtableapikey_test.go +++ b/pkg/detectors/airtableapikey/airtableapikey_test.go @@ -13,6 +13,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" ) diff --git a/pkg/detectors/airvisual/airvisual.go b/pkg/detectors/airvisual/airvisual.go index 4a4ccf46b682..c2816dc31705 100644 --- a/pkg/detectors/airvisual/airvisual.go +++ b/pkg/detectors/airvisual/airvisual.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify AirVisual secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/airvisual/airvisual_test.go b/pkg/detectors/airvisual/airvisual_test.go index cef7e9488e08..4b305fd961fd 100644 --- a/pkg/detectors/airvisual/airvisual_test.go +++ b/pkg/detectors/airvisual/airvisual_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/aiven/aiven.go b/pkg/detectors/aiven/aiven.go index 9ed94729b692..f96e65e1fb7f 100644 --- a/pkg/detectors/aiven/aiven.go +++ b/pkg/detectors/aiven/aiven.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Aiven secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/aiven/aiven_test.go b/pkg/detectors/aiven/aiven_test.go index 69ba404cad65..d3ddb8293b26 100644 --- a/pkg/detectors/aiven/aiven_test.go +++ b/pkg/detectors/aiven/aiven_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/alchemy/alchemy.go b/pkg/detectors/alchemy/alchemy.go index 86cd69549e85..cf5b1a7279d2 100644 --- a/pkg/detectors/alchemy/alchemy.go +++ b/pkg/detectors/alchemy/alchemy.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Alchemy secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/alchemy/alchemy_test.go b/pkg/detectors/alchemy/alchemy_test.go index eb460d50f2f0..59a787f0b2dc 100644 --- a/pkg/detectors/alchemy/alchemy_test.go +++ b/pkg/detectors/alchemy/alchemy_test.go @@ -6,11 +6,12 @@ package alchemy import ( "context" "fmt" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "testing" "time" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/alconost/alconost.go b/pkg/detectors/alconost/alconost.go index 9ce7746cdd1c..ce18c46b9386 100644 --- a/pkg/detectors/alconost/alconost.go +++ b/pkg/detectors/alconost/alconost.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Alconost secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/alconost/alconost_test.go b/pkg/detectors/alconost/alconost_test.go index 96551e827b8c..15aacac01ef1 100644 --- a/pkg/detectors/alconost/alconost_test.go +++ b/pkg/detectors/alconost/alconost_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/alegra/alegra.go b/pkg/detectors/alegra/alegra.go index 681677f4c056..62daffeab362 100644 --- a/pkg/detectors/alegra/alegra.go +++ b/pkg/detectors/alegra/alegra.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Alegra secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/alegra/alegra_test.go b/pkg/detectors/alegra/alegra_test.go index 31fe6fb58bdd..51408a08bb32 100644 --- a/pkg/detectors/alegra/alegra_test.go +++ b/pkg/detectors/alegra/alegra_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/aletheiaapi/aletheiaapi.go b/pkg/detectors/aletheiaapi/aletheiaapi.go index 7e3e987c74aa..e7cf57a3fc1c 100644 --- a/pkg/detectors/aletheiaapi/aletheiaapi.go +++ b/pkg/detectors/aletheiaapi/aletheiaapi.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify AletheiaApi secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/aletheiaapi/aletheiaapi_test.go b/pkg/detectors/aletheiaapi/aletheiaapi_test.go index 32b39a124fc8..5ef6428c0459 100644 --- a/pkg/detectors/aletheiaapi/aletheiaapi_test.go +++ b/pkg/detectors/aletheiaapi/aletheiaapi_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/algoliaadminkey/algoliaadminkey.go b/pkg/detectors/algoliaadminkey/algoliaadminkey.go index bd5c43507877..531dd7823394 100644 --- a/pkg/detectors/algoliaadminkey/algoliaadminkey.go +++ b/pkg/detectors/algoliaadminkey/algoliaadminkey.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify AlgoliaAdminKey secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/algoliaadminkey/algoliaadminkey_test.go b/pkg/detectors/algoliaadminkey/algoliaadminkey_test.go index 3a6985580f32..4650d682379f 100644 --- a/pkg/detectors/algoliaadminkey/algoliaadminkey_test.go +++ b/pkg/detectors/algoliaadminkey/algoliaadminkey_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/alibaba/alibaba.go b/pkg/detectors/alibaba/alibaba.go index ef69f847f109..6040c564ec6b 100644 --- a/pkg/detectors/alibaba/alibaba.go +++ b/pkg/detectors/alibaba/alibaba.go @@ -63,7 +63,7 @@ func buildStringToSign(method, input string) string { // FromData will find and optionally verify Alibaba secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/alibaba/alibaba_test.go b/pkg/detectors/alibaba/alibaba_test.go index f6cf9bb4d190..6fb69addd00a 100644 --- a/pkg/detectors/alibaba/alibaba_test.go +++ b/pkg/detectors/alibaba/alibaba_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/alienvault/alienvault.go b/pkg/detectors/alienvault/alienvault.go index b1c434328114..9942f6a55efd 100644 --- a/pkg/detectors/alienvault/alienvault.go +++ b/pkg/detectors/alienvault/alienvault.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify AlienVault secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/alienvault/alienvault_test.go b/pkg/detectors/alienvault/alienvault_test.go index afff2582ad0f..0e2ea497e451 100644 --- a/pkg/detectors/alienvault/alienvault_test.go +++ b/pkg/detectors/alienvault/alienvault_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/allsports/allsports.go b/pkg/detectors/allsports/allsports.go index 2250e76908d0..af2767595d39 100644 --- a/pkg/detectors/allsports/allsports.go +++ b/pkg/detectors/allsports/allsports.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Allsports secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/allsports/allsports_test.go b/pkg/detectors/allsports/allsports_test.go index edf6454fc8b1..3049237e05a0 100644 --- a/pkg/detectors/allsports/allsports_test.go +++ b/pkg/detectors/allsports/allsports_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/amadeus/amadeus.go b/pkg/detectors/amadeus/amadeus.go index 2682f154fe52..a0a27b352555 100644 --- a/pkg/detectors/amadeus/amadeus.go +++ b/pkg/detectors/amadeus/amadeus.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Amadeus secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) secretMatches := secretPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/amadeus/amadeus_test.go b/pkg/detectors/amadeus/amadeus_test.go index 0f87057ca491..0cea37b247b0 100644 --- a/pkg/detectors/amadeus/amadeus_test.go +++ b/pkg/detectors/amadeus/amadeus_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/ambee/ambee.go b/pkg/detectors/ambee/ambee.go index d35ee2d55987..52542f65394a 100644 --- a/pkg/detectors/ambee/ambee.go +++ b/pkg/detectors/ambee/ambee.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Ambee secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/ambee/ambee_test.go b/pkg/detectors/ambee/ambee_test.go index 6ff21de9dc28..eb522ce5aeff 100644 --- a/pkg/detectors/ambee/ambee_test.go +++ b/pkg/detectors/ambee/ambee_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/amplitudeapikey/amplitudeapikey.go b/pkg/detectors/amplitudeapikey/amplitudeapikey.go index c39de0da0a2a..f739b5ebb225 100644 --- a/pkg/detectors/amplitudeapikey/amplitudeapikey.go +++ b/pkg/detectors/amplitudeapikey/amplitudeapikey.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify AmplitudeApiKey secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) secretMatches := secretPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/amplitudeapikey/amplitudeapikey_test.go b/pkg/detectors/amplitudeapikey/amplitudeapikey_test.go index 9028ed7fb419..e746cdf403df 100644 --- a/pkg/detectors/amplitudeapikey/amplitudeapikey_test.go +++ b/pkg/detectors/amplitudeapikey/amplitudeapikey_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/anthropic/anthropic.go b/pkg/detectors/anthropic/anthropic.go index 9168bf8f3f3c..25bde798db14 100644 --- a/pkg/detectors/anthropic/anthropic.go +++ b/pkg/detectors/anthropic/anthropic.go @@ -42,7 +42,7 @@ type response struct { // FromData will find and optionally verify Anthropic secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/anthropic/anthropic_test.go b/pkg/detectors/anthropic/anthropic_test.go index 7b4ec5155daa..af70eb7182b1 100644 --- a/pkg/detectors/anthropic/anthropic_test.go +++ b/pkg/detectors/anthropic/anthropic_test.go @@ -6,11 +6,12 @@ package anthropic import ( "context" "fmt" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "testing" "time" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/anypoint/anypoint.go b/pkg/detectors/anypoint/anypoint.go index b501da67357c..6523fd611f4f 100644 --- a/pkg/detectors/anypoint/anypoint.go +++ b/pkg/detectors/anypoint/anypoint.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Anypoint secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) orgMatches := orgPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/anypoint/anypoint_test.go b/pkg/detectors/anypoint/anypoint_test.go index e073314369c3..5b310f295e42 100644 --- a/pkg/detectors/anypoint/anypoint_test.go +++ b/pkg/detectors/anypoint/anypoint_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/apacta/apacta.go b/pkg/detectors/apacta/apacta.go index fea8c0ad26d6..468c54cba4fc 100644 --- a/pkg/detectors/apacta/apacta.go +++ b/pkg/detectors/apacta/apacta.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Apacta secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/apacta/apacta_test.go b/pkg/detectors/apacta/apacta_test.go index d80e7f04b6a2..38f80cb96111 100644 --- a/pkg/detectors/apacta/apacta_test.go +++ b/pkg/detectors/apacta/apacta_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/api2cart/api2cart.go b/pkg/detectors/api2cart/api2cart.go index 013b830dca76..ba60c4574854 100644 --- a/pkg/detectors/api2cart/api2cart.go +++ b/pkg/detectors/api2cart/api2cart.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Api2Cart secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) for _, match := range matches { diff --git a/pkg/detectors/api2cart/api2cart_test.go b/pkg/detectors/api2cart/api2cart_test.go index f0243d52bcc9..c7d628e6077a 100644 --- a/pkg/detectors/api2cart/api2cart_test.go +++ b/pkg/detectors/api2cart/api2cart_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/apideck/apideck.go b/pkg/detectors/apideck/apideck.go index 5bac10c5df30..05856889f38e 100644 --- a/pkg/detectors/apideck/apideck.go +++ b/pkg/detectors/apideck/apideck.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ApiDeck secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/apideck/apideck_test.go b/pkg/detectors/apideck/apideck_test.go index 30eb2fa7c989..9eeb444e26d7 100644 --- a/pkg/detectors/apideck/apideck_test.go +++ b/pkg/detectors/apideck/apideck_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/apiflash/apiflash.go b/pkg/detectors/apiflash/apiflash.go index 65209b7c8658..0db9703f7457 100644 --- a/pkg/detectors/apiflash/apiflash.go +++ b/pkg/detectors/apiflash/apiflash.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Apiflash secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) urlMatches := urlPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/apiflash/apiflash_test.go b/pkg/detectors/apiflash/apiflash_test.go index c457a47225f2..edb4bf387347 100644 --- a/pkg/detectors/apiflash/apiflash_test.go +++ b/pkg/detectors/apiflash/apiflash_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/apifonica/apifonica.go b/pkg/detectors/apifonica/apifonica.go index e47e24b5622d..3cc6688d418d 100644 --- a/pkg/detectors/apifonica/apifonica.go +++ b/pkg/detectors/apifonica/apifonica.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Apifonica secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) tokenMatches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/apifonica/apifonica_test.go b/pkg/detectors/apifonica/apifonica_test.go index 8df2c4cb50a8..5cd53c8791fe 100644 --- a/pkg/detectors/apifonica/apifonica_test.go +++ b/pkg/detectors/apifonica/apifonica_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/apify/apify.go b/pkg/detectors/apify/apify.go index e1e4361b4451..0691d4f5cf26 100644 --- a/pkg/detectors/apify/apify.go +++ b/pkg/detectors/apify/apify.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Apify secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/apify/apify_test.go b/pkg/detectors/apify/apify_test.go index 79e866953358..3f8b1a49bcf1 100644 --- a/pkg/detectors/apify/apify_test.go +++ b/pkg/detectors/apify/apify_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/apilayer/apilayer.go b/pkg/detectors/apilayer/apilayer.go index a0c92f537e3f..3f4e4df30dfb 100644 --- a/pkg/detectors/apilayer/apilayer.go +++ b/pkg/detectors/apilayer/apilayer.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Apilayer secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/apilayer/apilayer_test.go b/pkg/detectors/apilayer/apilayer_test.go index e764f3db11b0..e3ae150e585a 100644 --- a/pkg/detectors/apilayer/apilayer_test.go +++ b/pkg/detectors/apilayer/apilayer_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/apimatic/apimatic.go b/pkg/detectors/apimatic/apimatic.go index 2ea2e070c1a9..201725ee5176 100644 --- a/pkg/detectors/apimatic/apimatic.go +++ b/pkg/detectors/apimatic/apimatic.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify APIMatic secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) passMatches := passPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/apiscience/apiscience.go b/pkg/detectors/apiscience/apiscience.go index e26e2fd3f524..f21791ecd999 100644 --- a/pkg/detectors/apiscience/apiscience.go +++ b/pkg/detectors/apiscience/apiscience.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ApiScience secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/apiscience/apiscience_test.go b/pkg/detectors/apiscience/apiscience_test.go index 857fcfabb945..ac900518ed11 100644 --- a/pkg/detectors/apiscience/apiscience_test.go +++ b/pkg/detectors/apiscience/apiscience_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/apitemplate/apitemplate.go b/pkg/detectors/apitemplate/apitemplate.go index d7e403edc2aa..2f8a2a40e164 100644 --- a/pkg/detectors/apitemplate/apitemplate.go +++ b/pkg/detectors/apitemplate/apitemplate.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify APITemplate secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/apitemplate/apitemplate_test.go b/pkg/detectors/apitemplate/apitemplate_test.go index ff20dbdbd821..3687d8727e07 100644 --- a/pkg/detectors/apitemplate/apitemplate_test.go +++ b/pkg/detectors/apitemplate/apitemplate_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/apollo/apollo.go b/pkg/detectors/apollo/apollo.go index ef9664943153..87e22f739737 100644 --- a/pkg/detectors/apollo/apollo.go +++ b/pkg/detectors/apollo/apollo.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Apollo secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/apollo/apollo_test.go b/pkg/detectors/apollo/apollo_test.go index 99ea2c755f97..a4159f9b5b30 100644 --- a/pkg/detectors/apollo/apollo_test.go +++ b/pkg/detectors/apollo/apollo_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/appcues/appcues.go b/pkg/detectors/appcues/appcues.go index f3d168a54ffc..b899c694e2ae 100644 --- a/pkg/detectors/appcues/appcues.go +++ b/pkg/detectors/appcues/appcues.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Appcues secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) userMatches := userPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/appcues/appcues_test.go b/pkg/detectors/appcues/appcues_test.go index c46205d002dc..35afcb69474a 100644 --- a/pkg/detectors/appcues/appcues_test.go +++ b/pkg/detectors/appcues/appcues_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/appfollow/appfollow.go b/pkg/detectors/appfollow/appfollow.go index 7e3e37abf0d7..c540f2968d05 100644 --- a/pkg/detectors/appfollow/appfollow.go +++ b/pkg/detectors/appfollow/appfollow.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Appfollow secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/appfollow/appfollow_test.go b/pkg/detectors/appfollow/appfollow_test.go index fd6e46745cec..6c4408af4f55 100644 --- a/pkg/detectors/appfollow/appfollow_test.go +++ b/pkg/detectors/appfollow/appfollow_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/appointedd/appointedd.go b/pkg/detectors/appointedd/appointedd.go index 2ce2c0378eb4..d8619a956a6e 100644 --- a/pkg/detectors/appointedd/appointedd.go +++ b/pkg/detectors/appointedd/appointedd.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify appointedd secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/appointedd/appointedd_test.go b/pkg/detectors/appointedd/appointedd_test.go index 3323032ef469..069a0bdb7221 100644 --- a/pkg/detectors/appointedd/appointedd_test.go +++ b/pkg/detectors/appointedd/appointedd_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/appoptics/appoptics.go b/pkg/detectors/appoptics/appoptics.go index f2bf45497497..456c9a2d2236 100644 --- a/pkg/detectors/appoptics/appoptics.go +++ b/pkg/detectors/appoptics/appoptics.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Appoptics secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/appoptics/appoptics_test.go b/pkg/detectors/appoptics/appoptics_test.go index 736bf738e82f..d115206c9bbe 100644 --- a/pkg/detectors/appoptics/appoptics_test.go +++ b/pkg/detectors/appoptics/appoptics_test.go @@ -86,7 +86,7 @@ func TestAppoptics_FromChunk(t *testing.T) { want: nil, wantErr: false, wantVerificationErr: false, - }, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/pkg/detectors/appsynergy/appsynergy.go b/pkg/detectors/appsynergy/appsynergy.go index 57284e2412ba..b41300584489 100644 --- a/pkg/detectors/appsynergy/appsynergy.go +++ b/pkg/detectors/appsynergy/appsynergy.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify AppSynergy secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/appsynergy/appsynergy_test.go b/pkg/detectors/appsynergy/appsynergy_test.go index 363af075ed58..f03389d784b7 100644 --- a/pkg/detectors/appsynergy/appsynergy_test.go +++ b/pkg/detectors/appsynergy/appsynergy_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/apptivo/apptivo.go b/pkg/detectors/apptivo/apptivo.go index 0763e06a93d4..c4afc1a7a6de 100644 --- a/pkg/detectors/apptivo/apptivo.go +++ b/pkg/detectors/apptivo/apptivo.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Apptivo secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/apptivo/apptivo_test.go b/pkg/detectors/apptivo/apptivo_test.go index d86c9872724e..771f8a5f0159 100644 --- a/pkg/detectors/apptivo/apptivo_test.go +++ b/pkg/detectors/apptivo/apptivo_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/artifactory/artifactory.go b/pkg/detectors/artifactory/artifactory.go index e0af41f4d659..19bb7a4ec60b 100644 --- a/pkg/detectors/artifactory/artifactory.go +++ b/pkg/detectors/artifactory/artifactory.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Artifactory secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) URLmatches := URLPat.FindAllStringSubmatch(dataStr, -1) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/artifactory/artifactory_test.go b/pkg/detectors/artifactory/artifactory_test.go index c33dcdc30042..3fb570aebf0b 100644 --- a/pkg/detectors/artifactory/artifactory_test.go +++ b/pkg/detectors/artifactory/artifactory_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/artsy/artsy.go b/pkg/detectors/artsy/artsy.go index 2cd90e0197c7..a2e9fbc9b0f8 100644 --- a/pkg/detectors/artsy/artsy.go +++ b/pkg/detectors/artsy/artsy.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Artsy secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idmatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/artsy/artsy_test.go b/pkg/detectors/artsy/artsy_test.go index bf44ba496710..5c890ad1d1b7 100644 --- a/pkg/detectors/artsy/artsy_test.go +++ b/pkg/detectors/artsy/artsy_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/asanaoauth/asanaoauth.go b/pkg/detectors/asanaoauth/asanaoauth.go index e20c07f28385..c4036115befd 100644 --- a/pkg/detectors/asanaoauth/asanaoauth.go +++ b/pkg/detectors/asanaoauth/asanaoauth.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify AsanaOauth secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/asanaoauth/asanaoauth_test.go b/pkg/detectors/asanaoauth/asanaoauth_test.go index 88f93066d4ea..cf876f7bda29 100644 --- a/pkg/detectors/asanaoauth/asanaoauth_test.go +++ b/pkg/detectors/asanaoauth/asanaoauth_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/asanapersonalaccesstoken/asanapersonalaccesstoken.go b/pkg/detectors/asanapersonalaccesstoken/asanapersonalaccesstoken.go index de5a83d7f6f9..383fb68b31cc 100644 --- a/pkg/detectors/asanapersonalaccesstoken/asanapersonalaccesstoken.go +++ b/pkg/detectors/asanapersonalaccesstoken/asanapersonalaccesstoken.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify AsanaPersonalAccessToken secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/asanapersonalaccesstoken/asanapersonalaccesstoken_test.go b/pkg/detectors/asanapersonalaccesstoken/asanapersonalaccesstoken_test.go index 97a61d918f42..a153d789e30a 100644 --- a/pkg/detectors/asanapersonalaccesstoken/asanapersonalaccesstoken_test.go +++ b/pkg/detectors/asanapersonalaccesstoken/asanapersonalaccesstoken_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/assemblyai/assemblyai.go b/pkg/detectors/assemblyai/assemblyai.go index 0a55dc376e04..04d1defd48bc 100644 --- a/pkg/detectors/assemblyai/assemblyai.go +++ b/pkg/detectors/assemblyai/assemblyai.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Assemblyai secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/assemblyai/assemblyai_test.go b/pkg/detectors/assemblyai/assemblyai_test.go index f042fb413469..9c6fb6d661fa 100644 --- a/pkg/detectors/assemblyai/assemblyai_test.go +++ b/pkg/detectors/assemblyai/assemblyai_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/atera/atera.go b/pkg/detectors/atera/atera.go index 8b5d89da1619..3f35ac258308 100644 --- a/pkg/detectors/atera/atera.go +++ b/pkg/detectors/atera/atera.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Atera secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/atera/atera_test.go b/pkg/detectors/atera/atera_test.go index ee90eafbc080..5e49cfd4b9ad 100644 --- a/pkg/detectors/atera/atera_test.go +++ b/pkg/detectors/atera/atera_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/audd/audd.go b/pkg/detectors/audd/audd.go index 439ff4c1714d..757965e11c91 100644 --- a/pkg/detectors/audd/audd.go +++ b/pkg/detectors/audd/audd.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Audd secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/auth0managementapitoken/auth0managementapitoken.go b/pkg/detectors/auth0managementapitoken/auth0managementapitoken.go index 358ed1aea120..e637d004ba40 100644 --- a/pkg/detectors/auth0managementapitoken/auth0managementapitoken.go +++ b/pkg/detectors/auth0managementapitoken/auth0managementapitoken.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Auth0ManagementApiToken secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) managementApiTokenMatches := managementApiTokenPat.FindAllStringSubmatch(dataStr, -1) domainMatches := domainPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/auth0managementapitoken/auth0managementapitoken_test.go b/pkg/detectors/auth0managementapitoken/auth0managementapitoken_test.go index 32a0ac059883..96bac9d1325d 100644 --- a/pkg/detectors/auth0managementapitoken/auth0managementapitoken_test.go +++ b/pkg/detectors/auth0managementapitoken/auth0managementapitoken_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/auth0oauth/auth0oauth.go b/pkg/detectors/auth0oauth/auth0oauth.go index d5db3ad6f0c6..37fb539bb4d2 100644 --- a/pkg/detectors/auth0oauth/auth0oauth.go +++ b/pkg/detectors/auth0oauth/auth0oauth.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Auth0oauth secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) clientIdMatches := clientIdPat.FindAllStringSubmatch(dataStr, -1) clientSecretMatches := clientSecretPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/auth0oauth/auth0oauth_test.go b/pkg/detectors/auth0oauth/auth0oauth_test.go index 5a343487d7ac..17f68f7d0b71 100644 --- a/pkg/detectors/auth0oauth/auth0oauth_test.go +++ b/pkg/detectors/auth0oauth/auth0oauth_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/autodesk/autodesk.go b/pkg/detectors/autodesk/autodesk.go index a02ccbf8d28c..f93105719309 100644 --- a/pkg/detectors/autodesk/autodesk.go +++ b/pkg/detectors/autodesk/autodesk.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Autodesk secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) secretMatches := secretPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/autodesk/autodesk_test.go b/pkg/detectors/autodesk/autodesk_test.go index d3d90c83c811..1fe80dc0c4dd 100644 --- a/pkg/detectors/autodesk/autodesk_test.go +++ b/pkg/detectors/autodesk/autodesk_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/autoklose/autoklose.go b/pkg/detectors/autoklose/autoklose.go index 77f3f2ac2be6..bc483a793b45 100644 --- a/pkg/detectors/autoklose/autoklose.go +++ b/pkg/detectors/autoklose/autoklose.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Autoklose secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/autoklose/autoklose_test.go b/pkg/detectors/autoklose/autoklose_test.go index 3976ccf761fd..751e9935d26b 100644 --- a/pkg/detectors/autoklose/autoklose_test.go +++ b/pkg/detectors/autoklose/autoklose_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/autopilot/autopilot.go b/pkg/detectors/autopilot/autopilot.go index bf14824e6747..28b7667339bc 100644 --- a/pkg/detectors/autopilot/autopilot.go +++ b/pkg/detectors/autopilot/autopilot.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify AutoPilot secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/autopilot/autopilot_test.go b/pkg/detectors/autopilot/autopilot_test.go index b15e26cd8e27..852d0af01ae3 100644 --- a/pkg/detectors/autopilot/autopilot_test.go +++ b/pkg/detectors/autopilot/autopilot_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/avazapersonalaccesstoken/avazapersonalaccesstoken.go b/pkg/detectors/avazapersonalaccesstoken/avazapersonalaccesstoken.go index 9bcda4010a9b..00db7cc5ebae 100644 --- a/pkg/detectors/avazapersonalaccesstoken/avazapersonalaccesstoken.go +++ b/pkg/detectors/avazapersonalaccesstoken/avazapersonalaccesstoken.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify AvazaPersonalAccessToken secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/aviationstack/aviationstack.go b/pkg/detectors/aviationstack/aviationstack.go index f2f251bca637..98bf3e2a1b09 100644 --- a/pkg/detectors/aviationstack/aviationstack.go +++ b/pkg/detectors/aviationstack/aviationstack.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify AviationStack secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/aviationstack/aviationstack_test.go b/pkg/detectors/aviationstack/aviationstack_test.go index b716fcd195e7..33fc77ee00b0 100644 --- a/pkg/detectors/aviationstack/aviationstack_test.go +++ b/pkg/detectors/aviationstack/aviationstack_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/aws/aws.go b/pkg/detectors/aws/aws.go index ca67ddec05a0..9889f9ed80a7 100644 --- a/pkg/detectors/aws/aws.go +++ b/pkg/detectors/aws/aws.go @@ -103,7 +103,7 @@ func GetHMAC(key []byte, data []byte) []byte { // FromData will find and optionally verify AWS secrets in a given set of bytes. func (s scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) secretMatches := secretPat.FindAllStringSubmatch(dataStr, -1) @@ -139,11 +139,11 @@ func (s scanner) FromData(ctx context.Context, verify bool, data []byte) (result if verify { verified, extraData, verificationErr := s.verifyMatch(ctx, resIDMatch, resSecretMatch, true) s1.Verified = verified - //It'd be good to log when calculated account value does not match - //the account value from verification. Should only be edge cases at most. - //if extraData["account"] != s1.ExtraData["account"] && extraData["account"] != "" {//log here} + // It'd be good to log when calculated account value does not match + // the account value from verification. Should only be edge cases at most. + // if extraData["account"] != s1.ExtraData["account"] && extraData["account"] != "" {//log here} - //Append the extraData to the existing ExtraData map. + // Append the extraData to the existing ExtraData map. // This will overwrite with the new verified values. for k, v := range extraData { s1.ExtraData[k] = v diff --git a/pkg/detectors/aws/aws_test.go b/pkg/detectors/aws/aws_test.go index 0d1ac08b5251..0878b22a031c 100644 --- a/pkg/detectors/aws/aws_test.go +++ b/pkg/detectors/aws/aws_test.go @@ -12,6 +12,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" diff --git a/pkg/detectors/awssessionkeys/awssessionkey.go b/pkg/detectors/awssessionkeys/awssessionkey.go index aee31402b9ed..dceb41d131d6 100644 --- a/pkg/detectors/awssessionkeys/awssessionkey.go +++ b/pkg/detectors/awssessionkeys/awssessionkey.go @@ -93,7 +93,7 @@ func checkSessionToken(sessionToken string, secret string) bool { // FromData will find and optionally verify AWS secrets in a given set of bytes. func (s scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) secretMatches := secretPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/axonaut/axonaut.go b/pkg/detectors/axonaut/axonaut.go index 4464f5982184..f9ef24977964 100644 --- a/pkg/detectors/axonaut/axonaut.go +++ b/pkg/detectors/axonaut/axonaut.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Axonaut secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/axonaut/axonaut_test.go b/pkg/detectors/axonaut/axonaut_test.go index 0d64cbc64e1e..643876f13e69 100644 --- a/pkg/detectors/axonaut/axonaut_test.go +++ b/pkg/detectors/axonaut/axonaut_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/aylien/aylien.go b/pkg/detectors/aylien/aylien.go index cfa4407c9d43..847a50e9e5f6 100644 --- a/pkg/detectors/aylien/aylien.go +++ b/pkg/detectors/aylien/aylien.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Aylien secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/aylien/aylien_test.go b/pkg/detectors/aylien/aylien_test.go index e1315f5f9b66..ae758ac32287 100644 --- a/pkg/detectors/aylien/aylien_test.go +++ b/pkg/detectors/aylien/aylien_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/ayrshare/ayrshare.go b/pkg/detectors/ayrshare/ayrshare.go index 2c013a232dfa..8c5f98f904fa 100644 --- a/pkg/detectors/ayrshare/ayrshare.go +++ b/pkg/detectors/ayrshare/ayrshare.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Ayrshare secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/ayrshare/ayrshare_test.go b/pkg/detectors/ayrshare/ayrshare_test.go index da11fac95ea7..be5c5f360481 100644 --- a/pkg/detectors/ayrshare/ayrshare_test.go +++ b/pkg/detectors/ayrshare/ayrshare_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/azure/azure.go b/pkg/detectors/azure/azure.go index 67a54e371678..62b671c20f70 100644 --- a/pkg/detectors/azure/azure.go +++ b/pkg/detectors/azure/azure.go @@ -8,6 +8,7 @@ import ( "github.com/Azure/go-autorest/autorest/azure/auth" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" ) @@ -43,7 +44,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Azure secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) clientSecretMatches := clientSecretPat.FindAllStringSubmatch(dataStr, -1) for _, clientSecret := range clientSecretMatches { diff --git a/pkg/detectors/azure/azure_test.go b/pkg/detectors/azure/azure_test.go index 9ecc18ab14a5..8af96ec6afa6 100644 --- a/pkg/detectors/azure/azure_test.go +++ b/pkg/detectors/azure/azure_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" diff --git a/pkg/detectors/azurebatch/azurebatch.go b/pkg/detectors/azurebatch/azurebatch.go index 576fcd43af40..e6dc0a2da299 100644 --- a/pkg/detectors/azurebatch/azurebatch.go +++ b/pkg/detectors/azurebatch/azurebatch.go @@ -38,7 +38,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Azurebatch secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) urlMatches := urlPat.FindAllStringSubmatch(dataStr, -1) secretMatches := secretPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/azurecontainerregistry/azurecontainerregistry.go b/pkg/detectors/azurecontainerregistry/azurecontainerregistry.go index 6698c338c2ea..651d955ef336 100644 --- a/pkg/detectors/azurecontainerregistry/azurecontainerregistry.go +++ b/pkg/detectors/azurecontainerregistry/azurecontainerregistry.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Azurecontainerregistry secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) urlMatches := url.FindAllStringSubmatch(dataStr, -1) passwordMatches := password.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/azurecontainerregistry/azurecontainerregistry_test.go b/pkg/detectors/azurecontainerregistry/azurecontainerregistry_test.go index ede6611f771e..5c1dd70cbfe2 100644 --- a/pkg/detectors/azurecontainerregistry/azurecontainerregistry_test.go +++ b/pkg/detectors/azurecontainerregistry/azurecontainerregistry_test.go @@ -6,11 +6,12 @@ package azurecontainerregistry import ( "context" "fmt" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "testing" "time" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" @@ -28,7 +29,6 @@ func TestAzureContainerRegistry_FromChunk(t *testing.T) { password := testSecrets.MustGetField("AZURE_CR_PASSWORD") passwordInactive := testSecrets.MustGetField("AZURE_CR_PASSWORD_INACTIVE") - type args struct { ctx context.Context data []byte @@ -104,7 +104,7 @@ func TestAzureContainerRegistry_FromChunk(t *testing.T) { t.Fatalf("wantVerificationError = %v, verification error = %v", tt.wantVerificationErr, got[i].VerificationError) } } - ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "RawV2", "Raw","Redacted", "VerificationError") + ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "RawV2", "Raw", "Redacted", "VerificationError") if diff := cmp.Diff(got, tt.want, ignoreOpts); diff != "" { t.Errorf("AzureContainerRegistry.FromData() %s diff: (-got +want)\n%s", tt.name, diff) } diff --git a/pkg/detectors/azurestorage/azurestorage.go b/pkg/detectors/azurestorage/azurestorage.go index d6f221529985..33e9a5549cac 100644 --- a/pkg/detectors/azurestorage/azurestorage.go +++ b/pkg/detectors/azurestorage/azurestorage.go @@ -11,6 +11,7 @@ import ( "strings" "time" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" ) @@ -31,7 +32,7 @@ func (s Scanner) Keywords() []string { } func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/bannerbear/bannerbear.go b/pkg/detectors/bannerbear/bannerbear.go index 3ab0ae88d548..cdc0db2798e4 100644 --- a/pkg/detectors/bannerbear/bannerbear.go +++ b/pkg/detectors/bannerbear/bannerbear.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Bannerbear secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/bannerbear/bannerbear_test.go b/pkg/detectors/bannerbear/bannerbear_test.go index 263daa202cfc..041166866b9b 100644 --- a/pkg/detectors/bannerbear/bannerbear_test.go +++ b/pkg/detectors/bannerbear/bannerbear_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/baremetrics/baremetrics.go b/pkg/detectors/baremetrics/baremetrics.go index 9d29b6722c93..8fb611bf7328 100644 --- a/pkg/detectors/baremetrics/baremetrics.go +++ b/pkg/detectors/baremetrics/baremetrics.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Baremetrics secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/baremetrics/baremetrics_test.go b/pkg/detectors/baremetrics/baremetrics_test.go index 87fde4b24191..ab8ca23ecf6d 100644 --- a/pkg/detectors/baremetrics/baremetrics_test.go +++ b/pkg/detectors/baremetrics/baremetrics_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/beamer/beamer.go b/pkg/detectors/beamer/beamer.go index 30f7333d1a3a..ac874aa589f2 100644 --- a/pkg/detectors/beamer/beamer.go +++ b/pkg/detectors/beamer/beamer.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Beamer secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/beamer/beamer_test.go b/pkg/detectors/beamer/beamer_test.go index 2fd40a34aed9..2b6a1c28cfee 100644 --- a/pkg/detectors/beamer/beamer_test.go +++ b/pkg/detectors/beamer/beamer_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/beebole/beebole.go b/pkg/detectors/beebole/beebole.go index f7464231060c..bd745ed8a2c4 100644 --- a/pkg/detectors/beebole/beebole.go +++ b/pkg/detectors/beebole/beebole.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Beebole secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/beebole/beebole_test.go b/pkg/detectors/beebole/beebole_test.go index 8dc52fc458b5..b559260026d7 100644 --- a/pkg/detectors/beebole/beebole_test.go +++ b/pkg/detectors/beebole/beebole_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/besnappy/besnappy.go b/pkg/detectors/besnappy/besnappy.go index d51d93f4c905..6f484bb4e0dc 100644 --- a/pkg/detectors/besnappy/besnappy.go +++ b/pkg/detectors/besnappy/besnappy.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Besnappy secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/besnappy/besnappy_test.go b/pkg/detectors/besnappy/besnappy_test.go index bab5c5563160..d5c8d21249cd 100644 --- a/pkg/detectors/besnappy/besnappy_test.go +++ b/pkg/detectors/besnappy/besnappy_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/besttime/besttime.go b/pkg/detectors/besttime/besttime.go index e251de7c8101..dfc24ca119ee 100644 --- a/pkg/detectors/besttime/besttime.go +++ b/pkg/detectors/besttime/besttime.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Besttime secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/besttime/besttime_test.go b/pkg/detectors/besttime/besttime_test.go index 902377d769fa..900f1c2e70b3 100644 --- a/pkg/detectors/besttime/besttime_test.go +++ b/pkg/detectors/besttime/besttime_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/betterstack/betterstack.go b/pkg/detectors/betterstack/betterstack.go index 8036ec9351a5..658b0aa95f4f 100644 --- a/pkg/detectors/betterstack/betterstack.go +++ b/pkg/detectors/betterstack/betterstack.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Betterstack secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/billomat/billomat.go b/pkg/detectors/billomat/billomat.go index 8eb7756206df..fa9e1f8b0af1 100644 --- a/pkg/detectors/billomat/billomat.go +++ b/pkg/detectors/billomat/billomat.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Billomat secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/billomat/billomat_test.go b/pkg/detectors/billomat/billomat_test.go index 745e16291021..2f761cdf94a6 100644 --- a/pkg/detectors/billomat/billomat_test.go +++ b/pkg/detectors/billomat/billomat_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/bitbar/bitbar.go b/pkg/detectors/bitbar/bitbar.go index 4463fe035236..004832b93bf7 100644 --- a/pkg/detectors/bitbar/bitbar.go +++ b/pkg/detectors/bitbar/bitbar.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Bitbar secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/bitcoinaverage/bitcoinaverage.go b/pkg/detectors/bitcoinaverage/bitcoinaverage.go index bcbe1ce156ee..2ff53b99e63d 100644 --- a/pkg/detectors/bitcoinaverage/bitcoinaverage.go +++ b/pkg/detectors/bitcoinaverage/bitcoinaverage.go @@ -37,7 +37,7 @@ type response struct { // FromData will find and optionally verify BitcoinAverage secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/bitcoinaverage/bitcoinaverage_test.go b/pkg/detectors/bitcoinaverage/bitcoinaverage_test.go index 87a78cd52c20..6a23218b0090 100644 --- a/pkg/detectors/bitcoinaverage/bitcoinaverage_test.go +++ b/pkg/detectors/bitcoinaverage/bitcoinaverage_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/bitfinex/bitfinex.go b/pkg/detectors/bitfinex/bitfinex.go index c53c9f07ee08..7d0b98aadffa 100644 --- a/pkg/detectors/bitfinex/bitfinex.go +++ b/pkg/detectors/bitfinex/bitfinex.go @@ -8,6 +8,7 @@ import ( "strings" "github.com/bitfinexcom/bitfinex-api-go/v2/rest" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" @@ -39,7 +40,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Bitfinex secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) apiKeyMatches := apiKeyPat.FindAllStringSubmatch(dataStr, -1) apiSecretMatches := apiSecretPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/bitfinex/bitfinex_test.go b/pkg/detectors/bitfinex/bitfinex_test.go index 479f9a964f04..e197fb7d48c8 100644 --- a/pkg/detectors/bitfinex/bitfinex_test.go +++ b/pkg/detectors/bitfinex/bitfinex_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/bitlyaccesstoken/bitlyaccesstoken.go b/pkg/detectors/bitlyaccesstoken/bitlyaccesstoken.go index 30ce2d1f22a5..f386118d622c 100644 --- a/pkg/detectors/bitlyaccesstoken/bitlyaccesstoken.go +++ b/pkg/detectors/bitlyaccesstoken/bitlyaccesstoken.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify BitLyAccessToken secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/bitlyaccesstoken/bitlyaccesstoken_test.go b/pkg/detectors/bitlyaccesstoken/bitlyaccesstoken_test.go index e4625d2639be..a64b7a7c469c 100644 --- a/pkg/detectors/bitlyaccesstoken/bitlyaccesstoken_test.go +++ b/pkg/detectors/bitlyaccesstoken/bitlyaccesstoken_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/bitmex/bitmex.go b/pkg/detectors/bitmex/bitmex.go index d83e8f4d422c..e60f3782256b 100644 --- a/pkg/detectors/bitmex/bitmex.go +++ b/pkg/detectors/bitmex/bitmex.go @@ -38,7 +38,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Bitmex secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) secretMatches := secretPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/bitmex/bitmex_test.go b/pkg/detectors/bitmex/bitmex_test.go index 9aefeabd7df9..5d1588eed6a8 100644 --- a/pkg/detectors/bitmex/bitmex_test.go +++ b/pkg/detectors/bitmex/bitmex_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/blazemeter/blazemeter.go b/pkg/detectors/blazemeter/blazemeter.go index de794b75feec..ba715dc55c56 100644 --- a/pkg/detectors/blazemeter/blazemeter.go +++ b/pkg/detectors/blazemeter/blazemeter.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Blazemeter secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/blazemeter/blazemeter_test.go b/pkg/detectors/blazemeter/blazemeter_test.go index 12d958cb23a8..b298e4b55f62 100644 --- a/pkg/detectors/blazemeter/blazemeter_test.go +++ b/pkg/detectors/blazemeter/blazemeter_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/blitapp/blitapp.go b/pkg/detectors/blitapp/blitapp.go index 430945870000..9dae7a11d37a 100644 --- a/pkg/detectors/blitapp/blitapp.go +++ b/pkg/detectors/blitapp/blitapp.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify BlitApp secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/blitapp/blitapp_test.go b/pkg/detectors/blitapp/blitapp_test.go index 01e4e9df16a9..0a22e65c79b7 100644 --- a/pkg/detectors/blitapp/blitapp_test.go +++ b/pkg/detectors/blitapp/blitapp_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/blocknative/blocknative.go b/pkg/detectors/blocknative/blocknative.go index 2da32a623f46..6b7af1748fe4 100644 --- a/pkg/detectors/blocknative/blocknative.go +++ b/pkg/detectors/blocknative/blocknative.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Blocknative secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/blocknative/blocknative_test.go b/pkg/detectors/blocknative/blocknative_test.go index d781cc699589..a6151bd34fa0 100644 --- a/pkg/detectors/blocknative/blocknative_test.go +++ b/pkg/detectors/blocknative/blocknative_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/blogger/blogger.go b/pkg/detectors/blogger/blogger.go index 7070b619b64b..7f55ea40aca1 100644 --- a/pkg/detectors/blogger/blogger.go +++ b/pkg/detectors/blogger/blogger.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Blogger secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) for _, match := range matches { diff --git a/pkg/detectors/blogger/blogger_test.go b/pkg/detectors/blogger/blogger_test.go index 4afd72354d5b..e1dbfeb589ca 100644 --- a/pkg/detectors/blogger/blogger_test.go +++ b/pkg/detectors/blogger/blogger_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/bombbomb/bombbomb.go b/pkg/detectors/bombbomb/bombbomb.go index e241e5433dc0..e73eb9230887 100644 --- a/pkg/detectors/bombbomb/bombbomb.go +++ b/pkg/detectors/bombbomb/bombbomb.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify BombBomb secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/boostnote/boostnote.go b/pkg/detectors/boostnote/boostnote.go index 83fa99d0534a..cc42e1563eae 100644 --- a/pkg/detectors/boostnote/boostnote.go +++ b/pkg/detectors/boostnote/boostnote.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify BoostNote secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/borgbase/borgbase.go b/pkg/detectors/borgbase/borgbase.go index 8a0267409c5e..45b521a0c8f8 100644 --- a/pkg/detectors/borgbase/borgbase.go +++ b/pkg/detectors/borgbase/borgbase.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Borgbase secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/braintreepayments/braintreepayments.go b/pkg/detectors/braintreepayments/braintreepayments.go index 1600945305d0..ca5c4e1efa94 100644 --- a/pkg/detectors/braintreepayments/braintreepayments.go +++ b/pkg/detectors/braintreepayments/braintreepayments.go @@ -41,7 +41,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify BraintreePayments secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/braintreepayments/braintreepayments_test.go b/pkg/detectors/braintreepayments/braintreepayments_test.go index 0713f124b614..931157fcf7d3 100644 --- a/pkg/detectors/braintreepayments/braintreepayments_test.go +++ b/pkg/detectors/braintreepayments/braintreepayments_test.go @@ -8,6 +8,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" diff --git a/pkg/detectors/brandfetch/brandfetch.go b/pkg/detectors/brandfetch/brandfetch.go index 606e7153c396..1e736dec1120 100644 --- a/pkg/detectors/brandfetch/brandfetch.go +++ b/pkg/detectors/brandfetch/brandfetch.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Brandfetch secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/brandfetch/brandfetch_test.go b/pkg/detectors/brandfetch/brandfetch_test.go index 76fe755e3eae..809ef0cc7634 100644 --- a/pkg/detectors/brandfetch/brandfetch_test.go +++ b/pkg/detectors/brandfetch/brandfetch_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/browserstack/browserstack.go b/pkg/detectors/browserstack/browserstack.go index 54cdf1aa880d..fc0ecf7957ba 100644 --- a/pkg/detectors/browserstack/browserstack.go +++ b/pkg/detectors/browserstack/browserstack.go @@ -37,7 +37,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify BrowserStack secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) userMatches := userPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/browserstack/browserstack_test.go b/pkg/detectors/browserstack/browserstack_test.go index e32b377f8727..4259c3de6576 100644 --- a/pkg/detectors/browserstack/browserstack_test.go +++ b/pkg/detectors/browserstack/browserstack_test.go @@ -11,6 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/browshot/browshot.go b/pkg/detectors/browshot/browshot.go index 4bd7266ec284..330b985fbc4a 100644 --- a/pkg/detectors/browshot/browshot.go +++ b/pkg/detectors/browshot/browshot.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Browshot secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/browshot/browshot_test.go b/pkg/detectors/browshot/browshot_test.go index 401ed17470eb..9a9acb3e6e68 100644 --- a/pkg/detectors/browshot/browshot_test.go +++ b/pkg/detectors/browshot/browshot_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/bscscan/bscscan.go b/pkg/detectors/bscscan/bscscan.go index ebd2718f933b..646cfdc46f0c 100644 --- a/pkg/detectors/bscscan/bscscan.go +++ b/pkg/detectors/bscscan/bscscan.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Bscscan secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) @@ -55,22 +55,22 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result res, err := client.Do(req) if err == nil { defer res.Body.Close() - bodyBytes, err := io.ReadAll(res.Body) - if err != nil { - continue - } - body := string(bodyBytes) - - if !strings.Contains(body, "NOTOK") { - s1.Verified = true - } else { - // This function will check false positives for common test words, but also it will make sur> - if detectors.IsKnownFalsePositive(resMatch, detectors.DefaultFalsePositives, true) { - continue - } - } - } - } + bodyBytes, err := io.ReadAll(res.Body) + if err != nil { + continue + } + body := string(bodyBytes) + + if !strings.Contains(body, "NOTOK") { + s1.Verified = true + } else { + // This function will check false positives for common test words, but also it will make sur> + if detectors.IsKnownFalsePositive(resMatch, detectors.DefaultFalsePositives, true) { + continue + } + } + } + } results = append(results, s1) } diff --git a/pkg/detectors/bscscan/bscscan_test.go b/pkg/detectors/bscscan/bscscan_test.go index b8bacbc2969f..e9bc89cd3cdd 100644 --- a/pkg/detectors/bscscan/bscscan_test.go +++ b/pkg/detectors/bscscan/bscscan_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/buddyns/buddyns.go b/pkg/detectors/buddyns/buddyns.go index fbf4d206cc66..2c4cbe754cac 100644 --- a/pkg/detectors/buddyns/buddyns.go +++ b/pkg/detectors/buddyns/buddyns.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Buddyns secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/buddyns/buddyns_test.go b/pkg/detectors/buddyns/buddyns_test.go index d1d84bf07093..13999bd67de0 100644 --- a/pkg/detectors/buddyns/buddyns_test.go +++ b/pkg/detectors/buddyns/buddyns_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/budibase/budibase.go b/pkg/detectors/budibase/budibase.go index 47f06242a5e0..7db310eabdaf 100644 --- a/pkg/detectors/budibase/budibase.go +++ b/pkg/detectors/budibase/budibase.go @@ -21,7 +21,7 @@ var _ detectors.Detector = (*Scanner)(nil) var ( defaultClient = common.SaneHttpClient() - + keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"budibase"}) + `\b([a-f0-9]{32}-[a-f0-9]{78,80})\b`) ) @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Budibase secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) @@ -54,7 +54,6 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result client = defaultClient } - // URL: https://docs.budibase.com/reference/appsearch // API searches for the app with given name, since we only need to check api key, sending any appname will work. payload := strings.NewReader(`{"name":"qwerty"}`) diff --git a/pkg/detectors/budibase/budibase_test.go b/pkg/detectors/budibase/budibase_test.go index 3cb2da696103..8198e4e98e66 100644 --- a/pkg/detectors/budibase/budibase_test.go +++ b/pkg/detectors/budibase/budibase_test.go @@ -68,8 +68,8 @@ func TestBudibase_FromChunk(t *testing.T) { }, want: []detectors.Result{ { - DetectorType: detectorspb.DetectorType_Budibase, - Verified: false, + DetectorType: detectorspb.DetectorType_Budibase, + Verified: false, VerificationError: fmt.Errorf("unexpected HTTP response status 403"), }, }, @@ -88,7 +88,6 @@ func TestBudibase_FromChunk(t *testing.T) { wantErr: false, wantVerificationErr: false, }, - } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/pkg/detectors/bugherd/bugherd.go b/pkg/detectors/bugherd/bugherd.go index f7c789cad222..9b1b58ede156 100644 --- a/pkg/detectors/bugherd/bugherd.go +++ b/pkg/detectors/bugherd/bugherd.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Bugherd secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/bugherd/bugherd_test.go b/pkg/detectors/bugherd/bugherd_test.go index 7d015a448d68..d21cdc4fe7e9 100644 --- a/pkg/detectors/bugherd/bugherd_test.go +++ b/pkg/detectors/bugherd/bugherd_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/bugsnag/bugsnag.go b/pkg/detectors/bugsnag/bugsnag.go index 1c4f7a33d299..aea9896ed800 100644 --- a/pkg/detectors/bugsnag/bugsnag.go +++ b/pkg/detectors/bugsnag/bugsnag.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Bugsnag secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/bugsnag/bugsnag_test.go b/pkg/detectors/bugsnag/bugsnag_test.go index 2d56674eb5b8..6fc90ec3d64b 100644 --- a/pkg/detectors/bugsnag/bugsnag_test.go +++ b/pkg/detectors/bugsnag/bugsnag_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/buildkite/buildkite.go b/pkg/detectors/buildkite/buildkite.go index d04c4c753da1..fe04901eb869 100644 --- a/pkg/detectors/buildkite/buildkite.go +++ b/pkg/detectors/buildkite/buildkite.go @@ -35,7 +35,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Buildkite secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/buildkitev2/buildkite.go b/pkg/detectors/buildkitev2/buildkite.go index 8e5d4a783d2e..d0e013e7d074 100644 --- a/pkg/detectors/buildkitev2/buildkite.go +++ b/pkg/detectors/buildkitev2/buildkite.go @@ -35,7 +35,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Buildkite secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/bulbul/bulbul.go b/pkg/detectors/bulbul/bulbul.go index 81e37ca04483..a7c21b5e2a3d 100644 --- a/pkg/detectors/bulbul/bulbul.go +++ b/pkg/detectors/bulbul/bulbul.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Bulbul secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/bulbul/bulbul_test.go b/pkg/detectors/bulbul/bulbul_test.go index e51371cf554e..bb8d6b162d8b 100644 --- a/pkg/detectors/bulbul/bulbul_test.go +++ b/pkg/detectors/bulbul/bulbul_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/bulksms/bulksms.go b/pkg/detectors/bulksms/bulksms.go index faf202736bd0..1f40ef7ca678 100644 --- a/pkg/detectors/bulksms/bulksms.go +++ b/pkg/detectors/bulksms/bulksms.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Bulksms secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/bulksms/bulksms_test.go b/pkg/detectors/bulksms/bulksms_test.go index b087cacc6ded..1bee558d9fcf 100644 --- a/pkg/detectors/bulksms/bulksms_test.go +++ b/pkg/detectors/bulksms/bulksms_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/buttercms/buttercms.go b/pkg/detectors/buttercms/buttercms.go index f6d83c2cc1bf..307ca5a69a7e 100644 --- a/pkg/detectors/buttercms/buttercms.go +++ b/pkg/detectors/buttercms/buttercms.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ButterCMS secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/buttercms/buttercms_test.go b/pkg/detectors/buttercms/buttercms_test.go index e4e5d13a7799..fd6cb4ce1a18 100644 --- a/pkg/detectors/buttercms/buttercms_test.go +++ b/pkg/detectors/buttercms/buttercms_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/caflou/caflou.go b/pkg/detectors/caflou/caflou.go index 8ff5c5e86faa..cb5f2745aca5 100644 --- a/pkg/detectors/caflou/caflou.go +++ b/pkg/detectors/caflou/caflou.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Caflou secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/caflou/caflou_test.go b/pkg/detectors/caflou/caflou_test.go index b8eb1bec3024..212238311283 100644 --- a/pkg/detectors/caflou/caflou_test.go +++ b/pkg/detectors/caflou/caflou_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/calendarific/calendarific.go b/pkg/detectors/calendarific/calendarific.go index 26e704a0b021..13c25b69041b 100644 --- a/pkg/detectors/calendarific/calendarific.go +++ b/pkg/detectors/calendarific/calendarific.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Calendarific secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/calendarific/calendarific_test.go b/pkg/detectors/calendarific/calendarific_test.go index 9b6fadba0109..2d299e1787eb 100644 --- a/pkg/detectors/calendarific/calendarific_test.go +++ b/pkg/detectors/calendarific/calendarific_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/calendlyapikey/calendlyapikey.go b/pkg/detectors/calendlyapikey/calendlyapikey.go index bdd92123d7b0..9622efc1f32e 100644 --- a/pkg/detectors/calendlyapikey/calendlyapikey.go +++ b/pkg/detectors/calendlyapikey/calendlyapikey.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify CalendlyApiKey secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/calendlyapikey/calendlyapikey_test.go b/pkg/detectors/calendlyapikey/calendlyapikey_test.go index 4f1e88a3a387..08752c5d88bb 100644 --- a/pkg/detectors/calendlyapikey/calendlyapikey_test.go +++ b/pkg/detectors/calendlyapikey/calendlyapikey_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/calorieninja/calorieninja.go b/pkg/detectors/calorieninja/calorieninja.go index 41f1608231b4..7a62d484e526 100644 --- a/pkg/detectors/calorieninja/calorieninja.go +++ b/pkg/detectors/calorieninja/calorieninja.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Calorieninja secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/calorieninja/calorieninja_test.go b/pkg/detectors/calorieninja/calorieninja_test.go index 4b680cb75011..271e33e56bb3 100644 --- a/pkg/detectors/calorieninja/calorieninja_test.go +++ b/pkg/detectors/calorieninja/calorieninja_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/campayn/campayn.go b/pkg/detectors/campayn/campayn.go index 3625a30783bc..d036fc1bdab6 100644 --- a/pkg/detectors/campayn/campayn.go +++ b/pkg/detectors/campayn/campayn.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Campayn secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/cannyio/cannyio.go b/pkg/detectors/cannyio/cannyio.go index e1bfd845c6f4..46c67061cdab 100644 --- a/pkg/detectors/cannyio/cannyio.go +++ b/pkg/detectors/cannyio/cannyio.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify CannyIo secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) for _, match := range matches { diff --git a/pkg/detectors/cannyio/cannyio_test.go b/pkg/detectors/cannyio/cannyio_test.go index 7226dcaf8355..93286aae876b 100644 --- a/pkg/detectors/cannyio/cannyio_test.go +++ b/pkg/detectors/cannyio/cannyio_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/capsulecrm/capsulecrm.go b/pkg/detectors/capsulecrm/capsulecrm.go index cb2e176c5f6d..b497fcbd44d6 100644 --- a/pkg/detectors/capsulecrm/capsulecrm.go +++ b/pkg/detectors/capsulecrm/capsulecrm.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify CapsuleCRM secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/capsulecrm/capsulecrm_test.go b/pkg/detectors/capsulecrm/capsulecrm_test.go index c63a12412703..5bc19a89decf 100644 --- a/pkg/detectors/capsulecrm/capsulecrm_test.go +++ b/pkg/detectors/capsulecrm/capsulecrm_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/captaindata/captaindata.go b/pkg/detectors/captaindata/captaindata.go index 308ddeeb22d8..e268fff70407 100644 --- a/pkg/detectors/captaindata/captaindata.go +++ b/pkg/detectors/captaindata/captaindata.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify CaptainData secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) projIdMatches := projIdPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/carboninterface/carboninterface.go b/pkg/detectors/carboninterface/carboninterface.go index eb29a4ab4e24..ed4a7137ec53 100644 --- a/pkg/detectors/carboninterface/carboninterface.go +++ b/pkg/detectors/carboninterface/carboninterface.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify CarbonInterface secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/carboninterface/carboninterface_test.go b/pkg/detectors/carboninterface/carboninterface_test.go index e002caa1c7ca..53d47da58ad9 100644 --- a/pkg/detectors/carboninterface/carboninterface_test.go +++ b/pkg/detectors/carboninterface/carboninterface_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/cashboard/cashboard.go b/pkg/detectors/cashboard/cashboard.go index df7110d82b76..341c2fc59b94 100644 --- a/pkg/detectors/cashboard/cashboard.go +++ b/pkg/detectors/cashboard/cashboard.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Cashboard secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) userMatches := userPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/caspio/caspio.go b/pkg/detectors/caspio/caspio.go index 6be190135d3d..6f1a4694b870 100644 --- a/pkg/detectors/caspio/caspio.go +++ b/pkg/detectors/caspio/caspio.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Caspio secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/censys/censys.go b/pkg/detectors/censys/censys.go index f9a0234d6dd8..f14818eb62e8 100644 --- a/pkg/detectors/censys/censys.go +++ b/pkg/detectors/censys/censys.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Censys secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/censys/censys_test.go b/pkg/detectors/censys/censys_test.go index 1b20923c4216..37cfd01cc310 100644 --- a/pkg/detectors/censys/censys_test.go +++ b/pkg/detectors/censys/censys_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/centralstationcrm/centralstationcrm.go b/pkg/detectors/centralstationcrm/centralstationcrm.go index 89b6b1f4f97c..176e4195c5dd 100644 --- a/pkg/detectors/centralstationcrm/centralstationcrm.go +++ b/pkg/detectors/centralstationcrm/centralstationcrm.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify CentralStationCRM secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/centralstationcrm/centralstationcrm_test.go b/pkg/detectors/centralstationcrm/centralstationcrm_test.go index 364ed8e829a1..61fc5e573e05 100644 --- a/pkg/detectors/centralstationcrm/centralstationcrm_test.go +++ b/pkg/detectors/centralstationcrm/centralstationcrm_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/cexio/cexio.go b/pkg/detectors/cexio/cexio.go index baf4f29c1b8f..e65382127ce9 100644 --- a/pkg/detectors/cexio/cexio.go +++ b/pkg/detectors/cexio/cexio.go @@ -41,7 +41,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify CexIO secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) keyMatches := keyPat.FindAllStringSubmatch(dataStr, -1) secretMatches := secretPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/chartmogul/chartmogul.go b/pkg/detectors/chartmogul/chartmogul.go index 03baa481fe66..655b7ae60449 100644 --- a/pkg/detectors/chartmogul/chartmogul.go +++ b/pkg/detectors/chartmogul/chartmogul.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Chartmogul secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/chartmogul/chartmogul_test.go b/pkg/detectors/chartmogul/chartmogul_test.go index 31d43fb4798e..e36206214895 100644 --- a/pkg/detectors/chartmogul/chartmogul_test.go +++ b/pkg/detectors/chartmogul/chartmogul_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/chatbot/chatbot.go b/pkg/detectors/chatbot/chatbot.go index 458810e6dd8e..8eb621bc8412 100644 --- a/pkg/detectors/chatbot/chatbot.go +++ b/pkg/detectors/chatbot/chatbot.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Chatbot secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/chatbot/chatbot_test.go b/pkg/detectors/chatbot/chatbot_test.go index ff62f399733c..54102f343ec3 100644 --- a/pkg/detectors/chatbot/chatbot_test.go +++ b/pkg/detectors/chatbot/chatbot_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/chatfule/chatfule.go b/pkg/detectors/chatfule/chatfule.go index 1fc150119cbb..5e69a1d1fcc8 100644 --- a/pkg/detectors/chatfule/chatfule.go +++ b/pkg/detectors/chatfule/chatfule.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Chatfule secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/checio/checio.go b/pkg/detectors/checio/checio.go index 690c8883192b..ba85908bd7f9 100644 --- a/pkg/detectors/checio/checio.go +++ b/pkg/detectors/checio/checio.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ChecIO secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/checio/checio_test.go b/pkg/detectors/checio/checio_test.go index e2fd6eafa416..4d9b89ca5dd7 100644 --- a/pkg/detectors/checio/checio_test.go +++ b/pkg/detectors/checio/checio_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/checklyhq/checklyhq.go b/pkg/detectors/checklyhq/checklyhq.go index ec89e87b635d..22d3f1cac50d 100644 --- a/pkg/detectors/checklyhq/checklyhq.go +++ b/pkg/detectors/checklyhq/checklyhq.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ChecklyHQ secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/checklyhq/checklyhq_test.go b/pkg/detectors/checklyhq/checklyhq_test.go index 8985924f788e..020828339319 100644 --- a/pkg/detectors/checklyhq/checklyhq_test.go +++ b/pkg/detectors/checklyhq/checklyhq_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/checkout/checkout.go b/pkg/detectors/checkout/checkout.go index c845e2654d5b..808ceb31e271 100644 --- a/pkg/detectors/checkout/checkout.go +++ b/pkg/detectors/checkout/checkout.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Checkout secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/checkout/checkout_test.go b/pkg/detectors/checkout/checkout_test.go index 0337cfe5b788..cd28c77b00fc 100644 --- a/pkg/detectors/checkout/checkout_test.go +++ b/pkg/detectors/checkout/checkout_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/checkvist/checkvist.go b/pkg/detectors/checkvist/checkvist.go index b2a4887bef57..07992a6a00cc 100644 --- a/pkg/detectors/checkvist/checkvist.go +++ b/pkg/detectors/checkvist/checkvist.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Checkvist secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) emailMatches := emailPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/cicero/cicero.go b/pkg/detectors/cicero/cicero.go index 6e317bf8a63a..a5e42802b45a 100644 --- a/pkg/detectors/cicero/cicero.go +++ b/pkg/detectors/cicero/cicero.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Cicero secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/cicero/cicero_test.go b/pkg/detectors/cicero/cicero_test.go index 7bb562b69e0e..04ebf1d98a67 100644 --- a/pkg/detectors/cicero/cicero_test.go +++ b/pkg/detectors/cicero/cicero_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/circleci/circleci.go b/pkg/detectors/circleci/circleci.go index 8c8d77da78da..8707e140d170 100644 --- a/pkg/detectors/circleci/circleci.go +++ b/pkg/detectors/circleci/circleci.go @@ -28,7 +28,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Circle secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/circleci/circleci_test.go b/pkg/detectors/circleci/circleci_test.go index 34d685903d28..6a2d7f738f11 100644 --- a/pkg/detectors/circleci/circleci_test.go +++ b/pkg/detectors/circleci/circleci_test.go @@ -11,6 +11,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" diff --git a/pkg/detectors/clarifai/clarifai.go b/pkg/detectors/clarifai/clarifai.go index 14ba3545694a..db251e0d1fed 100644 --- a/pkg/detectors/clarifai/clarifai.go +++ b/pkg/detectors/clarifai/clarifai.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Clarifai secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/clarifai/clarifai_test.go b/pkg/detectors/clarifai/clarifai_test.go index 96ab6fe5ae0e..6279a50a59f6 100644 --- a/pkg/detectors/clarifai/clarifai_test.go +++ b/pkg/detectors/clarifai/clarifai_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/clearbit/clearbit.go b/pkg/detectors/clearbit/clearbit.go index 6fcb7e8dbf2d..da78b752c6c8 100644 --- a/pkg/detectors/clearbit/clearbit.go +++ b/pkg/detectors/clearbit/clearbit.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Clearbit secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/clearbit/clearbit_test.go b/pkg/detectors/clearbit/clearbit_test.go index da8ba1c26924..a0913f9cf47b 100644 --- a/pkg/detectors/clearbit/clearbit_test.go +++ b/pkg/detectors/clearbit/clearbit_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/clickhelp/clickhelp.go b/pkg/detectors/clickhelp/clickhelp.go index 97f356175a08..9f39b4fbf104 100644 --- a/pkg/detectors/clickhelp/clickhelp.go +++ b/pkg/detectors/clickhelp/clickhelp.go @@ -35,7 +35,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Clickhelp secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) serverMatches := serverPat.FindAllStringSubmatch(dataStr, -1) emailMatches := emailPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/clickhelp/clickhelp_test.go b/pkg/detectors/clickhelp/clickhelp_test.go index 16965f63dcd5..9caf403dd532 100644 --- a/pkg/detectors/clickhelp/clickhelp_test.go +++ b/pkg/detectors/clickhelp/clickhelp_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/clicksendsms/clicksendsms.go b/pkg/detectors/clicksendsms/clicksendsms.go index 45c050f43ca8..2204102fd369 100644 --- a/pkg/detectors/clicksendsms/clicksendsms.go +++ b/pkg/detectors/clicksendsms/clicksendsms.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ClickSendsms secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/clicksendsms/clicksendsms_test.go b/pkg/detectors/clicksendsms/clicksendsms_test.go index 9df9c4c634ec..c120229a1fc3 100644 --- a/pkg/detectors/clicksendsms/clicksendsms_test.go +++ b/pkg/detectors/clicksendsms/clicksendsms_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/clickuppersonaltoken/clickuppersonaltoken.go b/pkg/detectors/clickuppersonaltoken/clickuppersonaltoken.go index 4ceed898d62f..1fc185a871c1 100644 --- a/pkg/detectors/clickuppersonaltoken/clickuppersonaltoken.go +++ b/pkg/detectors/clickuppersonaltoken/clickuppersonaltoken.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ClickupPersonalToken secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/clickuppersonaltoken/clickuppersonaltoken_test.go b/pkg/detectors/clickuppersonaltoken/clickuppersonaltoken_test.go index 8c8bd60f7292..2080775d03f5 100644 --- a/pkg/detectors/clickuppersonaltoken/clickuppersonaltoken_test.go +++ b/pkg/detectors/clickuppersonaltoken/clickuppersonaltoken_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/cliengo/cliengo.go b/pkg/detectors/cliengo/cliengo.go index 86ef11e80523..21a909e4ed6a 100644 --- a/pkg/detectors/cliengo/cliengo.go +++ b/pkg/detectors/cliengo/cliengo.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Cliengo secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/clinchpad/clinchpad.go b/pkg/detectors/clinchpad/clinchpad.go index 27c4c755271b..2d9666ba52e1 100644 --- a/pkg/detectors/clinchpad/clinchpad.go +++ b/pkg/detectors/clinchpad/clinchpad.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Clinchpad secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/clinchpad/clinchpad_test.go b/pkg/detectors/clinchpad/clinchpad_test.go index 68d05a39f247..904475c66906 100644 --- a/pkg/detectors/clinchpad/clinchpad_test.go +++ b/pkg/detectors/clinchpad/clinchpad_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/clockify/clockify.go b/pkg/detectors/clockify/clockify.go index bb7d21584ce6..9c18403f761b 100644 --- a/pkg/detectors/clockify/clockify.go +++ b/pkg/detectors/clockify/clockify.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Clockify secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/clockify/clockify_test.go b/pkg/detectors/clockify/clockify_test.go index 618512566d1b..786c5b403e16 100644 --- a/pkg/detectors/clockify/clockify_test.go +++ b/pkg/detectors/clockify/clockify_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/clockworksms/clockworksms.go b/pkg/detectors/clockworksms/clockworksms.go index 643ab8511b95..f18c122fd45d 100644 --- a/pkg/detectors/clockworksms/clockworksms.go +++ b/pkg/detectors/clockworksms/clockworksms.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Clockworksms secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) userKeyMatches := userKeyPat.FindAllStringSubmatch(dataStr, -1) tokenMatches := tokenPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/clockworksms/clockworksms_test.go b/pkg/detectors/clockworksms/clockworksms_test.go index 4250011b2311..6f44b29adfbc 100644 --- a/pkg/detectors/clockworksms/clockworksms_test.go +++ b/pkg/detectors/clockworksms/clockworksms_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/closecrm/close.go b/pkg/detectors/closecrm/close.go index e55c56d5bccd..0eec1698578c 100644 --- a/pkg/detectors/closecrm/close.go +++ b/pkg/detectors/closecrm/close.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Close secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/closecrm/close_test.go b/pkg/detectors/closecrm/close_test.go index 2a4940dc432c..f5642bc979ba 100644 --- a/pkg/detectors/closecrm/close_test.go +++ b/pkg/detectors/closecrm/close_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/cloudconvert/cloudconvert.go b/pkg/detectors/cloudconvert/cloudconvert.go index f454543c41c0..2184b44f5c05 100644 --- a/pkg/detectors/cloudconvert/cloudconvert.go +++ b/pkg/detectors/cloudconvert/cloudconvert.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify CloudConvert secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) for _, match := range matches { diff --git a/pkg/detectors/cloudconvert/cloudconvert_test.go b/pkg/detectors/cloudconvert/cloudconvert_test.go index 9109b4a589fc..3a38a237128c 100644 --- a/pkg/detectors/cloudconvert/cloudconvert_test.go +++ b/pkg/detectors/cloudconvert/cloudconvert_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/cloudelements/cloudelements.go b/pkg/detectors/cloudelements/cloudelements.go index 4413783f54ff..9395cf78fff2 100644 --- a/pkg/detectors/cloudelements/cloudelements.go +++ b/pkg/detectors/cloudelements/cloudelements.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify CloudElements secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) orgMatches := orgPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/cloudelements/cloudelements_test.go b/pkg/detectors/cloudelements/cloudelements_test.go index 6fa4314ddd17..4e49386876f9 100644 --- a/pkg/detectors/cloudelements/cloudelements_test.go +++ b/pkg/detectors/cloudelements/cloudelements_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/cloudflareapitoken/cloudflareapitoken.go b/pkg/detectors/cloudflareapitoken/cloudflareapitoken.go index 3557ba86d732..039b5a37cb2b 100644 --- a/pkg/detectors/cloudflareapitoken/cloudflareapitoken.go +++ b/pkg/detectors/cloudflareapitoken/cloudflareapitoken.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify CloudflareApiToken secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/cloudflareapitoken/cloudflareapitoken_test.go b/pkg/detectors/cloudflareapitoken/cloudflareapitoken_test.go index 05660e2c56a8..0dd1f9fee1c2 100644 --- a/pkg/detectors/cloudflareapitoken/cloudflareapitoken_test.go +++ b/pkg/detectors/cloudflareapitoken/cloudflareapitoken_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/cloudflarecakey/cloudflarecakey.go b/pkg/detectors/cloudflarecakey/cloudflarecakey.go index f2d7783fd289..c36127e275cd 100644 --- a/pkg/detectors/cloudflarecakey/cloudflarecakey.go +++ b/pkg/detectors/cloudflarecakey/cloudflarecakey.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify CloudflareCaKey secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/cloudflarecakey/cloudflarecakey_test.go b/pkg/detectors/cloudflarecakey/cloudflarecakey_test.go index 0eedf05b9ff9..70981ea785ff 100644 --- a/pkg/detectors/cloudflarecakey/cloudflarecakey_test.go +++ b/pkg/detectors/cloudflarecakey/cloudflarecakey_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/cloudflareglobalapikey/cloudflareglobalapikey.go b/pkg/detectors/cloudflareglobalapikey/cloudflareglobalapikey.go index c1798fc902d4..e074ec702133 100644 --- a/pkg/detectors/cloudflareglobalapikey/cloudflareglobalapikey.go +++ b/pkg/detectors/cloudflareglobalapikey/cloudflareglobalapikey.go @@ -35,7 +35,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify CloudflareGlobalApiKey secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) apiKeyMatches := apiKeyPat.FindAllStringSubmatch(dataStr, -1) emailMatches := emailPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/cloudflareglobalapikey/cloudflareglobalapikey_test.go b/pkg/detectors/cloudflareglobalapikey/cloudflareglobalapikey_test.go index 49a96a617fa4..d788006b0d15 100644 --- a/pkg/detectors/cloudflareglobalapikey/cloudflareglobalapikey_test.go +++ b/pkg/detectors/cloudflareglobalapikey/cloudflareglobalapikey_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/cloudimage/cloudimage.go b/pkg/detectors/cloudimage/cloudimage.go index c097f0b58bfb..2e684f63d5e2 100644 --- a/pkg/detectors/cloudimage/cloudimage.go +++ b/pkg/detectors/cloudimage/cloudimage.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify CloudImage secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/cloudmersive/cloudmersive.go b/pkg/detectors/cloudmersive/cloudmersive.go index 768b3c39e4d3..75bec70aaa79 100644 --- a/pkg/detectors/cloudmersive/cloudmersive.go +++ b/pkg/detectors/cloudmersive/cloudmersive.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Cloudmersive secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/cloudmersive/cloudmersive_test.go b/pkg/detectors/cloudmersive/cloudmersive_test.go index e0acea511c66..bae6a46b27c7 100644 --- a/pkg/detectors/cloudmersive/cloudmersive_test.go +++ b/pkg/detectors/cloudmersive/cloudmersive_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/cloudplan/cloudplan.go b/pkg/detectors/cloudplan/cloudplan.go index df0db176953e..b68e202ca5d0 100644 --- a/pkg/detectors/cloudplan/cloudplan.go +++ b/pkg/detectors/cloudplan/cloudplan.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Cloudplan secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/cloudplan/cloudplan_test.go b/pkg/detectors/cloudplan/cloudplan_test.go index 531d959b4c5f..a7a8179ce09f 100644 --- a/pkg/detectors/cloudplan/cloudplan_test.go +++ b/pkg/detectors/cloudplan/cloudplan_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/cloudsmith/cloudsmith.go b/pkg/detectors/cloudsmith/cloudsmith.go index b7aab4f6d097..e3533db1a511 100644 --- a/pkg/detectors/cloudsmith/cloudsmith.go +++ b/pkg/detectors/cloudsmith/cloudsmith.go @@ -36,7 +36,7 @@ type response struct { // FromData will find and optionally verify Cloudsmith secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/cloudsmith/cloudsmith_test.go b/pkg/detectors/cloudsmith/cloudsmith_test.go index 58fe57574567..804bd7633d97 100644 --- a/pkg/detectors/cloudsmith/cloudsmith_test.go +++ b/pkg/detectors/cloudsmith/cloudsmith_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/cloverly/cloverly.go b/pkg/detectors/cloverly/cloverly.go index 6736948e0897..aa7e77859fef 100644 --- a/pkg/detectors/cloverly/cloverly.go +++ b/pkg/detectors/cloverly/cloverly.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Cloverly secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/cloverly/cloverly_test.go b/pkg/detectors/cloverly/cloverly_test.go index cb4d64794411..14ea560238ec 100644 --- a/pkg/detectors/cloverly/cloverly_test.go +++ b/pkg/detectors/cloverly/cloverly_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/cloze/cloze.go b/pkg/detectors/cloze/cloze.go index 06f18ed51799..a3fba821aa0a 100644 --- a/pkg/detectors/cloze/cloze.go +++ b/pkg/detectors/cloze/cloze.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Cloze secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) emailMatches := emailPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/clustdoc/clustdoc.go b/pkg/detectors/clustdoc/clustdoc.go index 17bc35babb0c..2ec33c1bc5e5 100644 --- a/pkg/detectors/clustdoc/clustdoc.go +++ b/pkg/detectors/clustdoc/clustdoc.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ClustDoc secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/clustdoc/clustdoc_test.go b/pkg/detectors/clustdoc/clustdoc_test.go index 35802efcedd5..57dd1601419e 100644 --- a/pkg/detectors/clustdoc/clustdoc_test.go +++ b/pkg/detectors/clustdoc/clustdoc_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/coda/coda.go b/pkg/detectors/coda/coda.go index bec893080e30..fce17390bb81 100644 --- a/pkg/detectors/coda/coda.go +++ b/pkg/detectors/coda/coda.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Coda secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/coda/coda_test.go b/pkg/detectors/coda/coda_test.go index 0503f9e6ba59..4c17942ea535 100644 --- a/pkg/detectors/coda/coda_test.go +++ b/pkg/detectors/coda/coda_test.go @@ -6,11 +6,12 @@ package coda import ( "context" "fmt" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "testing" "time" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/codacy/codacy.go b/pkg/detectors/codacy/codacy.go index d33f22bc870a..90653e36ca40 100644 --- a/pkg/detectors/codacy/codacy.go +++ b/pkg/detectors/codacy/codacy.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Codacy secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/codacy/codacy_test.go b/pkg/detectors/codacy/codacy_test.go index d086024efb8e..c7447d93f389 100644 --- a/pkg/detectors/codacy/codacy_test.go +++ b/pkg/detectors/codacy/codacy_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/codeclimate/codeclimate.go b/pkg/detectors/codeclimate/codeclimate.go index aaf23de10517..fa5e912dc96d 100644 --- a/pkg/detectors/codeclimate/codeclimate.go +++ b/pkg/detectors/codeclimate/codeclimate.go @@ -39,7 +39,7 @@ type response struct { // FromData will find and optionally verify Codeclimate secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/codeclimate/codeclimate_test.go b/pkg/detectors/codeclimate/codeclimate_test.go index 2bbffcb25408..51851168d03f 100644 --- a/pkg/detectors/codeclimate/codeclimate_test.go +++ b/pkg/detectors/codeclimate/codeclimate_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/codemagic/codemagic.go b/pkg/detectors/codemagic/codemagic.go index bef4692f0957..0a3316003ad0 100644 --- a/pkg/detectors/codemagic/codemagic.go +++ b/pkg/detectors/codemagic/codemagic.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Codemagic secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/codemagic/codemagic_test.go b/pkg/detectors/codemagic/codemagic_test.go index e3ab148ae221..6be17c47e756 100644 --- a/pkg/detectors/codemagic/codemagic_test.go +++ b/pkg/detectors/codemagic/codemagic_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/codequiry/codequiry.go b/pkg/detectors/codequiry/codequiry.go index 17ba6a0768a7..5e3c686da846 100644 --- a/pkg/detectors/codequiry/codequiry.go +++ b/pkg/detectors/codequiry/codequiry.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Codequiry secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/codequiry/codequiry_test.go b/pkg/detectors/codequiry/codequiry_test.go index 30e9e1751eab..c0b9b873eb8c 100644 --- a/pkg/detectors/codequiry/codequiry_test.go +++ b/pkg/detectors/codequiry/codequiry_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/coinapi/coinapi.go b/pkg/detectors/coinapi/coinapi.go index 016652aca1db..ae3b344cdad8 100644 --- a/pkg/detectors/coinapi/coinapi.go +++ b/pkg/detectors/coinapi/coinapi.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify CoinApi secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/coinapi/coinapi_test.go b/pkg/detectors/coinapi/coinapi_test.go index 9ee35f7f9d83..fa15dace7c2b 100644 --- a/pkg/detectors/coinapi/coinapi_test.go +++ b/pkg/detectors/coinapi/coinapi_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/coinbase/coinbase.go b/pkg/detectors/coinbase/coinbase.go index ab13f820a07a..0ace66cb7857 100644 --- a/pkg/detectors/coinbase/coinbase.go +++ b/pkg/detectors/coinbase/coinbase.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Coinbase secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/coinbase_waas/coinbase_waas.go b/pkg/detectors/coinbase_waas/coinbase_waas.go index 7f31d754c605..f097e9c479bd 100644 --- a/pkg/detectors/coinbase_waas/coinbase_waas.go +++ b/pkg/detectors/coinbase_waas/coinbase_waas.go @@ -6,16 +6,18 @@ import ( "crypto/x509" "encoding/pem" "errors" + "net/http" + "regexp" + "strings" + "github.com/coinbase/waas-client-library-go/auth" "github.com/coinbase/waas-client-library-go/clients" v1clients "github.com/coinbase/waas-client-library-go/clients/v1" v1 "github.com/coinbase/waas-client-library-go/gen/go/coinbase/cloud/pools/v1" "github.com/google/uuid" "google.golang.org/api/googleapi" - "net/http" - "regexp" - "strings" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" ) @@ -49,7 +51,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify CoinbaseWaaS secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) keyNameMatches := keyNamePat.FindAllStringSubmatch(dataStr, -1) privKeyMatches := privKeyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/coinlayer/coinlayer.go b/pkg/detectors/coinlayer/coinlayer.go index 161f57144449..04580542033d 100644 --- a/pkg/detectors/coinlayer/coinlayer.go +++ b/pkg/detectors/coinlayer/coinlayer.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Coinlayer secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/coinlayer/coinlayer_test.go b/pkg/detectors/coinlayer/coinlayer_test.go index 095501355744..6ccdcea51c69 100644 --- a/pkg/detectors/coinlayer/coinlayer_test.go +++ b/pkg/detectors/coinlayer/coinlayer_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/coinlib/coinlib.go b/pkg/detectors/coinlib/coinlib.go index 6f8d330412e8..0caa36993a8b 100644 --- a/pkg/detectors/coinlib/coinlib.go +++ b/pkg/detectors/coinlib/coinlib.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Coinlib secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/coinlib/coinlib_test.go b/pkg/detectors/coinlib/coinlib_test.go index bdcc00c2b9ad..cb6229718826 100644 --- a/pkg/detectors/coinlib/coinlib_test.go +++ b/pkg/detectors/coinlib/coinlib_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/coinmarketcap/coinmarketcap.go b/pkg/detectors/coinmarketcap/coinmarketcap.go index bb75a27b037a..ac245343cf38 100644 --- a/pkg/detectors/coinmarketcap/coinmarketcap.go +++ b/pkg/detectors/coinmarketcap/coinmarketcap.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Coinmarketcap secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/coinmarketcap/coinmarketcap_test.go b/pkg/detectors/coinmarketcap/coinmarketcap_test.go index a456ed9bb126..6166c3931955 100644 --- a/pkg/detectors/coinmarketcap/coinmarketcap_test.go +++ b/pkg/detectors/coinmarketcap/coinmarketcap_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/collect2/collect2.go b/pkg/detectors/collect2/collect2.go index 79bcb0b38608..7b2d4007a96c 100644 --- a/pkg/detectors/collect2/collect2.go +++ b/pkg/detectors/collect2/collect2.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Collect2 secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/collect2/collect2_test.go b/pkg/detectors/collect2/collect2_test.go index 64f058a09250..03ab750865fb 100644 --- a/pkg/detectors/collect2/collect2_test.go +++ b/pkg/detectors/collect2/collect2_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/column/column.go b/pkg/detectors/column/column.go index 4c2ea840325a..4300d5fd43ce 100644 --- a/pkg/detectors/column/column.go +++ b/pkg/detectors/column/column.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Column secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/commercejs/commercejs.go b/pkg/detectors/commercejs/commercejs.go index e1347cfa2dfe..51ed9d293c8e 100644 --- a/pkg/detectors/commercejs/commercejs.go +++ b/pkg/detectors/commercejs/commercejs.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify CommerceJS secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/commercejs/commercejs_test.go b/pkg/detectors/commercejs/commercejs_test.go index 0c39e067e92a..788b3bc38590 100644 --- a/pkg/detectors/commercejs/commercejs_test.go +++ b/pkg/detectors/commercejs/commercejs_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/commodities/commodities.go b/pkg/detectors/commodities/commodities.go index 527e1906319a..383b9eb10bbd 100644 --- a/pkg/detectors/commodities/commodities.go +++ b/pkg/detectors/commodities/commodities.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Commodities secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/commodities/commodities_test.go b/pkg/detectors/commodities/commodities_test.go index 0c0ef7c2dbc0..731310495b9d 100644 --- a/pkg/detectors/commodities/commodities_test.go +++ b/pkg/detectors/commodities/commodities_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/companyhub/companyhub.go b/pkg/detectors/companyhub/companyhub.go index b7621bc8c660..a19313109621 100644 --- a/pkg/detectors/companyhub/companyhub.go +++ b/pkg/detectors/companyhub/companyhub.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify CompanyHub secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idmatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/companyhub/companyhub_test.go b/pkg/detectors/companyhub/companyhub_test.go index 877eef42e4e7..3ea86d53f2bc 100644 --- a/pkg/detectors/companyhub/companyhub_test.go +++ b/pkg/detectors/companyhub/companyhub_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/confluent/confluent.go b/pkg/detectors/confluent/confluent.go index 0257c506c0c8..80f6ac58e481 100644 --- a/pkg/detectors/confluent/confluent.go +++ b/pkg/detectors/confluent/confluent.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Confluent secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) secretMatches := secretPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/confluent/confluent_test.go b/pkg/detectors/confluent/confluent_test.go index 91b535decaa5..3e891cc0ab85 100644 --- a/pkg/detectors/confluent/confluent_test.go +++ b/pkg/detectors/confluent/confluent_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/contentfulpersonalaccesstoken/contentfulpersonalaccesstoken.go b/pkg/detectors/contentfulpersonalaccesstoken/contentfulpersonalaccesstoken.go index b1557473808b..b37edd372a75 100644 --- a/pkg/detectors/contentfulpersonalaccesstoken/contentfulpersonalaccesstoken.go +++ b/pkg/detectors/contentfulpersonalaccesstoken/contentfulpersonalaccesstoken.go @@ -30,7 +30,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ContentfulDelivery secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) keyMatches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/contentfulpersonalaccesstoken/contentfulpersonalaccesstoken_test.go b/pkg/detectors/contentfulpersonalaccesstoken/contentfulpersonalaccesstoken_test.go index f69286595b34..14a29a06c220 100644 --- a/pkg/detectors/contentfulpersonalaccesstoken/contentfulpersonalaccesstoken_test.go +++ b/pkg/detectors/contentfulpersonalaccesstoken/contentfulpersonalaccesstoken_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/conversiontools/conversiontools.go b/pkg/detectors/conversiontools/conversiontools.go index 64adf6ffe61e..f1b6387d6c12 100644 --- a/pkg/detectors/conversiontools/conversiontools.go +++ b/pkg/detectors/conversiontools/conversiontools.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ConversionTools secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/conversiontools/conversiontools_test.go b/pkg/detectors/conversiontools/conversiontools_test.go index 748c3567c5a7..b682804116dc 100644 --- a/pkg/detectors/conversiontools/conversiontools_test.go +++ b/pkg/detectors/conversiontools/conversiontools_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/convertapi/convertapi.go b/pkg/detectors/convertapi/convertapi.go index 9513b6d62075..8578e29ee99a 100644 --- a/pkg/detectors/convertapi/convertapi.go +++ b/pkg/detectors/convertapi/convertapi.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ConvertApi secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/convertapi/convertapi_test.go b/pkg/detectors/convertapi/convertapi_test.go index 89acb1db5823..9cff8d1436aa 100644 --- a/pkg/detectors/convertapi/convertapi_test.go +++ b/pkg/detectors/convertapi/convertapi_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/convertkit/convertkit.go b/pkg/detectors/convertkit/convertkit.go index 9f9dbbf2fb49..05a088f3411a 100644 --- a/pkg/detectors/convertkit/convertkit.go +++ b/pkg/detectors/convertkit/convertkit.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Convertkit secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/convertkit/convertkit_test.go b/pkg/detectors/convertkit/convertkit_test.go index 2b773d28c04e..649dfd753cdb 100644 --- a/pkg/detectors/convertkit/convertkit_test.go +++ b/pkg/detectors/convertkit/convertkit_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/convier/convier.go b/pkg/detectors/convier/convier.go index a0d2732ce5b6..8c8286f0049b 100644 --- a/pkg/detectors/convier/convier.go +++ b/pkg/detectors/convier/convier.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Convier secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/copper/copper.go b/pkg/detectors/copper/copper.go index b25b23a0dc53..0ac0d3affa42 100644 --- a/pkg/detectors/copper/copper.go +++ b/pkg/detectors/copper/copper.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Copper secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idmatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/copper/copper_test.go b/pkg/detectors/copper/copper_test.go index cf7d9f02110f..d9679a88b9b9 100644 --- a/pkg/detectors/copper/copper_test.go +++ b/pkg/detectors/copper/copper_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/couchbase/couchbase.go b/pkg/detectors/couchbase/couchbase.go index 09a1a4379a0d..d238c893adc8 100644 --- a/pkg/detectors/couchbase/couchbase.go +++ b/pkg/detectors/couchbase/couchbase.go @@ -10,6 +10,7 @@ import ( "unicode" "github.com/couchbase/gocb/v2" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" @@ -26,7 +27,7 @@ var ( connectionStringPat = regexp.MustCompile(`\bcb\.[a-z0-9]+\.cloud\.couchbase\.com\b`) usernamePat = `?()/\+=\s\n` passwordPat = `^<>;.*&|£\n\s` - //passwordPat = regexp.MustCompile(`(?i)(?:pass|pwd)(?:.|[\n\r]){0,15}(\b[^<>;.*&|£\n\s]{8,100}$)`) + // passwordPat = regexp.MustCompile(`(?i)(?:pass|pwd)(?:.|[\n\r]){0,15}(\b[^<>;.*&|£\n\s]{8,100}$)`) // passwordPat = regexp.MustCompile(`(?im)(?:pass|pwd)\S{0,40}?[:=\s]{1,3}[ '"=]{0,1}([^:?()/\+=\s\n]{4,40})\b`) ) @@ -60,7 +61,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Couchbase secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) connectionStringMatches := connectionStringPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/couchbase/couchbase_test.go b/pkg/detectors/couchbase/couchbase_test.go index 03b340879d9a..5d5a3e6a3edd 100644 --- a/pkg/detectors/couchbase/couchbase_test.go +++ b/pkg/detectors/couchbase/couchbase_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/countrylayer/countrylayer.go b/pkg/detectors/countrylayer/countrylayer.go index 6726c0536152..b4b3ab51480d 100644 --- a/pkg/detectors/countrylayer/countrylayer.go +++ b/pkg/detectors/countrylayer/countrylayer.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify CountryLayer secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/countrylayer/countrylayer_test.go b/pkg/detectors/countrylayer/countrylayer_test.go index c70dcc65ada0..da5d2b4bbc9e 100644 --- a/pkg/detectors/countrylayer/countrylayer_test.go +++ b/pkg/detectors/countrylayer/countrylayer_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/courier/courier.go b/pkg/detectors/courier/courier.go index 84419ddf8690..40e4d22c3fc2 100644 --- a/pkg/detectors/courier/courier.go +++ b/pkg/detectors/courier/courier.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Courier secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/courier/courier_test.go b/pkg/detectors/courier/courier_test.go index 2b6f81803575..a1ea1bde5792 100644 --- a/pkg/detectors/courier/courier_test.go +++ b/pkg/detectors/courier/courier_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/coveralls/coveralls.go b/pkg/detectors/coveralls/coveralls.go index c03bfe6edd8f..ecbfe78908c1 100644 --- a/pkg/detectors/coveralls/coveralls.go +++ b/pkg/detectors/coveralls/coveralls.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Coveralls secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/coveralls/coveralls_test.go b/pkg/detectors/coveralls/coveralls_test.go index 2b20f8ecee3b..e7d11b096d8b 100644 --- a/pkg/detectors/coveralls/coveralls_test.go +++ b/pkg/detectors/coveralls/coveralls_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/craftmypdf/craftmypdf.go b/pkg/detectors/craftmypdf/craftmypdf.go index 894d40bb89ba..4d584f2b6fe7 100644 --- a/pkg/detectors/craftmypdf/craftmypdf.go +++ b/pkg/detectors/craftmypdf/craftmypdf.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify CraftMyPDF secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/craftmypdf/craftmypdf_test.go b/pkg/detectors/craftmypdf/craftmypdf_test.go index b2952d214408..534177382c1b 100644 --- a/pkg/detectors/craftmypdf/craftmypdf_test.go +++ b/pkg/detectors/craftmypdf/craftmypdf_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/crossbrowsertesting/crossbrowsertesting.go b/pkg/detectors/crossbrowsertesting/crossbrowsertesting.go index 46ca3d55e8f5..77a029a529ae 100644 --- a/pkg/detectors/crossbrowsertesting/crossbrowsertesting.go +++ b/pkg/detectors/crossbrowsertesting/crossbrowsertesting.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify CrossBrowserTesting secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idmatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/crossbrowsertesting/crossbrowsertesting_test.go b/pkg/detectors/crossbrowsertesting/crossbrowsertesting_test.go index 03ffbffcb69b..a66d63d0cd36 100644 --- a/pkg/detectors/crossbrowsertesting/crossbrowsertesting_test.go +++ b/pkg/detectors/crossbrowsertesting/crossbrowsertesting_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/crowdin/crowdin.go b/pkg/detectors/crowdin/crowdin.go index 1a742241d213..cefbee7c8569 100644 --- a/pkg/detectors/crowdin/crowdin.go +++ b/pkg/detectors/crowdin/crowdin.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Crowdin secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) for _, match := range matches { diff --git a/pkg/detectors/crowdin/crowdin_test.go b/pkg/detectors/crowdin/crowdin_test.go index 10a050d8cb04..8811ff6476bb 100644 --- a/pkg/detectors/crowdin/crowdin_test.go +++ b/pkg/detectors/crowdin/crowdin_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/cryptocompare/cryptocompare.go b/pkg/detectors/cryptocompare/cryptocompare.go index b10bc5eb0ad3..23de4d0ac7fc 100644 --- a/pkg/detectors/cryptocompare/cryptocompare.go +++ b/pkg/detectors/cryptocompare/cryptocompare.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify CryptoCompare secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/cryptocompare/cryptocompare_test.go b/pkg/detectors/cryptocompare/cryptocompare_test.go index 49f069a3c993..6cc7f06de8e4 100644 --- a/pkg/detectors/cryptocompare/cryptocompare_test.go +++ b/pkg/detectors/cryptocompare/cryptocompare_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/currencycloud/currencycloud.go b/pkg/detectors/currencycloud/currencycloud.go index 66c0d433a3ed..7126cb68f16d 100644 --- a/pkg/detectors/currencycloud/currencycloud.go +++ b/pkg/detectors/currencycloud/currencycloud.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Currencycloud secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) emailMatches := emailPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/currencyfreaks/currencyfreaks.go b/pkg/detectors/currencyfreaks/currencyfreaks.go index d796d4ab4b3b..56fe3d4aa255 100644 --- a/pkg/detectors/currencyfreaks/currencyfreaks.go +++ b/pkg/detectors/currencyfreaks/currencyfreaks.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Currencyfreaks secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/currencyfreaks/currencyfreaks_test.go b/pkg/detectors/currencyfreaks/currencyfreaks_test.go index e3daa56b1e71..9fd894f57658 100644 --- a/pkg/detectors/currencyfreaks/currencyfreaks_test.go +++ b/pkg/detectors/currencyfreaks/currencyfreaks_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/currencylayer/currencylayer.go b/pkg/detectors/currencylayer/currencylayer.go index 215dd737caa4..51c0a5aa67f3 100644 --- a/pkg/detectors/currencylayer/currencylayer.go +++ b/pkg/detectors/currencylayer/currencylayer.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Currencylayer secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/currencylayer/currencylayer_test.go b/pkg/detectors/currencylayer/currencylayer_test.go index 5cc7958d8583..2d86c62353c8 100644 --- a/pkg/detectors/currencylayer/currencylayer_test.go +++ b/pkg/detectors/currencylayer/currencylayer_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/currencyscoop/currencyscoop.go b/pkg/detectors/currencyscoop/currencyscoop.go index 8071d45c8c95..2a755b5448da 100644 --- a/pkg/detectors/currencyscoop/currencyscoop.go +++ b/pkg/detectors/currencyscoop/currencyscoop.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Currencyscoop secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/currencyscoop/currencyscoop_test.go b/pkg/detectors/currencyscoop/currencyscoop_test.go index 378a11cff3ba..bb808cbe5738 100644 --- a/pkg/detectors/currencyscoop/currencyscoop_test.go +++ b/pkg/detectors/currencyscoop/currencyscoop_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/currentsapi/currentsapi.go b/pkg/detectors/currentsapi/currentsapi.go index c3129989bab8..fc5509501c17 100644 --- a/pkg/detectors/currentsapi/currentsapi.go +++ b/pkg/detectors/currentsapi/currentsapi.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify CurrentsAPI secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/currentsapi/currentsapi_test.go b/pkg/detectors/currentsapi/currentsapi_test.go index 63a8e8ed5e6b..69ff8d5b1b98 100644 --- a/pkg/detectors/currentsapi/currentsapi_test.go +++ b/pkg/detectors/currentsapi/currentsapi_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/customerguru/customerguru.go b/pkg/detectors/customerguru/customerguru.go index 4347b9a85296..ffb11c374c35 100644 --- a/pkg/detectors/customerguru/customerguru.go +++ b/pkg/detectors/customerguru/customerguru.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify CustomerGuru secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idmatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/customerguru/customerguru_test.go b/pkg/detectors/customerguru/customerguru_test.go index 3c16c76aa806..1e0ff6c014d5 100644 --- a/pkg/detectors/customerguru/customerguru_test.go +++ b/pkg/detectors/customerguru/customerguru_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/customerio/customerio.go b/pkg/detectors/customerio/customerio.go index 771d1260c6b3..c467fa9f92e5 100644 --- a/pkg/detectors/customerio/customerio.go +++ b/pkg/detectors/customerio/customerio.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify CustomerIO secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idmatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/customerio/customerio_test.go b/pkg/detectors/customerio/customerio_test.go index a28613e0433b..e849d10399b6 100644 --- a/pkg/detectors/customerio/customerio_test.go +++ b/pkg/detectors/customerio/customerio_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/d7network/d7network.go b/pkg/detectors/d7network/d7network.go index a8d4608c9f1c..c884b280a26e 100644 --- a/pkg/detectors/d7network/d7network.go +++ b/pkg/detectors/d7network/d7network.go @@ -6,6 +6,7 @@ import ( "regexp" "strings" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" ) @@ -28,7 +29,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify D7Network secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/d7network/d7network_test.go b/pkg/detectors/d7network/d7network_test.go index 737362aae3c6..f8e6115e77bf 100644 --- a/pkg/detectors/d7network/d7network_test.go +++ b/pkg/detectors/d7network/d7network_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/dailyco/dailyco.go b/pkg/detectors/dailyco/dailyco.go index 77de08308be9..7700a967ada4 100644 --- a/pkg/detectors/dailyco/dailyco.go +++ b/pkg/detectors/dailyco/dailyco.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify DailyCO secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/dailyco/dailyco_test.go b/pkg/detectors/dailyco/dailyco_test.go index 8832457eb5c4..6c520611fc6e 100644 --- a/pkg/detectors/dailyco/dailyco_test.go +++ b/pkg/detectors/dailyco/dailyco_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/dandelion/dandelion.go b/pkg/detectors/dandelion/dandelion.go index 973db3013800..1bd68bfe1ca9 100644 --- a/pkg/detectors/dandelion/dandelion.go +++ b/pkg/detectors/dandelion/dandelion.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Dandelion secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/dandelion/dandelion_test.go b/pkg/detectors/dandelion/dandelion_test.go index 3f7f376312e4..0691ba13999e 100644 --- a/pkg/detectors/dandelion/dandelion_test.go +++ b/pkg/detectors/dandelion/dandelion_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/dareboost/dareboost.go b/pkg/detectors/dareboost/dareboost.go index fbb13093306d..11743982576b 100644 --- a/pkg/detectors/dareboost/dareboost.go +++ b/pkg/detectors/dareboost/dareboost.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Dareboost secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/dareboost/dareboost_test.go b/pkg/detectors/dareboost/dareboost_test.go index 356ebace0d8f..beb5b49beb85 100644 --- a/pkg/detectors/dareboost/dareboost_test.go +++ b/pkg/detectors/dareboost/dareboost_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/databox/databox.go b/pkg/detectors/databox/databox.go index 4c36b7644d37..4272b18ae07a 100644 --- a/pkg/detectors/databox/databox.go +++ b/pkg/detectors/databox/databox.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Databox secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/databox/databox_test.go b/pkg/detectors/databox/databox_test.go index 4492d4cdb412..595f54f3795b 100644 --- a/pkg/detectors/databox/databox_test.go +++ b/pkg/detectors/databox/databox_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/databrickstoken/databrickstoken.go b/pkg/detectors/databrickstoken/databrickstoken.go index 72e48e6b07c6..a8d9b75b5b46 100644 --- a/pkg/detectors/databrickstoken/databrickstoken.go +++ b/pkg/detectors/databrickstoken/databrickstoken.go @@ -12,7 +12,7 @@ import ( "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" ) -type Scanner struct{ +type Scanner struct { client *http.Client } @@ -24,7 +24,7 @@ var ( // Make sure that your group is surrounded in boundary characters such as below to reduce false positives. domain = regexp.MustCompile(`\b([a-z0-9-]+(?:\.[a-z0-9-]+)*\.(cloud\.databricks\.com|gcp\.databricks\.com|azurewebsites\.net))\b`) - keyPat = regexp.MustCompile(`\b(dapi[0-9a-f]{32})(-\d)?\b`) + keyPat = regexp.MustCompile(`\b(dapi[0-9a-f]{32})(-\d)?\b`) ) // Keywords are used for efficiently pre-filtering chunks. @@ -35,7 +35,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Databrickstoken secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) domainMatches := domain.FindAllStringSubmatch(dataStr, -1) @@ -54,10 +54,10 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result if verify { client := s.client - if client == nil { - client = defaultClient - } - req, err := http.NewRequestWithContext(ctx, "GET", "https://" + resDomainMatch + "/api/2.0/clusters/list", nil) + if client == nil { + client = defaultClient + } + req, err := http.NewRequestWithContext(ctx, "GET", "https://"+resDomainMatch+"/api/2.0/clusters/list", nil) if err != nil { continue } diff --git a/pkg/detectors/databrickstoken/databrickstoken_test.go b/pkg/detectors/databrickstoken/databrickstoken_test.go index 92911f9d0e3e..bf617069feca 100644 --- a/pkg/detectors/databrickstoken/databrickstoken_test.go +++ b/pkg/detectors/databrickstoken/databrickstoken_test.go @@ -6,11 +6,12 @@ package databrickstoken import ( "context" "fmt" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "testing" "time" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/datadogtoken/datadogtoken.go b/pkg/detectors/datadogtoken/datadogtoken.go index eeda41ae36c9..6a6d7c58c46b 100644 --- a/pkg/detectors/datadogtoken/datadogtoken.go +++ b/pkg/detectors/datadogtoken/datadogtoken.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify DatadogToken secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) appMatches := appPat.FindAllStringSubmatch(dataStr, -1) apiMatches := apiPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/datadogtoken/datadogtoken_test.go b/pkg/detectors/datadogtoken/datadogtoken_test.go index 7a56810fde48..f18e942ad189 100644 --- a/pkg/detectors/datadogtoken/datadogtoken_test.go +++ b/pkg/detectors/datadogtoken/datadogtoken_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/datagov/datagov.go b/pkg/detectors/datagov/datagov.go index 2bc2c06cb4cc..a3f39962d0d7 100644 --- a/pkg/detectors/datagov/datagov.go +++ b/pkg/detectors/datagov/datagov.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify DataGov secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/datagov/datagov_test.go b/pkg/detectors/datagov/datagov_test.go index 41903fd76b2a..5a656a86dbc5 100644 --- a/pkg/detectors/datagov/datagov_test.go +++ b/pkg/detectors/datagov/datagov_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/debounce/debounce.go b/pkg/detectors/debounce/debounce.go index f63e200ce3b2..7366f3333bc2 100644 --- a/pkg/detectors/debounce/debounce.go +++ b/pkg/detectors/debounce/debounce.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Debounce secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/debounce/debounce_test.go b/pkg/detectors/debounce/debounce_test.go index 4d9cc1a3e6bf..9120630d42cd 100644 --- a/pkg/detectors/debounce/debounce_test.go +++ b/pkg/detectors/debounce/debounce_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/deepai/deepai.go b/pkg/detectors/deepai/deepai.go index 390ddb451975..3090a25fab7f 100644 --- a/pkg/detectors/deepai/deepai.go +++ b/pkg/detectors/deepai/deepai.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify DeepAI secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/deepai/deepai_test.go b/pkg/detectors/deepai/deepai_test.go index a378bac3f63a..ff4b87338b95 100644 --- a/pkg/detectors/deepai/deepai_test.go +++ b/pkg/detectors/deepai/deepai_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/deepgram/deepgram.go b/pkg/detectors/deepgram/deepgram.go index bdab52a9b1c5..945bfe65b491 100644 --- a/pkg/detectors/deepgram/deepgram.go +++ b/pkg/detectors/deepgram/deepgram.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Deepgram secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/deepgram/deepgram_test.go b/pkg/detectors/deepgram/deepgram_test.go index 628164a6aea6..9cefacfdef41 100644 --- a/pkg/detectors/deepgram/deepgram_test.go +++ b/pkg/detectors/deepgram/deepgram_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/delighted/delighted.go b/pkg/detectors/delighted/delighted.go index 5aad8cf9e38f..d2f61c44cc00 100644 --- a/pkg/detectors/delighted/delighted.go +++ b/pkg/detectors/delighted/delighted.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Delighted secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/delighted/delighted_test.go b/pkg/detectors/delighted/delighted_test.go index 3e4c473c8609..2087dc77b9a7 100644 --- a/pkg/detectors/delighted/delighted_test.go +++ b/pkg/detectors/delighted/delighted_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/demio/demio.go b/pkg/detectors/demio/demio.go index 22fce3ca29ae..b052a2244483 100644 --- a/pkg/detectors/demio/demio.go +++ b/pkg/detectors/demio/demio.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Demio secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := secretPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/demio/demio_test.go b/pkg/detectors/demio/demio_test.go index 67d24aa26227..98d55663eae0 100644 --- a/pkg/detectors/demio/demio_test.go +++ b/pkg/detectors/demio/demio_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/deno/denodeploy.go b/pkg/detectors/deno/denodeploy.go index 2137525538a4..acb83e63c514 100644 --- a/pkg/detectors/deno/denodeploy.go +++ b/pkg/detectors/deno/denodeploy.go @@ -4,12 +4,13 @@ import ( "context" "encoding/json" "fmt" - "github.com/trufflesecurity/trufflehog/v3/pkg/common" - "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" - "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" "io" "net/http" "regexp" + + "github.com/trufflesecurity/trufflehog/v3/pkg/common" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" + "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" ) type Scanner struct { @@ -36,7 +37,7 @@ type userResponse struct { // FromData will find and optionally verify DenoDeploy secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) tokenMatches := tokenPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/deputy/deputy.go b/pkg/detectors/deputy/deputy.go index e9033c9cbe65..b57ad515c9dd 100644 --- a/pkg/detectors/deputy/deputy.go +++ b/pkg/detectors/deputy/deputy.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Deputy secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) urlMatches := urlPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/deputy/deputy_test.go b/pkg/detectors/deputy/deputy_test.go index bbd6d038af70..2087ab46dcbb 100644 --- a/pkg/detectors/deputy/deputy_test.go +++ b/pkg/detectors/deputy/deputy_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/detectify/detectify.go b/pkg/detectors/detectify/detectify.go index d7896fdd8738..82d5e5df4af2 100644 --- a/pkg/detectors/detectify/detectify.go +++ b/pkg/detectors/detectify/detectify.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Detectify secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/detectify/detectify_test.go b/pkg/detectors/detectify/detectify_test.go index 6fcebae6e5b4..21df2af9dee9 100644 --- a/pkg/detectors/detectify/detectify_test.go +++ b/pkg/detectors/detectify/detectify_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/detectlanguage/detectlanguage.go b/pkg/detectors/detectlanguage/detectlanguage.go index 881e8336adc5..f490db5cd16e 100644 --- a/pkg/detectors/detectlanguage/detectlanguage.go +++ b/pkg/detectors/detectlanguage/detectlanguage.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify DetectLanguage secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/detectlanguage/detectlanguage_test.go b/pkg/detectors/detectlanguage/detectlanguage_test.go index 26874b4aa39d..cd4cfb520517 100644 --- a/pkg/detectors/detectlanguage/detectlanguage_test.go +++ b/pkg/detectors/detectlanguage/detectlanguage_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/dfuse/dfuse.go b/pkg/detectors/dfuse/dfuse.go index 8b170f8bab69..39cb5a595cee 100644 --- a/pkg/detectors/dfuse/dfuse.go +++ b/pkg/detectors/dfuse/dfuse.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Dfuse secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/dfuse/dfuse_test.go b/pkg/detectors/dfuse/dfuse_test.go index 5f603318a9dc..9d78740aac66 100644 --- a/pkg/detectors/dfuse/dfuse_test.go +++ b/pkg/detectors/dfuse/dfuse_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/diffbot/diffbot.go b/pkg/detectors/diffbot/diffbot.go index 47fb787f98d4..5f9494168e20 100644 --- a/pkg/detectors/diffbot/diffbot.go +++ b/pkg/detectors/diffbot/diffbot.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Diffbot secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/diggernaut/diggernaut.go b/pkg/detectors/diggernaut/diggernaut.go index 4b48f029d002..cb309211d1e0 100644 --- a/pkg/detectors/diggernaut/diggernaut.go +++ b/pkg/detectors/diggernaut/diggernaut.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Diggernaut secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/diggernaut/diggernaut_test.go b/pkg/detectors/diggernaut/diggernaut_test.go index 46d49b0c2284..35f231af5b21 100644 --- a/pkg/detectors/diggernaut/diggernaut_test.go +++ b/pkg/detectors/diggernaut/diggernaut_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/digitaloceantoken/digitaloceantoken.go b/pkg/detectors/digitaloceantoken/digitaloceantoken.go index 869bdd3e593f..dae8ba230f71 100644 --- a/pkg/detectors/digitaloceantoken/digitaloceantoken.go +++ b/pkg/detectors/digitaloceantoken/digitaloceantoken.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify DigitalOceanToken secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/digitaloceantoken/digitaloceantoken_test.go b/pkg/detectors/digitaloceantoken/digitaloceantoken_test.go index d1ff85876952..cee947ca99db 100644 --- a/pkg/detectors/digitaloceantoken/digitaloceantoken_test.go +++ b/pkg/detectors/digitaloceantoken/digitaloceantoken_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/digitaloceanv2/digitaloceanv2.go b/pkg/detectors/digitaloceanv2/digitaloceanv2.go index bc0dd5c10edf..ea3028fb8318 100644 --- a/pkg/detectors/digitaloceanv2/digitaloceanv2.go +++ b/pkg/detectors/digitaloceanv2/digitaloceanv2.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify DigitalOceanV2 secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/digitaloceanv2/digitaloceanv2_test.go b/pkg/detectors/digitaloceanv2/digitaloceanv2_test.go index 61c067d920a1..aeeb646e7d8e 100644 --- a/pkg/detectors/digitaloceanv2/digitaloceanv2_test.go +++ b/pkg/detectors/digitaloceanv2/digitaloceanv2_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/discordbottoken/discordbottoken.go b/pkg/detectors/discordbottoken/discordbottoken.go index d126e384c79f..f27147bb5cfe 100644 --- a/pkg/detectors/discordbottoken/discordbottoken.go +++ b/pkg/detectors/discordbottoken/discordbottoken.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify DiscordBotToken secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatch := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/discordbottoken/discordbottoken_test.go b/pkg/detectors/discordbottoken/discordbottoken_test.go index 400b7c933cac..3f2da1a420fc 100644 --- a/pkg/detectors/discordbottoken/discordbottoken_test.go +++ b/pkg/detectors/discordbottoken/discordbottoken_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/discordwebhook/discordwebhook.go b/pkg/detectors/discordwebhook/discordwebhook.go index 2db4f57d3a97..555201bf0f32 100644 --- a/pkg/detectors/discordwebhook/discordwebhook.go +++ b/pkg/detectors/discordwebhook/discordwebhook.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify DiscordWebhook secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/discordwebhook/discordwebhook_test.go b/pkg/detectors/discordwebhook/discordwebhook_test.go index 50a874715429..17a06b4fb961 100644 --- a/pkg/detectors/discordwebhook/discordwebhook_test.go +++ b/pkg/detectors/discordwebhook/discordwebhook_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/disqus/disqus.go b/pkg/detectors/disqus/disqus.go index 565753fed978..051222625f32 100644 --- a/pkg/detectors/disqus/disqus.go +++ b/pkg/detectors/disqus/disqus.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Disqus secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/disqus/disqus_test.go b/pkg/detectors/disqus/disqus_test.go index 2c8d073012d1..9e21b8806acc 100644 --- a/pkg/detectors/disqus/disqus_test.go +++ b/pkg/detectors/disqus/disqus_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/ditto/ditto.go b/pkg/detectors/ditto/ditto.go index 5ade311d555d..b26efabd7f96 100644 --- a/pkg/detectors/ditto/ditto.go +++ b/pkg/detectors/ditto/ditto.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Ditto secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/ditto/ditto_test.go b/pkg/detectors/ditto/ditto_test.go index 5871fc377d3c..057fbbcda9db 100644 --- a/pkg/detectors/ditto/ditto_test.go +++ b/pkg/detectors/ditto/ditto_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/dnscheck/dnscheck.go b/pkg/detectors/dnscheck/dnscheck.go index 9abb4540523f..f44b551cef27 100644 --- a/pkg/detectors/dnscheck/dnscheck.go +++ b/pkg/detectors/dnscheck/dnscheck.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Dnscheck secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idmatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/dnscheck/dnscheck_test.go b/pkg/detectors/dnscheck/dnscheck_test.go index 4b547a8fc12a..c9caf7e3805a 100644 --- a/pkg/detectors/dnscheck/dnscheck_test.go +++ b/pkg/detectors/dnscheck/dnscheck_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/dockerhub/dockerhub.go b/pkg/detectors/dockerhub/dockerhub.go index d304e3d3d2cf..d26965b732d9 100644 --- a/pkg/detectors/dockerhub/dockerhub.go +++ b/pkg/detectors/dockerhub/dockerhub.go @@ -37,7 +37,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Dockerhub secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) emailMatches := emailPat.FindAllString(dataStr, -1) dataStr = emailPat.ReplaceAllString(dataStr, "") diff --git a/pkg/detectors/docparser/docparser.go b/pkg/detectors/docparser/docparser.go index ce9a16fd5ef8..505563c840a7 100644 --- a/pkg/detectors/docparser/docparser.go +++ b/pkg/detectors/docparser/docparser.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Docparser secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/docparser/docparser_test.go b/pkg/detectors/docparser/docparser_test.go index 09b0ba5c54e5..b098185e979e 100644 --- a/pkg/detectors/docparser/docparser_test.go +++ b/pkg/detectors/docparser/docparser_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/documo/documo.go b/pkg/detectors/documo/documo.go index 7f0d0986be31..72bb20ee23de 100644 --- a/pkg/detectors/documo/documo.go +++ b/pkg/detectors/documo/documo.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Documo secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/documo/documo_test.go b/pkg/detectors/documo/documo_test.go index f4673755208f..da1b405cfdb3 100644 --- a/pkg/detectors/documo/documo_test.go +++ b/pkg/detectors/documo/documo_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/docusign/docusign.go b/pkg/detectors/docusign/docusign.go index 92008dee46b3..46c3f7ff678a 100644 --- a/pkg/detectors/docusign/docusign.go +++ b/pkg/detectors/docusign/docusign.go @@ -4,11 +4,12 @@ import ( "context" "encoding/base64" "fmt" - "github.com/go-errors/errors" "net/http" "regexp" "strings" + "github.com/go-errors/errors" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" @@ -39,7 +40,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Docusign secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) secretMatches := secretPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/docusign/docusign_test.go b/pkg/detectors/docusign/docusign_test.go index c9531248a276..291f7ba2c774 100644 --- a/pkg/detectors/docusign/docusign_test.go +++ b/pkg/detectors/docusign/docusign_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/doppler/doppler.go b/pkg/detectors/doppler/doppler.go index 654a1232246e..ae0e8ab5e277 100644 --- a/pkg/detectors/doppler/doppler.go +++ b/pkg/detectors/doppler/doppler.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Doppler secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/doppler/doppler_test.go b/pkg/detectors/doppler/doppler_test.go index dc7374b4278e..bdbe03811514 100644 --- a/pkg/detectors/doppler/doppler_test.go +++ b/pkg/detectors/doppler/doppler_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/dotmailer/dotmailer.go b/pkg/detectors/dotmailer/dotmailer.go index 77c9bd0b9854..996b53b93244 100644 --- a/pkg/detectors/dotmailer/dotmailer.go +++ b/pkg/detectors/dotmailer/dotmailer.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Dotmailer secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) passMatches := passPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/dotmailer/dotmailer_test.go b/pkg/detectors/dotmailer/dotmailer_test.go index ea13358443ee..d21aeef40345 100644 --- a/pkg/detectors/dotmailer/dotmailer_test.go +++ b/pkg/detectors/dotmailer/dotmailer_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/dovico/dovico.go b/pkg/detectors/dovico/dovico.go index 76d96816f353..ee1a11701de2 100644 --- a/pkg/detectors/dovico/dovico.go +++ b/pkg/detectors/dovico/dovico.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Dovico secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) userMatches := userPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/dovico/dovico_test.go b/pkg/detectors/dovico/dovico_test.go index 38865f192be2..88db9bf0587e 100644 --- a/pkg/detectors/dovico/dovico_test.go +++ b/pkg/detectors/dovico/dovico_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/dronahq/dronahq.go b/pkg/detectors/dronahq/dronahq.go index dff7a25ff0e3..91c6c26a94ae 100644 --- a/pkg/detectors/dronahq/dronahq.go +++ b/pkg/detectors/dronahq/dronahq.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify DronaHQ secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/dronahq/dronahq_test.go b/pkg/detectors/dronahq/dronahq_test.go index afa6579da20a..fff0f218bd6d 100644 --- a/pkg/detectors/dronahq/dronahq_test.go +++ b/pkg/detectors/dronahq/dronahq_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/droneci/droneci.go b/pkg/detectors/droneci/droneci.go index 4bbcc18e6eb8..5363f61016ba 100644 --- a/pkg/detectors/droneci/droneci.go +++ b/pkg/detectors/droneci/droneci.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify DroneCI secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/droneci/droneci_test.go b/pkg/detectors/droneci/droneci_test.go index cd3d3195dc09..038c14f40631 100644 --- a/pkg/detectors/droneci/droneci_test.go +++ b/pkg/detectors/droneci/droneci_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/dropbox/dropbox.go b/pkg/detectors/dropbox/dropbox.go index 6bd92a494c44..76d4a2300622 100644 --- a/pkg/detectors/dropbox/dropbox.go +++ b/pkg/detectors/dropbox/dropbox.go @@ -29,7 +29,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Dropbox secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/dropbox/dropbox_test.go b/pkg/detectors/dropbox/dropbox_test.go index 8b2408f82964..3b13b813c537 100644 --- a/pkg/detectors/dropbox/dropbox_test.go +++ b/pkg/detectors/dropbox/dropbox_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" diff --git a/pkg/detectors/duply/duply.go b/pkg/detectors/duply/duply.go index 23ee96710aab..d89f31983d3a 100644 --- a/pkg/detectors/duply/duply.go +++ b/pkg/detectors/duply/duply.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Duply secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/duply/duply_test.go b/pkg/detectors/duply/duply_test.go index 50903f4cdfba..a68ce6cc32d7 100644 --- a/pkg/detectors/duply/duply_test.go +++ b/pkg/detectors/duply/duply_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/dwolla/dwolla.go b/pkg/detectors/dwolla/dwolla.go index fb738289f927..c7e160edae60 100644 --- a/pkg/detectors/dwolla/dwolla.go +++ b/pkg/detectors/dwolla/dwolla.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Dwolla secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) secretMatches := secretPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/dynalist/dynalist.go b/pkg/detectors/dynalist/dynalist.go index 1ba986802f0a..7a4d827091ae 100644 --- a/pkg/detectors/dynalist/dynalist.go +++ b/pkg/detectors/dynalist/dynalist.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Dynalist secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/dynalist/dynalist_test.go b/pkg/detectors/dynalist/dynalist_test.go index e16ee89d9ef8..2e945f60685e 100644 --- a/pkg/detectors/dynalist/dynalist_test.go +++ b/pkg/detectors/dynalist/dynalist_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/dyspatch/dyspatch.go b/pkg/detectors/dyspatch/dyspatch.go index 8f078345182f..71aec4f1b445 100644 --- a/pkg/detectors/dyspatch/dyspatch.go +++ b/pkg/detectors/dyspatch/dyspatch.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Dyspatch secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/dyspatch/dyspatch_test.go b/pkg/detectors/dyspatch/dyspatch_test.go index 7658fde19184..f433134fef27 100644 --- a/pkg/detectors/dyspatch/dyspatch_test.go +++ b/pkg/detectors/dyspatch/dyspatch_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/eagleeyenetworks/eagleeyenetworks.go b/pkg/detectors/eagleeyenetworks/eagleeyenetworks.go index 3c3fd4e7bbdf..0b307046a6e6 100644 --- a/pkg/detectors/eagleeyenetworks/eagleeyenetworks.go +++ b/pkg/detectors/eagleeyenetworks/eagleeyenetworks.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify EagleEyeNetworks secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) emailMatches := email.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/eagleeyenetworks/eagleeyenetworks_test.go b/pkg/detectors/eagleeyenetworks/eagleeyenetworks_test.go index e569e2840ab0..e939ab116742 100644 --- a/pkg/detectors/eagleeyenetworks/eagleeyenetworks_test.go +++ b/pkg/detectors/eagleeyenetworks/eagleeyenetworks_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/easyinsight/easyinsight.go b/pkg/detectors/easyinsight/easyinsight.go index 7011dacd6b7b..1837a07a4aef 100644 --- a/pkg/detectors/easyinsight/easyinsight.go +++ b/pkg/detectors/easyinsight/easyinsight.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify EasyInsight secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/ecostruxureit/ecostruxureit.go b/pkg/detectors/ecostruxureit/ecostruxureit.go index b4762cf53e1d..4dbe0b8e82a2 100644 --- a/pkg/detectors/ecostruxureit/ecostruxureit.go +++ b/pkg/detectors/ecostruxureit/ecostruxureit.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify EcoStruxureIT secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/ecostruxureit/ecostruxureit_test.go b/pkg/detectors/ecostruxureit/ecostruxureit_test.go index 019701cffadf..15ebbf241d50 100644 --- a/pkg/detectors/ecostruxureit/ecostruxureit_test.go +++ b/pkg/detectors/ecostruxureit/ecostruxureit_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/edamam/edamam.go b/pkg/detectors/edamam/edamam.go index 65773b15821b..06fc9dcb8c6d 100644 --- a/pkg/detectors/edamam/edamam.go +++ b/pkg/detectors/edamam/edamam.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Edamam secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/edamam/edamam_test.go b/pkg/detectors/edamam/edamam_test.go index 1951a12ffaa7..f0bac0135b93 100644 --- a/pkg/detectors/edamam/edamam_test.go +++ b/pkg/detectors/edamam/edamam_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/edenai/edenai.go b/pkg/detectors/edenai/edenai.go index 9301fe6c62ec..5cccdc596754 100644 --- a/pkg/detectors/edenai/edenai.go +++ b/pkg/detectors/edenai/edenai.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify EdenAI secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/edenai/edenai_test.go b/pkg/detectors/edenai/edenai_test.go index df8fff25e219..d7c0f85aa661 100644 --- a/pkg/detectors/edenai/edenai_test.go +++ b/pkg/detectors/edenai/edenai_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/eightxeight/eightxeight.go b/pkg/detectors/eightxeight/eightxeight.go index 3e62e51f1394..be815c7cfc04 100644 --- a/pkg/detectors/eightxeight/eightxeight.go +++ b/pkg/detectors/eightxeight/eightxeight.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify EightxEight secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/elasticemail/elasticemail.go b/pkg/detectors/elasticemail/elasticemail.go index 39289c95d972..afc384f0dc67 100644 --- a/pkg/detectors/elasticemail/elasticemail.go +++ b/pkg/detectors/elasticemail/elasticemail.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ElasticEmail secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/enablex/enablex.go b/pkg/detectors/enablex/enablex.go index 3242450798a3..b2b4137ae424 100644 --- a/pkg/detectors/enablex/enablex.go +++ b/pkg/detectors/enablex/enablex.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Enablex secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/enigma/enigma.go b/pkg/detectors/enigma/enigma.go index b201d355d27c..16d6c7bc5d3e 100644 --- a/pkg/detectors/enigma/enigma.go +++ b/pkg/detectors/enigma/enigma.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Enigma secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/enigma/enigma_test.go b/pkg/detectors/enigma/enigma_test.go index e1389586d228..cbcf1fa21079 100644 --- a/pkg/detectors/enigma/enigma_test.go +++ b/pkg/detectors/enigma/enigma_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/envoyapikey/envoyapikey.go b/pkg/detectors/envoyapikey/envoyapikey.go index 263fb44278c7..af0fc087c661 100644 --- a/pkg/detectors/envoyapikey/envoyapikey.go +++ b/pkg/detectors/envoyapikey/envoyapikey.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Envoy secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/etherscan/etherscan.go b/pkg/detectors/etherscan/etherscan.go index b34a6fa9d7ee..bbbdb9e6a3be 100644 --- a/pkg/detectors/etherscan/etherscan.go +++ b/pkg/detectors/etherscan/etherscan.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Etherscan secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/etherscan/etherscan_test.go b/pkg/detectors/etherscan/etherscan_test.go index 80b278f35ba0..feea905b9c77 100644 --- a/pkg/detectors/etherscan/etherscan_test.go +++ b/pkg/detectors/etherscan/etherscan_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/ethplorer/ethplorer.go b/pkg/detectors/ethplorer/ethplorer.go index 93f3853c05f5..edb4c490c804 100644 --- a/pkg/detectors/ethplorer/ethplorer.go +++ b/pkg/detectors/ethplorer/ethplorer.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Ethplorer secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/ethplorer/ethplorer_test.go b/pkg/detectors/ethplorer/ethplorer_test.go index eb1fd58c6a16..1f3dc3c44640 100644 --- a/pkg/detectors/ethplorer/ethplorer_test.go +++ b/pkg/detectors/ethplorer/ethplorer_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/etsyapikey/etsyapikey.go b/pkg/detectors/etsyapikey/etsyapikey.go index f1a4d6e937d4..1af79eada086 100644 --- a/pkg/detectors/etsyapikey/etsyapikey.go +++ b/pkg/detectors/etsyapikey/etsyapikey.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify EtsyApiKey secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/etsyapikey/etsyapikey_test.go b/pkg/detectors/etsyapikey/etsyapikey_test.go index 21514928480f..1a6cb1008be0 100644 --- a/pkg/detectors/etsyapikey/etsyapikey_test.go +++ b/pkg/detectors/etsyapikey/etsyapikey_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/eventbrite/eventbrite.go b/pkg/detectors/eventbrite/eventbrite.go index 821596371762..f499b37431dc 100644 --- a/pkg/detectors/eventbrite/eventbrite.go +++ b/pkg/detectors/eventbrite/eventbrite.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Eventbrite secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/eventbrite/eventbrite_test.go b/pkg/detectors/eventbrite/eventbrite_test.go index d5eddbd5e665..117eb86b70a1 100644 --- a/pkg/detectors/eventbrite/eventbrite_test.go +++ b/pkg/detectors/eventbrite/eventbrite_test.go @@ -6,11 +6,12 @@ package eventbrite import ( "context" "fmt" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "testing" "time" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/everhour/everhour.go b/pkg/detectors/everhour/everhour.go index 8d7876bad77a..3b270688eb5b 100644 --- a/pkg/detectors/everhour/everhour.go +++ b/pkg/detectors/everhour/everhour.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Everhour secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/everhour/everhour_test.go b/pkg/detectors/everhour/everhour_test.go index 7694c0082276..eb826494d070 100644 --- a/pkg/detectors/everhour/everhour_test.go +++ b/pkg/detectors/everhour/everhour_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/exchangerateapi/exchangerateapi.go b/pkg/detectors/exchangerateapi/exchangerateapi.go index 39e7c1b6808b..0bb71d28090d 100644 --- a/pkg/detectors/exchangerateapi/exchangerateapi.go +++ b/pkg/detectors/exchangerateapi/exchangerateapi.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ExchangeRateAPI secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/exchangeratesapi/exchangeratesapi.go b/pkg/detectors/exchangeratesapi/exchangeratesapi.go index 3d8113779f2e..fe12c29dde1e 100644 --- a/pkg/detectors/exchangeratesapi/exchangeratesapi.go +++ b/pkg/detectors/exchangeratesapi/exchangeratesapi.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ExchangeRatesAPI secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/exchangeratesapi/exchangeratesapi_test.go b/pkg/detectors/exchangeratesapi/exchangeratesapi_test.go index 9dc1dc5d9f0e..b14d18d5d640 100644 --- a/pkg/detectors/exchangeratesapi/exchangeratesapi_test.go +++ b/pkg/detectors/exchangeratesapi/exchangeratesapi_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/exportsdk/exportsdk.go b/pkg/detectors/exportsdk/exportsdk.go index 024184f65717..eb635d2876b8 100644 --- a/pkg/detectors/exportsdk/exportsdk.go +++ b/pkg/detectors/exportsdk/exportsdk.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ExportSDK secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idmatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/exportsdk/exportsdk_test.go b/pkg/detectors/exportsdk/exportsdk_test.go index df8732ea0ca0..6d9720b39c44 100644 --- a/pkg/detectors/exportsdk/exportsdk_test.go +++ b/pkg/detectors/exportsdk/exportsdk_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/extractorapi/extractorapi.go b/pkg/detectors/extractorapi/extractorapi.go index 922e0a98f2ee..b25cfa08b2d9 100644 --- a/pkg/detectors/extractorapi/extractorapi.go +++ b/pkg/detectors/extractorapi/extractorapi.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ExtractorAPI secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/extractorapi/extractorapi_test.go b/pkg/detectors/extractorapi/extractorapi_test.go index dd3df82d2f56..415d42b5b429 100644 --- a/pkg/detectors/extractorapi/extractorapi_test.go +++ b/pkg/detectors/extractorapi/extractorapi_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/facebookoauth/facebookoauth.go b/pkg/detectors/facebookoauth/facebookoauth.go index 6fe5d2e80317..0eece3e99e3c 100644 --- a/pkg/detectors/facebookoauth/facebookoauth.go +++ b/pkg/detectors/facebookoauth/facebookoauth.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify FacebookOAuth secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) apiIdMatches := apiIdPat.FindAllStringSubmatch(dataStr, -1) apiSecretMatches := apiSecretPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/facebookoauth/facebookoauth_test.go b/pkg/detectors/facebookoauth/facebookoauth_test.go index c8947b65b9b3..0740ff67334c 100644 --- a/pkg/detectors/facebookoauth/facebookoauth_test.go +++ b/pkg/detectors/facebookoauth/facebookoauth_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/faceplusplus/faceplusplus.go b/pkg/detectors/faceplusplus/faceplusplus.go index d0163eaf5f9c..6523d506b818 100644 --- a/pkg/detectors/faceplusplus/faceplusplus.go +++ b/pkg/detectors/faceplusplus/faceplusplus.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Faceplusplus secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) secretMatches := secretPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/faceplusplus/faceplusplus_test.go b/pkg/detectors/faceplusplus/faceplusplus_test.go index 544a0a736a2c..e04f107dab11 100644 --- a/pkg/detectors/faceplusplus/faceplusplus_test.go +++ b/pkg/detectors/faceplusplus/faceplusplus_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/fastforex/fastforex.go b/pkg/detectors/fastforex/fastforex.go index 6d05255b92b4..e9d4358374d2 100644 --- a/pkg/detectors/fastforex/fastforex.go +++ b/pkg/detectors/fastforex/fastforex.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify FastForex secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/fastforex/fastforex_test.go b/pkg/detectors/fastforex/fastforex_test.go index 3902de7dff84..6f8bf54c23bb 100644 --- a/pkg/detectors/fastforex/fastforex_test.go +++ b/pkg/detectors/fastforex/fastforex_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/fastlypersonaltoken/fastlypersonaltoken.go b/pkg/detectors/fastlypersonaltoken/fastlypersonaltoken.go index 9a2416a06020..296d9fd7dc45 100644 --- a/pkg/detectors/fastlypersonaltoken/fastlypersonaltoken.go +++ b/pkg/detectors/fastlypersonaltoken/fastlypersonaltoken.go @@ -41,7 +41,7 @@ type fastlyUserRes struct { // FromData will find and optionally verify FastlyPersonalToken secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/fastlypersonaltoken/fastlypersonaltoken_test.go b/pkg/detectors/fastlypersonaltoken/fastlypersonaltoken_test.go index cbf2c5426c62..d37eb27b9501 100644 --- a/pkg/detectors/fastlypersonaltoken/fastlypersonaltoken_test.go +++ b/pkg/detectors/fastlypersonaltoken/fastlypersonaltoken_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/feedier/feedier.go b/pkg/detectors/feedier/feedier.go index 94b41d598704..cabec7b94815 100644 --- a/pkg/detectors/feedier/feedier.go +++ b/pkg/detectors/feedier/feedier.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Feedier secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/feedier/feedier_test.go b/pkg/detectors/feedier/feedier_test.go index 5c00d07a0a22..78ac8816559f 100644 --- a/pkg/detectors/feedier/feedier_test.go +++ b/pkg/detectors/feedier/feedier_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/fetchrss/fetchrss.go b/pkg/detectors/fetchrss/fetchrss.go index 19490cfe286b..0de2ee899daa 100644 --- a/pkg/detectors/fetchrss/fetchrss.go +++ b/pkg/detectors/fetchrss/fetchrss.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Fetchrss secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/fetchrss/fetchrss_test.go b/pkg/detectors/fetchrss/fetchrss_test.go index 59f4fca77985..b6d138e2034e 100644 --- a/pkg/detectors/fetchrss/fetchrss_test.go +++ b/pkg/detectors/fetchrss/fetchrss_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/fibery/fibery.go b/pkg/detectors/fibery/fibery.go index 11f11eb313da..e294276ff129 100644 --- a/pkg/detectors/fibery/fibery.go +++ b/pkg/detectors/fibery/fibery.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Fibery secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) domainMatches := domainPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/fibery/fibery_test.go b/pkg/detectors/fibery/fibery_test.go index 3872c788de19..de2077736afd 100644 --- a/pkg/detectors/fibery/fibery_test.go +++ b/pkg/detectors/fibery/fibery_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/figmapersonalaccesstoken/v1/figmapersonalaccesstoken.go b/pkg/detectors/figmapersonalaccesstoken/v1/figmapersonalaccesstoken.go index 59dda2dfdbff..c401ed09ba8c 100644 --- a/pkg/detectors/figmapersonalaccesstoken/v1/figmapersonalaccesstoken.go +++ b/pkg/detectors/figmapersonalaccesstoken/v1/figmapersonalaccesstoken.go @@ -36,7 +36,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify FigmaPersonalAccessToken secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/figmapersonalaccesstoken/v1/figmapersonalaccesstoken_test.go b/pkg/detectors/figmapersonalaccesstoken/v1/figmapersonalaccesstoken_test.go index 22453c03235f..f21d544ce22b 100644 --- a/pkg/detectors/figmapersonalaccesstoken/v1/figmapersonalaccesstoken_test.go +++ b/pkg/detectors/figmapersonalaccesstoken/v1/figmapersonalaccesstoken_test.go @@ -11,6 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" diff --git a/pkg/detectors/figmapersonalaccesstoken/v2/figmapersonalaccesstoken_v2.go b/pkg/detectors/figmapersonalaccesstoken/v2/figmapersonalaccesstoken_v2.go index ec7c765e266b..a0e4238bbde6 100644 --- a/pkg/detectors/figmapersonalaccesstoken/v2/figmapersonalaccesstoken_v2.go +++ b/pkg/detectors/figmapersonalaccesstoken/v2/figmapersonalaccesstoken_v2.go @@ -35,7 +35,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify FigmaPersonalAccessToken secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/figmapersonalaccesstoken/v2/figmapersonalaccesstoken_v2_test.go b/pkg/detectors/figmapersonalaccesstoken/v2/figmapersonalaccesstoken_v2_test.go index 7c8bc4e347d5..43fcfde2bd0d 100644 --- a/pkg/detectors/figmapersonalaccesstoken/v2/figmapersonalaccesstoken_v2_test.go +++ b/pkg/detectors/figmapersonalaccesstoken/v2/figmapersonalaccesstoken_v2_test.go @@ -11,6 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" diff --git a/pkg/detectors/fileio/fileio.go b/pkg/detectors/fileio/fileio.go index 4bb6cdb8b373..900df63420ae 100644 --- a/pkg/detectors/fileio/fileio.go +++ b/pkg/detectors/fileio/fileio.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify FileIO secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/fileio/fileio_test.go b/pkg/detectors/fileio/fileio_test.go index 97f82c56c8f6..e9be5fc18e0f 100644 --- a/pkg/detectors/fileio/fileio_test.go +++ b/pkg/detectors/fileio/fileio_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/finage/finage.go b/pkg/detectors/finage/finage.go index 1901ed601a9d..f2663f06c440 100644 --- a/pkg/detectors/finage/finage.go +++ b/pkg/detectors/finage/finage.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Finage secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/financialmodelingprep/financialmodelingprep.go b/pkg/detectors/financialmodelingprep/financialmodelingprep.go index cf7d7a17fc78..5fa7888a8647 100644 --- a/pkg/detectors/financialmodelingprep/financialmodelingprep.go +++ b/pkg/detectors/financialmodelingprep/financialmodelingprep.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify FinancialModelingPrep secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/financialmodelingprep/financialmodelingprep_test.go b/pkg/detectors/financialmodelingprep/financialmodelingprep_test.go index 66355a5265cb..3718e0aa787a 100644 --- a/pkg/detectors/financialmodelingprep/financialmodelingprep_test.go +++ b/pkg/detectors/financialmodelingprep/financialmodelingprep_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/findl/findl.go b/pkg/detectors/findl/findl.go index 323cd90c9fa0..e451158cdc38 100644 --- a/pkg/detectors/findl/findl.go +++ b/pkg/detectors/findl/findl.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Findl secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/findl/findl_test.go b/pkg/detectors/findl/findl_test.go index 49c9edf0975d..d125ad88353e 100644 --- a/pkg/detectors/findl/findl_test.go +++ b/pkg/detectors/findl/findl_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/finnhub/finnhub.go b/pkg/detectors/finnhub/finnhub.go index 57e0caaf7b63..18bab39badd2 100644 --- a/pkg/detectors/finnhub/finnhub.go +++ b/pkg/detectors/finnhub/finnhub.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Finnhub secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/finnhub/finnhub_test.go b/pkg/detectors/finnhub/finnhub_test.go index 5366f8007920..f2114a65d45f 100644 --- a/pkg/detectors/finnhub/finnhub_test.go +++ b/pkg/detectors/finnhub/finnhub_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/fixerio/fixerio.go b/pkg/detectors/fixerio/fixerio.go index 17df2ef99f33..cd0f9a131719 100644 --- a/pkg/detectors/fixerio/fixerio.go +++ b/pkg/detectors/fixerio/fixerio.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify FixerIO secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/fixerio/fixerio_test.go b/pkg/detectors/fixerio/fixerio_test.go index 67b4c1aef06d..0ae7bd16c1dc 100644 --- a/pkg/detectors/fixerio/fixerio_test.go +++ b/pkg/detectors/fixerio/fixerio_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/flatio/flatio.go b/pkg/detectors/flatio/flatio.go index bffb97a9fb94..4b2357f87e70 100644 --- a/pkg/detectors/flatio/flatio.go +++ b/pkg/detectors/flatio/flatio.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify FlatIO secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/flatio/flatio_test.go b/pkg/detectors/flatio/flatio_test.go index 3f6ada9d82cd..f38acd603c92 100644 --- a/pkg/detectors/flatio/flatio_test.go +++ b/pkg/detectors/flatio/flatio_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/fleetbase/fleetbase.go b/pkg/detectors/fleetbase/fleetbase.go index 0b5746efe282..d24361104e0a 100644 --- a/pkg/detectors/fleetbase/fleetbase.go +++ b/pkg/detectors/fleetbase/fleetbase.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Fleetbase secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/fleetbase/fleetbase_test.go b/pkg/detectors/fleetbase/fleetbase_test.go index daa5443b0932..721d06f1fa84 100644 --- a/pkg/detectors/fleetbase/fleetbase_test.go +++ b/pkg/detectors/fleetbase/fleetbase_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/flickr/flickr.go b/pkg/detectors/flickr/flickr.go index 2eabda609384..cd50a70000f3 100644 --- a/pkg/detectors/flickr/flickr.go +++ b/pkg/detectors/flickr/flickr.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Flickr secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/flickr/flickr_test.go b/pkg/detectors/flickr/flickr_test.go index 8c78a2bc18cf..699bdd521378 100644 --- a/pkg/detectors/flickr/flickr_test.go +++ b/pkg/detectors/flickr/flickr_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/flightapi/flightapi.go b/pkg/detectors/flightapi/flightapi.go index a6249c300a6b..74edc6a863eb 100644 --- a/pkg/detectors/flightapi/flightapi.go +++ b/pkg/detectors/flightapi/flightapi.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify FlightApi secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/flightapi/flightapi_test.go b/pkg/detectors/flightapi/flightapi_test.go index f34732eff397..a61d225a9f54 100644 --- a/pkg/detectors/flightapi/flightapi_test.go +++ b/pkg/detectors/flightapi/flightapi_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/flightlabs/flightlabs.go b/pkg/detectors/flightlabs/flightlabs.go index 18a3e390d93c..1cf8957a21b4 100644 --- a/pkg/detectors/flightlabs/flightlabs.go +++ b/pkg/detectors/flightlabs/flightlabs.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify FlightLabs secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/flightlabs/flightlabs_test.go b/pkg/detectors/flightlabs/flightlabs_test.go index 54d90a8cabd4..ab8ecbcf07e3 100644 --- a/pkg/detectors/flightlabs/flightlabs_test.go +++ b/pkg/detectors/flightlabs/flightlabs_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/flightstats/flightstats.go b/pkg/detectors/flightstats/flightstats.go index 2d6253c90404..8949ce2d7a3e 100644 --- a/pkg/detectors/flightstats/flightstats.go +++ b/pkg/detectors/flightstats/flightstats.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Flightstats secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/float/float.go b/pkg/detectors/float/float.go index 211911932007..0e58cf55bb8f 100644 --- a/pkg/detectors/float/float.go +++ b/pkg/detectors/float/float.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Float secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/flowdash/flowdash.go b/pkg/detectors/flowdash/flowdash.go index 2cc5d72fa596..f7799c302d07 100644 --- a/pkg/detectors/flowdash/flowdash.go +++ b/pkg/detectors/flowdash/flowdash.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Flowdash secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/flowdash/flowdash_test.go b/pkg/detectors/flowdash/flowdash_test.go index dbfbb23172a7..00ab82c5a54b 100644 --- a/pkg/detectors/flowdash/flowdash_test.go +++ b/pkg/detectors/flowdash/flowdash_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/flowflu/flowflu.go b/pkg/detectors/flowflu/flowflu.go index bc58079823a7..c666f88b8c5d 100644 --- a/pkg/detectors/flowflu/flowflu.go +++ b/pkg/detectors/flowflu/flowflu.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify FlowFlu secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) accountMatches := accountPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/flowflu/flowflu_test.go b/pkg/detectors/flowflu/flowflu_test.go index 166e8383ba7a..c515441c77d5 100644 --- a/pkg/detectors/flowflu/flowflu_test.go +++ b/pkg/detectors/flowflu/flowflu_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/flutterwave/flutterwave.go b/pkg/detectors/flutterwave/flutterwave.go index bad763f7c8a9..63f040e4e044 100644 --- a/pkg/detectors/flutterwave/flutterwave.go +++ b/pkg/detectors/flutterwave/flutterwave.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Flutterwave secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/flutterwave/flutterwave_test.go b/pkg/detectors/flutterwave/flutterwave_test.go index 28e3644904b8..4bbc60b05a27 100644 --- a/pkg/detectors/flutterwave/flutterwave_test.go +++ b/pkg/detectors/flutterwave/flutterwave_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/fmfw/fmfw.go b/pkg/detectors/fmfw/fmfw.go index f406be1387e1..92324cc1b4eb 100644 --- a/pkg/detectors/fmfw/fmfw.go +++ b/pkg/detectors/fmfw/fmfw.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Fmfw secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/fmfw/fmfw_test.go b/pkg/detectors/fmfw/fmfw_test.go index c6f5683b229a..9d6ff883b73e 100644 --- a/pkg/detectors/fmfw/fmfw_test.go +++ b/pkg/detectors/fmfw/fmfw_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/formbucket/formbucket.go b/pkg/detectors/formbucket/formbucket.go index 62ab3fd929d3..59d12fec2997 100644 --- a/pkg/detectors/formbucket/formbucket.go +++ b/pkg/detectors/formbucket/formbucket.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify FormBucket secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/formcraft/formcraft.go b/pkg/detectors/formcraft/formcraft.go index 1b040a17cfbc..93526b776f82 100644 --- a/pkg/detectors/formcraft/formcraft.go +++ b/pkg/detectors/formcraft/formcraft.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Formcraft secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/formcraft/formcraft_test.go b/pkg/detectors/formcraft/formcraft_test.go index a4cb6bc77ee3..446ee4fb18f3 100644 --- a/pkg/detectors/formcraft/formcraft_test.go +++ b/pkg/detectors/formcraft/formcraft_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/formio/formio.go b/pkg/detectors/formio/formio.go index f843d6e9bd81..4e3934ad1aa6 100644 --- a/pkg/detectors/formio/formio.go +++ b/pkg/detectors/formio/formio.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify FormIO secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/formsite/formsite.go b/pkg/detectors/formsite/formsite.go index 38addb63a14d..7259418ef6e9 100644 --- a/pkg/detectors/formsite/formsite.go +++ b/pkg/detectors/formsite/formsite.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Formsite secrets in a given set of bytes.. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) serverMatches := serverPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/formsite/formsite_test.go b/pkg/detectors/formsite/formsite_test.go index 376b0a9afe50..cafc9c0ef4c5 100644 --- a/pkg/detectors/formsite/formsite_test.go +++ b/pkg/detectors/formsite/formsite_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/foursquare/foursquare.go b/pkg/detectors/foursquare/foursquare.go index 6fbc66e03bc3..5e83e34851e7 100644 --- a/pkg/detectors/foursquare/foursquare.go +++ b/pkg/detectors/foursquare/foursquare.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Foursquare secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) secretMatches := secretMatch.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/foursquare/foursquare_test.go b/pkg/detectors/foursquare/foursquare_test.go index 3220efad0492..1ca314aaf1b6 100644 --- a/pkg/detectors/foursquare/foursquare_test.go +++ b/pkg/detectors/foursquare/foursquare_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/frameio/frameio.go b/pkg/detectors/frameio/frameio.go index 5c0d47d6eb1e..1113db010fd8 100644 --- a/pkg/detectors/frameio/frameio.go +++ b/pkg/detectors/frameio/frameio.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Frameio secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/frameio/frameio_test.go b/pkg/detectors/frameio/frameio_test.go index a6dda6085137..be93d92f2925 100644 --- a/pkg/detectors/frameio/frameio_test.go +++ b/pkg/detectors/frameio/frameio_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/freshbooks/freshbooks.go b/pkg/detectors/freshbooks/freshbooks.go index 271ec9072549..f2de91797391 100644 --- a/pkg/detectors/freshbooks/freshbooks.go +++ b/pkg/detectors/freshbooks/freshbooks.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Freshbooks secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) uriMatches := uriPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/freshdesk/freshdesk.go b/pkg/detectors/freshdesk/freshdesk.go index a0f425b9ad91..2d9d63cb5138 100644 --- a/pkg/detectors/freshdesk/freshdesk.go +++ b/pkg/detectors/freshdesk/freshdesk.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Freshdesk secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) urlMatches := urlPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/front/front.go b/pkg/detectors/front/front.go index f059f41baf12..757d368b18f8 100644 --- a/pkg/detectors/front/front.go +++ b/pkg/detectors/front/front.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Front secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/front/front_test.go b/pkg/detectors/front/front_test.go index 4cf649b7e7e2..c851b42ad177 100644 --- a/pkg/detectors/front/front_test.go +++ b/pkg/detectors/front/front_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/ftp/ftp.go b/pkg/detectors/ftp/ftp.go index c55cd541de05..e953d158095b 100644 --- a/pkg/detectors/ftp/ftp.go +++ b/pkg/detectors/ftp/ftp.go @@ -11,6 +11,7 @@ import ( "github.com/jlaffaye/ftp" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" ) @@ -42,7 +43,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify URI secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/ftp/ftp_test.go b/pkg/detectors/ftp/ftp_test.go index 434f6fb7b6d1..e0fa954f5e0a 100644 --- a/pkg/detectors/ftp/ftp_test.go +++ b/pkg/detectors/ftp/ftp_test.go @@ -5,11 +5,12 @@ package ftp import ( "context" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "testing" "time" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" ) diff --git a/pkg/detectors/fulcrum/fulcrum.go b/pkg/detectors/fulcrum/fulcrum.go index eae2e4463052..3b391a518311 100644 --- a/pkg/detectors/fulcrum/fulcrum.go +++ b/pkg/detectors/fulcrum/fulcrum.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify fullcrum secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/fulcrum/fulcrum_test.go b/pkg/detectors/fulcrum/fulcrum_test.go index 06d83d4ea6cb..87d2b845be52 100644 --- a/pkg/detectors/fulcrum/fulcrum_test.go +++ b/pkg/detectors/fulcrum/fulcrum_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/fullstory/fullstory.go b/pkg/detectors/fullstory/fullstory.go index 641080516a06..404183a57d32 100644 --- a/pkg/detectors/fullstory/fullstory.go +++ b/pkg/detectors/fullstory/fullstory.go @@ -35,7 +35,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Fullstory secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/fullstory/fullstory_test.go b/pkg/detectors/fullstory/fullstory_test.go index 3fe830567773..263930f75e2c 100644 --- a/pkg/detectors/fullstory/fullstory_test.go +++ b/pkg/detectors/fullstory/fullstory_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/fullstory_v2/fullstory_v2.go b/pkg/detectors/fullstory_v2/fullstory_v2.go index 196d80d2c8cc..89ead2c0a951 100644 --- a/pkg/detectors/fullstory_v2/fullstory_v2.go +++ b/pkg/detectors/fullstory_v2/fullstory_v2.go @@ -35,7 +35,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Fullstory secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/fullstory_v2/fullstory_v2_test.go b/pkg/detectors/fullstory_v2/fullstory_v2_test.go index 083ba2410e3d..dd4d26fa9f58 100644 --- a/pkg/detectors/fullstory_v2/fullstory_v2_test.go +++ b/pkg/detectors/fullstory_v2/fullstory_v2_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/fusebill/fusebill.go b/pkg/detectors/fusebill/fusebill.go index 689db0269829..e3396ab8415a 100644 --- a/pkg/detectors/fusebill/fusebill.go +++ b/pkg/detectors/fusebill/fusebill.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Fusebill secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/fxmarket/fxmarket.go b/pkg/detectors/fxmarket/fxmarket.go index 5a229f99440e..81434de2db7b 100644 --- a/pkg/detectors/fxmarket/fxmarket.go +++ b/pkg/detectors/fxmarket/fxmarket.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Fxmarket secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/fxmarket/fxmarket_test.go b/pkg/detectors/fxmarket/fxmarket_test.go index 10fbd296dc7d..2da1ca38d605 100644 --- a/pkg/detectors/fxmarket/fxmarket_test.go +++ b/pkg/detectors/fxmarket/fxmarket_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/gcp/gcp.go b/pkg/detectors/gcp/gcp.go index 8771fc252bb2..3de2deef5017 100644 --- a/pkg/detectors/gcp/gcp.go +++ b/pkg/detectors/gcp/gcp.go @@ -6,9 +6,11 @@ import ( "regexp" "strings" + "golang.org/x/oauth2/google" + + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" - "golang.org/x/oauth2/google" ) type Scanner struct{} @@ -47,7 +49,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify GCP secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllString(dataStr, -1) diff --git a/pkg/detectors/gcp/gcp_test.go b/pkg/detectors/gcp/gcp_test.go index b2540dcba7a7..d9f6ab8476ff 100644 --- a/pkg/detectors/gcp/gcp_test.go +++ b/pkg/detectors/gcp/gcp_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" diff --git a/pkg/detectors/geckoboard/geckoboard.go b/pkg/detectors/geckoboard/geckoboard.go index eda0bd430b74..5d0be6172c19 100644 --- a/pkg/detectors/geckoboard/geckoboard.go +++ b/pkg/detectors/geckoboard/geckoboard.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Geckoboard secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/geckoboard/geckoboard_test.go b/pkg/detectors/geckoboard/geckoboard_test.go index 2788ecd24d43..89c88867a733 100644 --- a/pkg/detectors/geckoboard/geckoboard_test.go +++ b/pkg/detectors/geckoboard/geckoboard_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/gemini/gemini.go b/pkg/detectors/gemini/gemini.go index 7e47f10a5b3a..5decf40f7bcb 100644 --- a/pkg/detectors/gemini/gemini.go +++ b/pkg/detectors/gemini/gemini.go @@ -45,7 +45,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Gemini secrets in a given set of bytes. func (s Scanner) FromData(_ context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) idMatches := keyPat.FindAllStringSubmatch(dataStr, -1) secretMatches := secretPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/generic/generic.go b/pkg/detectors/generic/generic.go index 22c77cdf6f63..8543e0ba6ffc 100644 --- a/pkg/detectors/generic/generic.go +++ b/pkg/detectors/generic/generic.go @@ -9,6 +9,7 @@ import ( "regexp" "strings" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" ) @@ -24,11 +25,11 @@ func New() Scanner { `\b([/]{0,1}([\w]+[/])+[\w\.]*)\b`, // filepath `([0-9A-F]{2}[:-]){5}([0-9A-F]{2})`, // MAC addr `\d{4}[-/]{1}([0]\d|1[0-2])[-/]{1}([0-2]\d|3[01])`, // date - `[v|\-]\d\.\d`, //version - `\d\.\d\.\d-`, //version + `[v|\-]\d\.\d`, // version + `\d\.\d\.\d-`, // version `[\d]{1,3}\.[\d]{1,3}\.[\d]{1,3}\.[\d]{1,3}`, // IPs and OIDs `[A-Fa-f0-9x]{2}:[A-Fa-f0-9x]{2}:[A-Fa-f0-9x]{2}`, // hex encoding - `[\w]+\([\w, ]+\)`, // function + `[\w]+\([\w, ]+\)`, // function } excludeMatchers := []*regexp.Regexp{} @@ -63,7 +64,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Generic secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/gengo/gengo.go b/pkg/detectors/gengo/gengo.go index e90e14fac5d3..ad2af8b4cb5c 100644 --- a/pkg/detectors/gengo/gengo.go +++ b/pkg/detectors/gengo/gengo.go @@ -41,7 +41,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Gengo secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) secretMatches := secretPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/gengo/gengo_test.go b/pkg/detectors/gengo/gengo_test.go index 52a4000595eb..bdf899cb8a97 100644 --- a/pkg/detectors/gengo/gengo_test.go +++ b/pkg/detectors/gengo/gengo_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/geoapify/geoapify.go b/pkg/detectors/geoapify/geoapify.go index d20c890b85ec..f2a5cada8a95 100644 --- a/pkg/detectors/geoapify/geoapify.go +++ b/pkg/detectors/geoapify/geoapify.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Geoapify secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/geoapify/geoapify_test.go b/pkg/detectors/geoapify/geoapify_test.go index aa232cba3ff2..728434fbb442 100644 --- a/pkg/detectors/geoapify/geoapify_test.go +++ b/pkg/detectors/geoapify/geoapify_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/geocode/geocode.go b/pkg/detectors/geocode/geocode.go index 9b6bce1a4daa..446c356001cd 100644 --- a/pkg/detectors/geocode/geocode.go +++ b/pkg/detectors/geocode/geocode.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Geocode secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/geocode/geocode_test.go b/pkg/detectors/geocode/geocode_test.go index 9c6f3ba974c5..f0bea8e220b1 100644 --- a/pkg/detectors/geocode/geocode_test.go +++ b/pkg/detectors/geocode/geocode_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/geocodify/geocodify.go b/pkg/detectors/geocodify/geocodify.go index e93dc296284e..ed48244a20bb 100644 --- a/pkg/detectors/geocodify/geocodify.go +++ b/pkg/detectors/geocodify/geocodify.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Geocodify secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/geocodio/geocodio.go b/pkg/detectors/geocodio/geocodio.go index 21cbdb2f189f..32a6a9921771 100644 --- a/pkg/detectors/geocodio/geocodio.go +++ b/pkg/detectors/geocodio/geocodio.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Geocodio secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) searchMatches := searchPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/geocodio/geocodio_test.go b/pkg/detectors/geocodio/geocodio_test.go index b243a8afec9b..2c8a48fdacd0 100644 --- a/pkg/detectors/geocodio/geocodio_test.go +++ b/pkg/detectors/geocodio/geocodio_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/geoipifi/geoipifi.go b/pkg/detectors/geoipifi/geoipifi.go index 3a0d31464ebd..c338b86844c2 100644 --- a/pkg/detectors/geoipifi/geoipifi.go +++ b/pkg/detectors/geoipifi/geoipifi.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify GeoIpifi secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/geoipifi/geoipifi_test.go b/pkg/detectors/geoipifi/geoipifi_test.go index e9cd2b68aa6a..6003db2ea858 100644 --- a/pkg/detectors/geoipifi/geoipifi_test.go +++ b/pkg/detectors/geoipifi/geoipifi_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/getemail/getemail.go b/pkg/detectors/getemail/getemail.go index 4bf56ee19c40..c7b3ca862441 100644 --- a/pkg/detectors/getemail/getemail.go +++ b/pkg/detectors/getemail/getemail.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify GetEmail secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/getemails/getemails.go b/pkg/detectors/getemails/getemails.go index 4d33a59ccb6e..a422b1c805a7 100644 --- a/pkg/detectors/getemails/getemails.go +++ b/pkg/detectors/getemails/getemails.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify GetEmails secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/getemails/getemails_test.go b/pkg/detectors/getemails/getemails_test.go index 2a669b6faae0..6c1449737f64 100644 --- a/pkg/detectors/getemails/getemails_test.go +++ b/pkg/detectors/getemails/getemails_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/getgeoapi/getgeoapi.go b/pkg/detectors/getgeoapi/getgeoapi.go index c3784f36b63c..7ceefc3da48e 100644 --- a/pkg/detectors/getgeoapi/getgeoapi.go +++ b/pkg/detectors/getgeoapi/getgeoapi.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Getgeoapi secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/getgeoapi/getgeoapi_test.go b/pkg/detectors/getgeoapi/getgeoapi_test.go index ed5ee41ae5fd..f6a818e71ed5 100644 --- a/pkg/detectors/getgeoapi/getgeoapi_test.go +++ b/pkg/detectors/getgeoapi/getgeoapi_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/getgist/getgist.go b/pkg/detectors/getgist/getgist.go index 3a0158bb3fab..55f8e3019817 100644 --- a/pkg/detectors/getgist/getgist.go +++ b/pkg/detectors/getgist/getgist.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Getgist secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/getgist/getgist_test.go b/pkg/detectors/getgist/getgist_test.go index d156f1f2f2fa..a9ecf436079c 100644 --- a/pkg/detectors/getgist/getgist_test.go +++ b/pkg/detectors/getgist/getgist_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/getresponse/getresponse.go b/pkg/detectors/getresponse/getresponse.go index 9e77cf0b7591..459625ef0a6d 100644 --- a/pkg/detectors/getresponse/getresponse.go +++ b/pkg/detectors/getresponse/getresponse.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Getresponse secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/getresponse/getresponse_test.go b/pkg/detectors/getresponse/getresponse_test.go index e14c9396883d..2b628b053470 100644 --- a/pkg/detectors/getresponse/getresponse_test.go +++ b/pkg/detectors/getresponse/getresponse_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/getsandbox/getsandbox.go b/pkg/detectors/getsandbox/getsandbox.go index a45cc70c2eed..46db9e94412a 100644 --- a/pkg/detectors/getsandbox/getsandbox.go +++ b/pkg/detectors/getsandbox/getsandbox.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify GetSandbox secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/github/github.go b/pkg/detectors/github/github.go index c0d07e72d3c2..880652e8b06d 100644 --- a/pkg/detectors/github/github.go +++ b/pkg/detectors/github/github.go @@ -53,7 +53,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify GitHub secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/github/github_test.go b/pkg/detectors/github/github_test.go index 488c5e1360af..eec4fe917632 100644 --- a/pkg/detectors/github/github_test.go +++ b/pkg/detectors/github/github_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" diff --git a/pkg/detectors/github_oauth2/github_oauth2.go b/pkg/detectors/github_oauth2/github_oauth2.go index a3678a3970e3..7f2142154f29 100644 --- a/pkg/detectors/github_oauth2/github_oauth2.go +++ b/pkg/detectors/github_oauth2/github_oauth2.go @@ -5,10 +5,12 @@ import ( "regexp" "strings" - "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" - "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" "golang.org/x/oauth2/clientcredentials" "golang.org/x/oauth2/github" + + "github.com/trufflesecurity/trufflehog/v3/pkg/common" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" + "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" ) type Scanner struct{ detectors.EndpointSetter } @@ -34,7 +36,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify GitHub secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) // Oauth2 client ID and secret oauth2ClientIDMatches := oauth2ClientIDPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/github_old/github_old.go b/pkg/detectors/github_old/github_old.go index b5edc1596d31..20a47cf81d70 100644 --- a/pkg/detectors/github_old/github_old.go +++ b/pkg/detectors/github_old/github_old.go @@ -49,7 +49,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify GitHub secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/github_old/github_old_test.go b/pkg/detectors/github_old/github_old_test.go index f61847956943..9d0d4d93d6a6 100644 --- a/pkg/detectors/github_old/github_old_test.go +++ b/pkg/detectors/github_old/github_old_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" diff --git a/pkg/detectors/githubapp/githubapp.go b/pkg/detectors/githubapp/githubapp.go index ec1c07588ff5..eec4f8ccfe70 100644 --- a/pkg/detectors/githubapp/githubapp.go +++ b/pkg/detectors/githubapp/githubapp.go @@ -2,7 +2,6 @@ package githubapp import ( "context" - // b64 "encoding/base64" "fmt" "net/http" @@ -11,6 +10,7 @@ import ( "time" "github.com/golang-jwt/jwt" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" @@ -38,7 +38,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify GitHubApp secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) appMatches := appPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/githubapp/githubapp_test.go b/pkg/detectors/githubapp/githubapp_test.go index 714fe84f9c96..78d7a2c32500 100644 --- a/pkg/detectors/githubapp/githubapp_test.go +++ b/pkg/detectors/githubapp/githubapp_test.go @@ -11,6 +11,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/gitlab/gitlab.go b/pkg/detectors/gitlab/gitlab.go index 1188f3df4e11..32d8787d919f 100644 --- a/pkg/detectors/gitlab/gitlab.go +++ b/pkg/detectors/gitlab/gitlab.go @@ -38,7 +38,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Gitlab secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) for _, match := range matches { diff --git a/pkg/detectors/gitlab/gitlab_v2_test.go b/pkg/detectors/gitlab/gitlab_v2_test.go index 1c5f3a03014f..730d574114a3 100644 --- a/pkg/detectors/gitlab/gitlab_v2_test.go +++ b/pkg/detectors/gitlab/gitlab_v2_test.go @@ -11,6 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" ) diff --git a/pkg/detectors/gitlabv2/gitlab_v2.go b/pkg/detectors/gitlabv2/gitlab_v2.go index 3084efa62d2e..86e82e0a4013 100644 --- a/pkg/detectors/gitlabv2/gitlab_v2.go +++ b/pkg/detectors/gitlabv2/gitlab_v2.go @@ -38,7 +38,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Gitlab secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) for _, match := range matches { diff --git a/pkg/detectors/gitlabv2/gitlab_v2_test.go b/pkg/detectors/gitlabv2/gitlab_v2_test.go index d074c6fb0dd4..b4cb15216451 100644 --- a/pkg/detectors/gitlabv2/gitlab_v2_test.go +++ b/pkg/detectors/gitlabv2/gitlab_v2_test.go @@ -11,6 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" diff --git a/pkg/detectors/gitter/gitter.go b/pkg/detectors/gitter/gitter.go index f190118e039e..9b5f437ee49a 100644 --- a/pkg/detectors/gitter/gitter.go +++ b/pkg/detectors/gitter/gitter.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Gitter secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/gitter/gitter_test.go b/pkg/detectors/gitter/gitter_test.go index aaa480aaf5c8..fdc1a3114350 100644 --- a/pkg/detectors/gitter/gitter_test.go +++ b/pkg/detectors/gitter/gitter_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/glassnode/glassnode.go b/pkg/detectors/glassnode/glassnode.go index b09e84870e29..1e7ca27e6893 100644 --- a/pkg/detectors/glassnode/glassnode.go +++ b/pkg/detectors/glassnode/glassnode.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Glassnode secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/glassnode/glassnode_test.go b/pkg/detectors/glassnode/glassnode_test.go index baa04ee22ffd..2fc8a8aa6c06 100644 --- a/pkg/detectors/glassnode/glassnode_test.go +++ b/pkg/detectors/glassnode/glassnode_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/gocanvas/gocanvas.go b/pkg/detectors/gocanvas/gocanvas.go index 00854e62a25e..dab9cd5a998f 100644 --- a/pkg/detectors/gocanvas/gocanvas.go +++ b/pkg/detectors/gocanvas/gocanvas.go @@ -36,7 +36,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify GoCanvas secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) emailMatches := emailPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/gocardless/gocardless.go b/pkg/detectors/gocardless/gocardless.go index 693911adb293..a8f4bdd4be7f 100644 --- a/pkg/detectors/gocardless/gocardless.go +++ b/pkg/detectors/gocardless/gocardless.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify GoCardless secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/gocardless/gocardless_test.go b/pkg/detectors/gocardless/gocardless_test.go index e20a5276e23d..5fc35ea3154d 100644 --- a/pkg/detectors/gocardless/gocardless_test.go +++ b/pkg/detectors/gocardless/gocardless_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/goodday/goodday.go b/pkg/detectors/goodday/goodday.go index 7523e3a0acaa..2bb13e35b7dc 100644 --- a/pkg/detectors/goodday/goodday.go +++ b/pkg/detectors/goodday/goodday.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify GoodDay secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/grafana/grafana.go b/pkg/detectors/grafana/grafana.go index 696ede60b1da..c4d5d5ef18e5 100644 --- a/pkg/detectors/grafana/grafana.go +++ b/pkg/detectors/grafana/grafana.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Grafana secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/grafana/grafana_test.go b/pkg/detectors/grafana/grafana_test.go index 3079553ceef0..41abd9966639 100644 --- a/pkg/detectors/grafana/grafana_test.go +++ b/pkg/detectors/grafana/grafana_test.go @@ -6,11 +6,12 @@ package grafana import ( "context" "fmt" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "testing" "time" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/grafanaserviceaccount/grafanaserviceaccount.go b/pkg/detectors/grafanaserviceaccount/grafanaserviceaccount.go index 0d002fb409ea..bc8353c9a5f9 100644 --- a/pkg/detectors/grafanaserviceaccount/grafanaserviceaccount.go +++ b/pkg/detectors/grafanaserviceaccount/grafanaserviceaccount.go @@ -22,7 +22,7 @@ var _ detectors.Detector = (*Scanner)(nil) var ( defaultClient = common.SaneHttpClient() // Make sure that your group is surrounded in boundary characters such as below to reduce false positives. - keyPat = regexp.MustCompile(`\b(glsa_[0-9a-zA-Z_]{41})\b`) + keyPat = regexp.MustCompile(`\b(glsa_[0-9a-zA-Z_]{41})\b`) domainPat = regexp.MustCompile(`\b([a-zA-Z0-9-]+\.grafana\.net)\b`) ) @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Grafanaserviceaccount secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) keyMatches := keyPat.FindAllStringSubmatch(dataStr, -1) domainMatches := domainPat.FindAllStringSubmatch(dataStr, -1) @@ -45,16 +45,16 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } key := strings.TrimSpace(match[1]) - for _, domainMatch := range domainMatches { - if len(domainMatch) != 2 { - continue - } + for _, domainMatch := range domainMatches { + if len(domainMatch) != 2 { + continue + } domainRes := strings.TrimSpace(domainMatch[1]) s1 := detectors.Result{ DetectorType: detectorspb.DetectorType_GrafanaServiceAccount, Raw: []byte(key), - RawV2: []byte(fmt.Sprintf("%s:%s", domainRes, key)), + RawV2: []byte(fmt.Sprintf("%s:%s", domainRes, key)), } if verify { diff --git a/pkg/detectors/grafanaserviceaccount/grafanaserviceaccount_test.go b/pkg/detectors/grafanaserviceaccount/grafanaserviceaccount_test.go index 48818f58056d..bfdea5c987b5 100644 --- a/pkg/detectors/grafanaserviceaccount/grafanaserviceaccount_test.go +++ b/pkg/detectors/grafanaserviceaccount/grafanaserviceaccount_test.go @@ -6,11 +6,12 @@ package grafanaserviceaccount import ( "context" "fmt" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "testing" "time" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/graphcms/graphcms.go b/pkg/detectors/graphcms/graphcms.go index 1059b7d3b2c8..53ff9d9fe7d1 100644 --- a/pkg/detectors/graphcms/graphcms.go +++ b/pkg/detectors/graphcms/graphcms.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify GraphCMS secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/graphcms/graphcms_test.go b/pkg/detectors/graphcms/graphcms_test.go index caf8424d5a27..8ef4a7222d33 100644 --- a/pkg/detectors/graphcms/graphcms_test.go +++ b/pkg/detectors/graphcms/graphcms_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/graphhopper/graphhopper.go b/pkg/detectors/graphhopper/graphhopper.go index b3e249613a31..be548dda7b64 100644 --- a/pkg/detectors/graphhopper/graphhopper.go +++ b/pkg/detectors/graphhopper/graphhopper.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Graphhopper secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) for _, match := range matches { if len(match) != 2 { diff --git a/pkg/detectors/graphhopper/graphhopper_test.go b/pkg/detectors/graphhopper/graphhopper_test.go index 7531b2f37ab0..f3aa76a89972 100644 --- a/pkg/detectors/graphhopper/graphhopper_test.go +++ b/pkg/detectors/graphhopper/graphhopper_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/groovehq/groovehq.go b/pkg/detectors/groovehq/groovehq.go index ca5c7b7b8177..7701850b5aa5 100644 --- a/pkg/detectors/groovehq/groovehq.go +++ b/pkg/detectors/groovehq/groovehq.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Groovehq secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/groovehq/groovehq_test.go b/pkg/detectors/groovehq/groovehq_test.go index 00f399b0c26f..8275cfb756ec 100644 --- a/pkg/detectors/groovehq/groovehq_test.go +++ b/pkg/detectors/groovehq/groovehq_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/gtmetrix/gtmetrix.go b/pkg/detectors/gtmetrix/gtmetrix.go index 7decbba1263b..b8fe53843178 100644 --- a/pkg/detectors/gtmetrix/gtmetrix.go +++ b/pkg/detectors/gtmetrix/gtmetrix.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify GTMetrix secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/gtmetrix/gtmetrix_test.go b/pkg/detectors/gtmetrix/gtmetrix_test.go index 534a618a2aa4..20f7d336a6b6 100644 --- a/pkg/detectors/gtmetrix/gtmetrix_test.go +++ b/pkg/detectors/gtmetrix/gtmetrix_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/guardianapi/guardianapi.go b/pkg/detectors/guardianapi/guardianapi.go index 0630f582dfc3..f23ab947fc42 100644 --- a/pkg/detectors/guardianapi/guardianapi.go +++ b/pkg/detectors/guardianapi/guardianapi.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Guardianapi secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/guardianapi/guardianapi_test.go b/pkg/detectors/guardianapi/guardianapi_test.go index 486080863618..84f1730d44fc 100644 --- a/pkg/detectors/guardianapi/guardianapi_test.go +++ b/pkg/detectors/guardianapi/guardianapi_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/gumroad/gumroad.go b/pkg/detectors/gumroad/gumroad.go index 5725574c514c..f7e510bff2a4 100644 --- a/pkg/detectors/gumroad/gumroad.go +++ b/pkg/detectors/gumroad/gumroad.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Gumroad secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/gumroad/gumroad_test.go b/pkg/detectors/gumroad/gumroad_test.go index 6b9ef5350a0c..508084d9ca33 100644 --- a/pkg/detectors/gumroad/gumroad_test.go +++ b/pkg/detectors/gumroad/gumroad_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/guru/guru.go b/pkg/detectors/guru/guru.go index 563a1fc9df01..d23c18f85613 100644 --- a/pkg/detectors/guru/guru.go +++ b/pkg/detectors/guru/guru.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Guru secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) unameMatches := unamePat.FindAllStringSubmatch(dataStr, -1) keyMatches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/gyazo/gyazo.go b/pkg/detectors/gyazo/gyazo.go index b52555071fd4..c13254de786f 100644 --- a/pkg/detectors/gyazo/gyazo.go +++ b/pkg/detectors/gyazo/gyazo.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Gyazo secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/gyazo/gyazo_test.go b/pkg/detectors/gyazo/gyazo_test.go index d3761c977434..555fc362c0f6 100644 --- a/pkg/detectors/gyazo/gyazo_test.go +++ b/pkg/detectors/gyazo/gyazo_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/happyscribe/happyscribe.go b/pkg/detectors/happyscribe/happyscribe.go index 354206563d90..7a382ee8f316 100644 --- a/pkg/detectors/happyscribe/happyscribe.go +++ b/pkg/detectors/happyscribe/happyscribe.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Happyscribe secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/happyscribe/happyscribe_test.go b/pkg/detectors/happyscribe/happyscribe_test.go index 8671dce22532..4d7d029b17f5 100644 --- a/pkg/detectors/happyscribe/happyscribe_test.go +++ b/pkg/detectors/happyscribe/happyscribe_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/harvest/harvest.go b/pkg/detectors/harvest/harvest.go index 10a38f7390c7..730e6a22daa4 100644 --- a/pkg/detectors/harvest/harvest.go +++ b/pkg/detectors/harvest/harvest.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Harvest secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idmatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/harvest/harvest_test.go b/pkg/detectors/harvest/harvest_test.go index 6efae6187fd8..781b92059735 100644 --- a/pkg/detectors/harvest/harvest_test.go +++ b/pkg/detectors/harvest/harvest_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/heatmapapi/heatmapapi.go b/pkg/detectors/heatmapapi/heatmapapi.go index 284d06c13227..851e70515a71 100644 --- a/pkg/detectors/heatmapapi/heatmapapi.go +++ b/pkg/detectors/heatmapapi/heatmapapi.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Heatmapapi secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/heatmapapi/heatmapapi_test.go b/pkg/detectors/heatmapapi/heatmapapi_test.go index d377be8cd3fd..e7c269f1bbc3 100644 --- a/pkg/detectors/heatmapapi/heatmapapi_test.go +++ b/pkg/detectors/heatmapapi/heatmapapi_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/hellosign/hellosign.go b/pkg/detectors/hellosign/hellosign.go index 9b43595be541..b096a61457fa 100644 --- a/pkg/detectors/hellosign/hellosign.go +++ b/pkg/detectors/hellosign/hellosign.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify HelloSign secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/helpcrunch/helpcrunch.go b/pkg/detectors/helpcrunch/helpcrunch.go index 55a82a37a759..ee088548ef4c 100644 --- a/pkg/detectors/helpcrunch/helpcrunch.go +++ b/pkg/detectors/helpcrunch/helpcrunch.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify HelpCrunch secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/helpcrunch/helpcrunch_test.go b/pkg/detectors/helpcrunch/helpcrunch_test.go index 01dfd5de6cd6..a072125c3d8e 100644 --- a/pkg/detectors/helpcrunch/helpcrunch_test.go +++ b/pkg/detectors/helpcrunch/helpcrunch_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/helpscout/helpscout.go b/pkg/detectors/helpscout/helpscout.go index ed139de33597..16e284297925 100644 --- a/pkg/detectors/helpscout/helpscout.go +++ b/pkg/detectors/helpscout/helpscout.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Helpscout secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/helpscout/helpscout_test.go b/pkg/detectors/helpscout/helpscout_test.go index 7a3ab7b12f97..5467757098f0 100644 --- a/pkg/detectors/helpscout/helpscout_test.go +++ b/pkg/detectors/helpscout/helpscout_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/hereapi/hereapi.go b/pkg/detectors/hereapi/hereapi.go index c6362a7b4755..c7d76bc3937e 100644 --- a/pkg/detectors/hereapi/hereapi.go +++ b/pkg/detectors/hereapi/hereapi.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify HereAPI secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) for _, match := range matches { if len(match) != 2 { diff --git a/pkg/detectors/hereapi/hereapi_test.go b/pkg/detectors/hereapi/hereapi_test.go index 8955ceeacc90..234401343cf5 100644 --- a/pkg/detectors/hereapi/hereapi_test.go +++ b/pkg/detectors/hereapi/hereapi_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/heroku/heroku.go b/pkg/detectors/heroku/heroku.go index 2821fc7cb319..2ad1b04b4a7c 100644 --- a/pkg/detectors/heroku/heroku.go +++ b/pkg/detectors/heroku/heroku.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Heroku secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/heroku/heroku_test.go b/pkg/detectors/heroku/heroku_test.go index ff4d3bf12c2b..7a09a050bf03 100644 --- a/pkg/detectors/heroku/heroku_test.go +++ b/pkg/detectors/heroku/heroku_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/hive/hive.go b/pkg/detectors/hive/hive.go index eecb74c86f8a..3c2cd80ff038 100644 --- a/pkg/detectors/hive/hive.go +++ b/pkg/detectors/hive/hive.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Hive secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) keyMatches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/hive/hive_test.go b/pkg/detectors/hive/hive_test.go index 9d25915e11f9..c19689a054bb 100644 --- a/pkg/detectors/hive/hive_test.go +++ b/pkg/detectors/hive/hive_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/hiveage/hiveage.go b/pkg/detectors/hiveage/hiveage.go index 1f84e97ea22c..5a5788f2fc1e 100644 --- a/pkg/detectors/hiveage/hiveage.go +++ b/pkg/detectors/hiveage/hiveage.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Hiveage secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/hiveage/hiveage_test.go b/pkg/detectors/hiveage/hiveage_test.go index fe8c71f3a606..1d933e360608 100644 --- a/pkg/detectors/hiveage/hiveage_test.go +++ b/pkg/detectors/hiveage/hiveage_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/holidayapi/holidayapi.go b/pkg/detectors/holidayapi/holidayapi.go index f22ee728ffc0..c74720b7fb15 100644 --- a/pkg/detectors/holidayapi/holidayapi.go +++ b/pkg/detectors/holidayapi/holidayapi.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify HolidayAPI secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/holidayapi/holidayapi_test.go b/pkg/detectors/holidayapi/holidayapi_test.go index 33a92322277c..5f2c5c207124 100644 --- a/pkg/detectors/holidayapi/holidayapi_test.go +++ b/pkg/detectors/holidayapi/holidayapi_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/holistic/holistic.go b/pkg/detectors/holistic/holistic.go index 71160576acbd..899c87c4e78e 100644 --- a/pkg/detectors/holistic/holistic.go +++ b/pkg/detectors/holistic/holistic.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Holistic secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/holistic/holistic_test.go b/pkg/detectors/holistic/holistic_test.go index 1e6ab8c114a0..f38037bf457c 100644 --- a/pkg/detectors/holistic/holistic_test.go +++ b/pkg/detectors/holistic/holistic_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/honeycomb/honeycomb.go b/pkg/detectors/honeycomb/honeycomb.go index 08af012f4d64..bcaadc273a84 100644 --- a/pkg/detectors/honeycomb/honeycomb.go +++ b/pkg/detectors/honeycomb/honeycomb.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Honeycomb secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/honeycomb/honeycomb_test.go b/pkg/detectors/honeycomb/honeycomb_test.go index 50579d93470b..d04332e494fd 100644 --- a/pkg/detectors/honeycomb/honeycomb_test.go +++ b/pkg/detectors/honeycomb/honeycomb_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/host/host.go b/pkg/detectors/host/host.go index 0ed0db805c25..11c26c5e5d19 100644 --- a/pkg/detectors/host/host.go +++ b/pkg/detectors/host/host.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Host secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/host/host_test.go b/pkg/detectors/host/host_test.go index d1dc402f18b3..44ba0dab44d7 100644 --- a/pkg/detectors/host/host_test.go +++ b/pkg/detectors/host/host_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/html2pdf/html2pdf.go b/pkg/detectors/html2pdf/html2pdf.go index 5b0594af52ec..6028744db020 100644 --- a/pkg/detectors/html2pdf/html2pdf.go +++ b/pkg/detectors/html2pdf/html2pdf.go @@ -8,6 +8,7 @@ import ( "regexp" "strings" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" ) @@ -35,7 +36,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Html2Pdf secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/html2pdf/html2pdf_test.go b/pkg/detectors/html2pdf/html2pdf_test.go index a41f595b4534..bd589d6bb621 100644 --- a/pkg/detectors/html2pdf/html2pdf_test.go +++ b/pkg/detectors/html2pdf/html2pdf_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/hubspotapikey/hubspotapikey.go b/pkg/detectors/hubspotapikey/hubspotapikey.go index 4adb62c76b16..b2e554b2830b 100644 --- a/pkg/detectors/hubspotapikey/hubspotapikey.go +++ b/pkg/detectors/hubspotapikey/hubspotapikey.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify HubSpotApiKey secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) for _, match := range matches { diff --git a/pkg/detectors/hubspotapikey/hubspotapikey_test.go b/pkg/detectors/hubspotapikey/hubspotapikey_test.go index 8c8a819c498d..d6d0b758373a 100644 --- a/pkg/detectors/hubspotapikey/hubspotapikey_test.go +++ b/pkg/detectors/hubspotapikey/hubspotapikey_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/huggingface/huggingface.go b/pkg/detectors/huggingface/huggingface.go index 694da79f97de..35e8ddd24a0e 100644 --- a/pkg/detectors/huggingface/huggingface.go +++ b/pkg/detectors/huggingface/huggingface.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Huggingface secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/huggingface/huggingface_test.go b/pkg/detectors/huggingface/huggingface_test.go index fbdb94244926..3cb8f76e902d 100644 --- a/pkg/detectors/huggingface/huggingface_test.go +++ b/pkg/detectors/huggingface/huggingface_test.go @@ -6,11 +6,12 @@ package huggingface import ( "context" "fmt" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "testing" "time" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/humanity/humanity.go b/pkg/detectors/humanity/humanity.go index 879948606aa3..ef964a517f64 100644 --- a/pkg/detectors/humanity/humanity.go +++ b/pkg/detectors/humanity/humanity.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Humanity secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/humanity/humanity_test.go b/pkg/detectors/humanity/humanity_test.go index 71f3268739a3..1f78555a71ed 100644 --- a/pkg/detectors/humanity/humanity_test.go +++ b/pkg/detectors/humanity/humanity_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/hunter/hunter.go b/pkg/detectors/hunter/hunter.go index c53fda8abdb8..9bfd38b83c42 100644 --- a/pkg/detectors/hunter/hunter.go +++ b/pkg/detectors/hunter/hunter.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Hunter secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/hybiscus/hybiscus.go b/pkg/detectors/hybiscus/hybiscus.go index 61c173bf3c04..a30f187a1cb4 100644 --- a/pkg/detectors/hybiscus/hybiscus.go +++ b/pkg/detectors/hybiscus/hybiscus.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Hybiscus secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/hybiscus/hybiscus_test.go b/pkg/detectors/hybiscus/hybiscus_test.go index 064e73e9a3db..6f1dcd442171 100644 --- a/pkg/detectors/hybiscus/hybiscus_test.go +++ b/pkg/detectors/hybiscus/hybiscus_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/hypertrack/hypertrack.go b/pkg/detectors/hypertrack/hypertrack.go index 318bed544ee1..aafc78023faf 100644 --- a/pkg/detectors/hypertrack/hypertrack.go +++ b/pkg/detectors/hypertrack/hypertrack.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Hypertrack secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) accMatches := accPat.FindAllStringSubmatch(dataStr, -1) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/hypertrack/hypertrack_test.go b/pkg/detectors/hypertrack/hypertrack_test.go index 4485281a0d79..caff08b3983b 100644 --- a/pkg/detectors/hypertrack/hypertrack_test.go +++ b/pkg/detectors/hypertrack/hypertrack_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/ibmclouduserkey/ibmclouduserkey.go b/pkg/detectors/ibmclouduserkey/ibmclouduserkey.go index d94f8942dbca..8f336d033ebe 100644 --- a/pkg/detectors/ibmclouduserkey/ibmclouduserkey.go +++ b/pkg/detectors/ibmclouduserkey/ibmclouduserkey.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify IbmCloudUserKey secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/ibmclouduserkey/ibmclouduserkey_test.go b/pkg/detectors/ibmclouduserkey/ibmclouduserkey_test.go index d872fa905217..5a64a307c469 100644 --- a/pkg/detectors/ibmclouduserkey/ibmclouduserkey_test.go +++ b/pkg/detectors/ibmclouduserkey/ibmclouduserkey_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/iconfinder/iconfinder.go b/pkg/detectors/iconfinder/iconfinder.go index 60f27d796ec2..c90db1ab935a 100644 --- a/pkg/detectors/iconfinder/iconfinder.go +++ b/pkg/detectors/iconfinder/iconfinder.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify IconFinder secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/iconfinder/iconfinder_test.go b/pkg/detectors/iconfinder/iconfinder_test.go index 2f1fcdf149de..56f0c70b1eb1 100644 --- a/pkg/detectors/iconfinder/iconfinder_test.go +++ b/pkg/detectors/iconfinder/iconfinder_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/iexapis/iexapis.go b/pkg/detectors/iexapis/iexapis.go index dcc25865bae7..4e632e4a35a0 100644 --- a/pkg/detectors/iexapis/iexapis.go +++ b/pkg/detectors/iexapis/iexapis.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Iexapis secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/iexapis/iexapis_test.go b/pkg/detectors/iexapis/iexapis_test.go index 10471c9b69b6..1f322f756b45 100644 --- a/pkg/detectors/iexapis/iexapis_test.go +++ b/pkg/detectors/iexapis/iexapis_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/iexcloud/iexcloud.go b/pkg/detectors/iexcloud/iexcloud.go index 53ceff3d846c..8b4cb5196508 100644 --- a/pkg/detectors/iexcloud/iexcloud.go +++ b/pkg/detectors/iexcloud/iexcloud.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Iexcloud secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/iexcloud/iexcloud_test.go b/pkg/detectors/iexcloud/iexcloud_test.go index 29285bc6a56e..8db603ff8365 100644 --- a/pkg/detectors/iexcloud/iexcloud_test.go +++ b/pkg/detectors/iexcloud/iexcloud_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/imagekit/imagekit.go b/pkg/detectors/imagekit/imagekit.go index b0f224d283d8..e8d0bf537472 100644 --- a/pkg/detectors/imagekit/imagekit.go +++ b/pkg/detectors/imagekit/imagekit.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Imagekit secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/imagekit/imagekit_test.go b/pkg/detectors/imagekit/imagekit_test.go index 50a5bb40e811..4958a7924eb9 100644 --- a/pkg/detectors/imagekit/imagekit_test.go +++ b/pkg/detectors/imagekit/imagekit_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/imagga/imagga.go b/pkg/detectors/imagga/imagga.go index 7ba883e2ff85..739b5f514e9a 100644 --- a/pkg/detectors/imagga/imagga.go +++ b/pkg/detectors/imagga/imagga.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Imagga secrets in a given set of bytes.ddd func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/imagga/imagga_test.go b/pkg/detectors/imagga/imagga_test.go index b46d71050bb7..d14f36a08b70 100644 --- a/pkg/detectors/imagga/imagga_test.go +++ b/pkg/detectors/imagga/imagga_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/impala/impala.go b/pkg/detectors/impala/impala.go index e7dceeace9c3..3554ec0475f1 100644 --- a/pkg/detectors/impala/impala.go +++ b/pkg/detectors/impala/impala.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Impala secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/impala/impala_test.go b/pkg/detectors/impala/impala_test.go index 1590112a9703..4b3bff630ef2 100644 --- a/pkg/detectors/impala/impala_test.go +++ b/pkg/detectors/impala/impala_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/infura/infura.go b/pkg/detectors/infura/infura.go index 4ee17c7d9a09..1b039979d002 100644 --- a/pkg/detectors/infura/infura.go +++ b/pkg/detectors/infura/infura.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Infura secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/infura/infura_test.go b/pkg/detectors/infura/infura_test.go index 1e3864413cb0..a0bceb502aaa 100644 --- a/pkg/detectors/infura/infura_test.go +++ b/pkg/detectors/infura/infura_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/insightly/insightly.go b/pkg/detectors/insightly/insightly.go index faaad14af025..1bf34660b51d 100644 --- a/pkg/detectors/insightly/insightly.go +++ b/pkg/detectors/insightly/insightly.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Insightly secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/insightly/insightly_test.go b/pkg/detectors/insightly/insightly_test.go index bcaa17ae6763..e07404a34ea8 100644 --- a/pkg/detectors/insightly/insightly_test.go +++ b/pkg/detectors/insightly/insightly_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/instabot/instabot.go b/pkg/detectors/instabot/instabot.go index 0aa468e63ede..2f2c29b52014 100644 --- a/pkg/detectors/instabot/instabot.go +++ b/pkg/detectors/instabot/instabot.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Instabot secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) for _, match := range matches { diff --git a/pkg/detectors/instabot/instabot_test.go b/pkg/detectors/instabot/instabot_test.go index 82f593e154f1..b5fc09e58529 100644 --- a/pkg/detectors/instabot/instabot_test.go +++ b/pkg/detectors/instabot/instabot_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/instamojo/instamojo.go b/pkg/detectors/instamojo/instamojo.go index 4ada2694ad06..43af6b660eff 100644 --- a/pkg/detectors/instamojo/instamojo.go +++ b/pkg/detectors/instamojo/instamojo.go @@ -23,9 +23,9 @@ var _ detectors.Detector = (*Scanner)(nil) var ( defaultClient = common.SaneHttpClient() // Make sure that your group is surrounded in boundary characters such as below to reduce false positives. - //KeyPat is client_id - keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"instamojo"}) + `\b([0-9a-zA-Z]{40})\b`) - //Secretpat is Client_secret + // KeyPat is client_id + keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"instamojo"}) + `\b([0-9a-zA-Z]{40})\b`) + // Secretpat is Client_secret secretPat = regexp.MustCompile(detectors.PrefixRegex([]string{"instamojo"}) + `\b([0-9a-zA-Z]{128})\b`) ) @@ -37,7 +37,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Instamojo secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) secretMatches := secretPat.FindAllStringSubmatch(dataStr, -1) clientIdmatches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/instamojo/instamojo_test.go b/pkg/detectors/instamojo/instamojo_test.go index d6e6fdb36a6a..9a208358e31f 100644 --- a/pkg/detectors/instamojo/instamojo_test.go +++ b/pkg/detectors/instamojo/instamojo_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" @@ -67,7 +68,7 @@ func TestInstamojo_FromChunk(t *testing.T) { }, want: []detectors.Result{ { - DetectorType: detectorspb.DetectorType_Instamojo, + DetectorType: detectorspb.DetectorType_Instamojo, VerificationError: fmt.Errorf("unexpected HTTP response status 401"), }, }, @@ -82,7 +83,7 @@ func TestInstamojo_FromChunk(t *testing.T) { data: []byte("You cannot find the secret within"), verify: true, }, - want: nil, + want: nil, wantErr: false, wantVerificationErr: true, }, diff --git a/pkg/detectors/integromat/integromat.go b/pkg/detectors/integromat/integromat.go index a7476113b236..fcb6a937a78b 100644 --- a/pkg/detectors/integromat/integromat.go +++ b/pkg/detectors/integromat/integromat.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Integromat secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/integromat/integromat_test.go b/pkg/detectors/integromat/integromat_test.go index 0f48d4d7b4e9..79bad60a7dbf 100644 --- a/pkg/detectors/integromat/integromat_test.go +++ b/pkg/detectors/integromat/integromat_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/intercom/intercom.go b/pkg/detectors/intercom/intercom.go index ae4185f70b0b..dcabc42ee0b0 100644 --- a/pkg/detectors/intercom/intercom.go +++ b/pkg/detectors/intercom/intercom.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify InterCom secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/intercom/intercom_test.go b/pkg/detectors/intercom/intercom_test.go index 1c738cbf5f50..515a3c19f70c 100644 --- a/pkg/detectors/intercom/intercom_test.go +++ b/pkg/detectors/intercom/intercom_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/interseller/interseller.go b/pkg/detectors/interseller/interseller.go index cf2e5c77bb50..5d3bf75904bd 100644 --- a/pkg/detectors/interseller/interseller.go +++ b/pkg/detectors/interseller/interseller.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Interseller secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/interseller/interseller_test.go b/pkg/detectors/interseller/interseller_test.go index 58d662e57607..b191b6eccba4 100644 --- a/pkg/detectors/interseller/interseller_test.go +++ b/pkg/detectors/interseller/interseller_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/intrinio/intrinio.go b/pkg/detectors/intrinio/intrinio.go index 7792e5f1a022..74c2a00dd08a 100644 --- a/pkg/detectors/intrinio/intrinio.go +++ b/pkg/detectors/intrinio/intrinio.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Intrinio secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/intrinio/intrinio_test.go b/pkg/detectors/intrinio/intrinio_test.go index 3b68683ca012..4ed6b9ac9a3c 100644 --- a/pkg/detectors/intrinio/intrinio_test.go +++ b/pkg/detectors/intrinio/intrinio_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/invoiceocean/invoiceocean.go b/pkg/detectors/invoiceocean/invoiceocean.go index c2a10462fd17..aedc40ef7cd2 100644 --- a/pkg/detectors/invoiceocean/invoiceocean.go +++ b/pkg/detectors/invoiceocean/invoiceocean.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Invoiceocean secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) urlMatches := urlPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/invoiceocean/invoiceocean_test.go b/pkg/detectors/invoiceocean/invoiceocean_test.go index 0631669aac5b..c70edc219173 100644 --- a/pkg/detectors/invoiceocean/invoiceocean_test.go +++ b/pkg/detectors/invoiceocean/invoiceocean_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/ip2location/ip2location.go b/pkg/detectors/ip2location/ip2location.go index 9503b51e098d..328e402dfd9f 100644 --- a/pkg/detectors/ip2location/ip2location.go +++ b/pkg/detectors/ip2location/ip2location.go @@ -12,7 +12,7 @@ import ( "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" ) -type Scanner struct {} +type Scanner struct{} // Ensure the Scanner satisfies the interface at compile time. var _ detectors.Detector = (*Scanner)(nil) @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Ip2location secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) @@ -47,8 +47,8 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } if verify { - req, err := http.NewRequestWithContext(ctx, "GET", "https://api.ip2location.io/?key=" + resMatch, nil) - + req, err := http.NewRequestWithContext(ctx, "GET", "https://api.ip2location.io/?key="+resMatch, nil) + if err != nil { continue } @@ -79,6 +79,3 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result func (s Scanner) Type() detectorspb.DetectorType { return detectorspb.DetectorType_Ip2location } - - - diff --git a/pkg/detectors/ipapi/ipapi.go b/pkg/detectors/ipapi/ipapi.go index 3205b27061d6..9e129c35d8e7 100644 --- a/pkg/detectors/ipapi/ipapi.go +++ b/pkg/detectors/ipapi/ipapi.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Ipapi secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/ipapi/ipapi_test.go b/pkg/detectors/ipapi/ipapi_test.go index 4750a530b76c..177a680dae40 100644 --- a/pkg/detectors/ipapi/ipapi_test.go +++ b/pkg/detectors/ipapi/ipapi_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/ipgeolocation/ipgeolocation.go b/pkg/detectors/ipgeolocation/ipgeolocation.go index 29cadae88eaf..8db95240ac23 100644 --- a/pkg/detectors/ipgeolocation/ipgeolocation.go +++ b/pkg/detectors/ipgeolocation/ipgeolocation.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify IPGeolocation secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/ipgeolocation/ipgeolocation_test.go b/pkg/detectors/ipgeolocation/ipgeolocation_test.go index 374d290f196f..55478bf37b73 100644 --- a/pkg/detectors/ipgeolocation/ipgeolocation_test.go +++ b/pkg/detectors/ipgeolocation/ipgeolocation_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/ipify/ipify.go b/pkg/detectors/ipify/ipify.go index 3f288075295b..92610aef18c4 100644 --- a/pkg/detectors/ipify/ipify.go +++ b/pkg/detectors/ipify/ipify.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Ipify secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/ipify/ipify_test.go b/pkg/detectors/ipify/ipify_test.go index 82344afa01b9..dba7d0028edd 100644 --- a/pkg/detectors/ipify/ipify_test.go +++ b/pkg/detectors/ipify/ipify_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/ipinfo/ipinfo.go b/pkg/detectors/ipinfo/ipinfo.go index 4b7024b33254..ae050b27bfd5 100644 --- a/pkg/detectors/ipinfo/ipinfo.go +++ b/pkg/detectors/ipinfo/ipinfo.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Ipinfo secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/ipinfo/ipinfo_test.go b/pkg/detectors/ipinfo/ipinfo_test.go index d1c523fbec58..8f53f0a7526e 100644 --- a/pkg/detectors/ipinfo/ipinfo_test.go +++ b/pkg/detectors/ipinfo/ipinfo_test.go @@ -6,11 +6,12 @@ package ipinfo import ( "context" "fmt" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "testing" "time" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/ipinfodb/ipinfodb.go b/pkg/detectors/ipinfodb/ipinfodb.go index 1ec4bd72d6d7..c76cf97edfef 100644 --- a/pkg/detectors/ipinfodb/ipinfodb.go +++ b/pkg/detectors/ipinfodb/ipinfodb.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify IPinfoDB secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/ipinfodb/ipinfodb_test.go b/pkg/detectors/ipinfodb/ipinfodb_test.go index 14c2ec5bf10a..acb98777c0b0 100644 --- a/pkg/detectors/ipinfodb/ipinfodb_test.go +++ b/pkg/detectors/ipinfodb/ipinfodb_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/ipquality/ipquality.go b/pkg/detectors/ipquality/ipquality.go index 6288e6f5b202..433dee15b7a4 100644 --- a/pkg/detectors/ipquality/ipquality.go +++ b/pkg/detectors/ipquality/ipquality.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Ipquality secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/ipquality/ipquality_test.go b/pkg/detectors/ipquality/ipquality_test.go index 237e024efd8f..f4abebbec952 100644 --- a/pkg/detectors/ipquality/ipquality_test.go +++ b/pkg/detectors/ipquality/ipquality_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/ipstack/ipstack.go b/pkg/detectors/ipstack/ipstack.go index bfc9a3e5f9a2..49098117bab3 100644 --- a/pkg/detectors/ipstack/ipstack.go +++ b/pkg/detectors/ipstack/ipstack.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify IpStack secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/ipstack/ipstack_test.go b/pkg/detectors/ipstack/ipstack_test.go index 6d64f772a921..244257f48241 100644 --- a/pkg/detectors/ipstack/ipstack_test.go +++ b/pkg/detectors/ipstack/ipstack_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/jdbc/jdbc.go b/pkg/detectors/jdbc/jdbc.go index 32fb96055f25..47137d90d474 100644 --- a/pkg/detectors/jdbc/jdbc.go +++ b/pkg/detectors/jdbc/jdbc.go @@ -9,6 +9,7 @@ import ( "strings" "time" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" ) @@ -58,7 +59,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Jdbc secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) matchLoop: diff --git a/pkg/detectors/jdbc/jdbc_integration_test.go b/pkg/detectors/jdbc/jdbc_integration_test.go index 9ce26d50d70e..7f29116f9b4e 100644 --- a/pkg/detectors/jdbc/jdbc_integration_test.go +++ b/pkg/detectors/jdbc/jdbc_integration_test.go @@ -14,6 +14,7 @@ import ( "github.com/kylelemons/godebug/pretty" "github.com/stretchr/testify/assert" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" ) diff --git a/pkg/detectors/jdbc/jdbc_test.go b/pkg/detectors/jdbc/jdbc_test.go index 6739e7b25b87..7b070acacdf5 100644 --- a/pkg/detectors/jdbc/jdbc_test.go +++ b/pkg/detectors/jdbc/jdbc_test.go @@ -5,11 +5,13 @@ package jdbc import ( "context" - "github.com/stretchr/testify/assert" "os" "testing" + "github.com/stretchr/testify/assert" + "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" ) diff --git a/pkg/detectors/jdbc/mysql.go b/pkg/detectors/jdbc/mysql.go index f21662ec99d3..e9a7da37a631 100644 --- a/pkg/detectors/jdbc/mysql.go +++ b/pkg/detectors/jdbc/mysql.go @@ -3,8 +3,9 @@ package jdbc import ( "context" "errors" - "github.com/go-sql-driver/mysql" "strings" + + "github.com/go-sql-driver/mysql" ) type mysqlJDBC struct { diff --git a/pkg/detectors/jdbc/sqlserver.go b/pkg/detectors/jdbc/sqlserver.go index 3a092e5a13c3..07aae0789771 100644 --- a/pkg/detectors/jdbc/sqlserver.go +++ b/pkg/detectors/jdbc/sqlserver.go @@ -3,8 +3,9 @@ package jdbc import ( "context" "errors" - mssql "github.com/denisenkom/go-mssqldb" "strings" + + mssql "github.com/denisenkom/go-mssqldb" ) type sqlServerJDBC struct { diff --git a/pkg/detectors/jiratoken/jiratoken.go b/pkg/detectors/jiratoken/jiratoken.go index 3e495773ce48..1d69af62b454 100644 --- a/pkg/detectors/jiratoken/jiratoken.go +++ b/pkg/detectors/jiratoken/jiratoken.go @@ -45,7 +45,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify JiraToken secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) tokens := tokenPat.FindAllStringSubmatch(dataStr, -1) domains := domainPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/jiratoken/jiratoken_test.go b/pkg/detectors/jiratoken/jiratoken_test.go index d733b0b92481..149296181858 100644 --- a/pkg/detectors/jiratoken/jiratoken_test.go +++ b/pkg/detectors/jiratoken/jiratoken_test.go @@ -11,6 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/jiratoken_v2/jiratoken_v2.go b/pkg/detectors/jiratoken_v2/jiratoken_v2.go index 57233b666f2f..e71154ea9295 100644 --- a/pkg/detectors/jiratoken_v2/jiratoken_v2.go +++ b/pkg/detectors/jiratoken_v2/jiratoken_v2.go @@ -46,7 +46,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify JiraToken secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) tokens := tokenPat.FindAllStringSubmatch(dataStr, -1) domains := domainPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/jiratoken_v2/jiratoken_v2_test.go b/pkg/detectors/jiratoken_v2/jiratoken_v2_test.go index bdfd2454ce20..ed2320d27586 100644 --- a/pkg/detectors/jiratoken_v2/jiratoken_v2_test.go +++ b/pkg/detectors/jiratoken_v2/jiratoken_v2_test.go @@ -11,6 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/jotform/jotform.go b/pkg/detectors/jotform/jotform.go index 513b4ac09d22..35dc4bc9de96 100644 --- a/pkg/detectors/jotform/jotform.go +++ b/pkg/detectors/jotform/jotform.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Jotform secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/jotform/jotform_test.go b/pkg/detectors/jotform/jotform_test.go index 5f2674932c0d..363d50a6d239 100644 --- a/pkg/detectors/jotform/jotform_test.go +++ b/pkg/detectors/jotform/jotform_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/jumpcloud/jumpcloud.go b/pkg/detectors/jumpcloud/jumpcloud.go index 35b9af0d7684..247b023ab01c 100644 --- a/pkg/detectors/jumpcloud/jumpcloud.go +++ b/pkg/detectors/jumpcloud/jumpcloud.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Jumpcloud secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/jumpcloud/jumpcloud_test.go b/pkg/detectors/jumpcloud/jumpcloud_test.go index fe9dfbc0487f..138ef05e0448 100644 --- a/pkg/detectors/jumpcloud/jumpcloud_test.go +++ b/pkg/detectors/jumpcloud/jumpcloud_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/juro/juro.go b/pkg/detectors/juro/juro.go index 09357911ca72..644c0def461f 100644 --- a/pkg/detectors/juro/juro.go +++ b/pkg/detectors/juro/juro.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Juro secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/juro/juro_test.go b/pkg/detectors/juro/juro_test.go index 682aed80ed00..cace679e47cb 100644 --- a/pkg/detectors/juro/juro_test.go +++ b/pkg/detectors/juro/juro_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/kanban/kanban.go b/pkg/detectors/kanban/kanban.go index f05a3a8c5aa7..df7c2eae521d 100644 --- a/pkg/detectors/kanban/kanban.go +++ b/pkg/detectors/kanban/kanban.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Kanban secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) urlMatches := urlPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/kanban/kanban_test.go b/pkg/detectors/kanban/kanban_test.go index 7f3bc6c10704..2bbeba351612 100644 --- a/pkg/detectors/kanban/kanban_test.go +++ b/pkg/detectors/kanban/kanban_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/kanbantool/kanbantool.go b/pkg/detectors/kanbantool/kanbantool.go index 36a49c7466ee..c81490354000 100644 --- a/pkg/detectors/kanbantool/kanbantool.go +++ b/pkg/detectors/kanbantool/kanbantool.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Kanbantool secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := domainPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/karmacrm/karmacrm.go b/pkg/detectors/karmacrm/karmacrm.go index 5a3e61543878..2658c88b9216 100644 --- a/pkg/detectors/karmacrm/karmacrm.go +++ b/pkg/detectors/karmacrm/karmacrm.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify KarmaCRM secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/karmacrm/karmacrm_test.go b/pkg/detectors/karmacrm/karmacrm_test.go index f072a58c0b37..9009774f0bbf 100644 --- a/pkg/detectors/karmacrm/karmacrm_test.go +++ b/pkg/detectors/karmacrm/karmacrm_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/keenio/keenio.go b/pkg/detectors/keenio/keenio.go index 0637cb6925cf..bbc85f07a52c 100644 --- a/pkg/detectors/keenio/keenio.go +++ b/pkg/detectors/keenio/keenio.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify KeenIO secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idmatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/keenio/keenio_test.go b/pkg/detectors/keenio/keenio_test.go index 4275158c0017..5187542a016c 100644 --- a/pkg/detectors/keenio/keenio_test.go +++ b/pkg/detectors/keenio/keenio_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/kickbox/kickbox.go b/pkg/detectors/kickbox/kickbox.go index 4578bad575da..753840334ef6 100644 --- a/pkg/detectors/kickbox/kickbox.go +++ b/pkg/detectors/kickbox/kickbox.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Kickbox secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/kickbox/kickbox_test.go b/pkg/detectors/kickbox/kickbox_test.go index 9827199929f8..27747ac153e0 100644 --- a/pkg/detectors/kickbox/kickbox_test.go +++ b/pkg/detectors/kickbox/kickbox_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/klaviyo/klaviyo.go b/pkg/detectors/klaviyo/klaviyo.go index 2cbd94e77f3f..460df462ab0d 100644 --- a/pkg/detectors/klaviyo/klaviyo.go +++ b/pkg/detectors/klaviyo/klaviyo.go @@ -47,7 +47,7 @@ type response struct { // FromData will find and optionally verify Klaviyo secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/klaviyo/klaviyo_test.go b/pkg/detectors/klaviyo/klaviyo_test.go index effeabcf6823..aa2bc0d2d5d7 100644 --- a/pkg/detectors/klaviyo/klaviyo_test.go +++ b/pkg/detectors/klaviyo/klaviyo_test.go @@ -6,11 +6,12 @@ package klaviyo import ( "context" "fmt" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "testing" "time" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/klipfolio/klipfolio.go b/pkg/detectors/klipfolio/klipfolio.go index 478d1dfa6f2e..eccdd0b591f5 100644 --- a/pkg/detectors/klipfolio/klipfolio.go +++ b/pkg/detectors/klipfolio/klipfolio.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Klipfolio secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/knapsackpro/knapsackpro.go b/pkg/detectors/knapsackpro/knapsackpro.go index 721d81f9796f..f207446968d5 100644 --- a/pkg/detectors/knapsackpro/knapsackpro.go +++ b/pkg/detectors/knapsackpro/knapsackpro.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify KnapsackPro secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/knapsackpro/knapsackpro_test.go b/pkg/detectors/knapsackpro/knapsackpro_test.go index 84f746efe10b..d5eaec0a02c8 100644 --- a/pkg/detectors/knapsackpro/knapsackpro_test.go +++ b/pkg/detectors/knapsackpro/knapsackpro_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/kontent/kontent.go b/pkg/detectors/kontent/kontent.go index ec1316ed7783..08b176550e33 100644 --- a/pkg/detectors/kontent/kontent.go +++ b/pkg/detectors/kontent/kontent.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Kontent secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/kontent/kontent_test.go b/pkg/detectors/kontent/kontent_test.go index 66f2c20f10ea..199ee3859327 100644 --- a/pkg/detectors/kontent/kontent_test.go +++ b/pkg/detectors/kontent/kontent_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/kraken/kraken.go b/pkg/detectors/kraken/kraken.go index 000c9811c0be..6d6f4defac0a 100644 --- a/pkg/detectors/kraken/kraken.go +++ b/pkg/detectors/kraken/kraken.go @@ -41,7 +41,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Kraken secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) privKeyMatches := privKeyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/kraken/kraken_test.go b/pkg/detectors/kraken/kraken_test.go index 2a6de9a01625..a038c178dfdd 100644 --- a/pkg/detectors/kraken/kraken_test.go +++ b/pkg/detectors/kraken/kraken_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/kucoin/kucoin.go b/pkg/detectors/kucoin/kucoin.go index a97bc6594dd6..5c8364459ce1 100644 --- a/pkg/detectors/kucoin/kucoin.go +++ b/pkg/detectors/kucoin/kucoin.go @@ -38,7 +38,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify KuCoin secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) keyMatches := keyPat.FindAllStringSubmatch(dataStr, -1) secretMatches := secretPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/kylas/kylas.go b/pkg/detectors/kylas/kylas.go index 3a01c15a9a2d..f9bef1b53f7e 100644 --- a/pkg/detectors/kylas/kylas.go +++ b/pkg/detectors/kylas/kylas.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Kylas secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/kylas/kylas_test.go b/pkg/detectors/kylas/kylas_test.go index 613363dcf4c9..a65051f98abd 100644 --- a/pkg/detectors/kylas/kylas_test.go +++ b/pkg/detectors/kylas/kylas_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/languagelayer/languagelayer.go b/pkg/detectors/languagelayer/languagelayer.go index 7368a28b47bc..23771c6bed70 100644 --- a/pkg/detectors/languagelayer/languagelayer.go +++ b/pkg/detectors/languagelayer/languagelayer.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify LanguageLayer secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/languagelayer/languagelayer_test.go b/pkg/detectors/languagelayer/languagelayer_test.go index 56083fa13d24..4d95f369eee8 100644 --- a/pkg/detectors/languagelayer/languagelayer_test.go +++ b/pkg/detectors/languagelayer/languagelayer_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/lastfm/lastfm.go b/pkg/detectors/lastfm/lastfm.go index 7b71caef5d14..f60c98afae2b 100644 --- a/pkg/detectors/lastfm/lastfm.go +++ b/pkg/detectors/lastfm/lastfm.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Lastfm secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/lastfm/lastfm_test.go b/pkg/detectors/lastfm/lastfm_test.go index 458d9671515f..f4121d32960f 100644 --- a/pkg/detectors/lastfm/lastfm_test.go +++ b/pkg/detectors/lastfm/lastfm_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/launchdarkly/launchdarkly.go b/pkg/detectors/launchdarkly/launchdarkly.go index eada888fe43e..841aa220fb02 100644 --- a/pkg/detectors/launchdarkly/launchdarkly.go +++ b/pkg/detectors/launchdarkly/launchdarkly.go @@ -44,7 +44,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify LaunchDarkly secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/launchdarkly/launchdarkly_test.go b/pkg/detectors/launchdarkly/launchdarkly_test.go index 2f269462f5bd..0955011bc574 100644 --- a/pkg/detectors/launchdarkly/launchdarkly_test.go +++ b/pkg/detectors/launchdarkly/launchdarkly_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/ldap/ldap.go b/pkg/detectors/ldap/ldap.go index fb5fd15df687..9494cab51c9a 100644 --- a/pkg/detectors/ldap/ldap.go +++ b/pkg/detectors/ldap/ldap.go @@ -11,6 +11,8 @@ import ( "time" "github.com/go-ldap/ldap/v3" + + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" ) @@ -45,7 +47,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Ldap secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) // Check for matches in the URI + username + password format uriMatches := uriPat.FindAllString(dataStr, -1) diff --git a/pkg/detectors/ldap/ldap_integration_test.go b/pkg/detectors/ldap/ldap_integration_test.go index 8b85d382bcc2..1c7ac57e3410 100644 --- a/pkg/detectors/ldap/ldap_integration_test.go +++ b/pkg/detectors/ldap/ldap_integration_test.go @@ -7,14 +7,15 @@ import ( "bytes" "context" "errors" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "os" "os/exec" "strings" "testing" "time" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" diff --git a/pkg/detectors/ldap/ldap_test.go b/pkg/detectors/ldap/ldap_test.go index 91ac4ec4088f..e5d0be3c9bbe 100644 --- a/pkg/detectors/ldap/ldap_test.go +++ b/pkg/detectors/ldap/ldap_test.go @@ -8,6 +8,7 @@ import ( "testing" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" diff --git a/pkg/detectors/leadfeeder/leadfeeder.go b/pkg/detectors/leadfeeder/leadfeeder.go index 0b073b34cbe1..fae8704c2cea 100644 --- a/pkg/detectors/leadfeeder/leadfeeder.go +++ b/pkg/detectors/leadfeeder/leadfeeder.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Leadfeeder secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/leadfeeder/leadfeeder_test.go b/pkg/detectors/leadfeeder/leadfeeder_test.go index 7af05a73a15c..696909844cd5 100644 --- a/pkg/detectors/leadfeeder/leadfeeder_test.go +++ b/pkg/detectors/leadfeeder/leadfeeder_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/lemlist/lemlist.go b/pkg/detectors/lemlist/lemlist.go index 37954f4df623..fdaacf570969 100644 --- a/pkg/detectors/lemlist/lemlist.go +++ b/pkg/detectors/lemlist/lemlist.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Lemlist secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/lemlist/lemlist_test.go b/pkg/detectors/lemlist/lemlist_test.go index 772dfb0135fd..0efb23fbe8f9 100644 --- a/pkg/detectors/lemlist/lemlist_test.go +++ b/pkg/detectors/lemlist/lemlist_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/lemonsqueezy/lemonsqueezy.go b/pkg/detectors/lemonsqueezy/lemonsqueezy.go index b1cd1da4ac7e..1c98e6c8bae0 100644 --- a/pkg/detectors/lemonsqueezy/lemonsqueezy.go +++ b/pkg/detectors/lemonsqueezy/lemonsqueezy.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Lemonsqueezy secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/lendflow/lendflow.go b/pkg/detectors/lendflow/lendflow.go index 9503f6eb6d44..46745393ee49 100644 --- a/pkg/detectors/lendflow/lendflow.go +++ b/pkg/detectors/lendflow/lendflow.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Lendflow secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/lessannoyingcrm/lessannoyingcrm.go b/pkg/detectors/lessannoyingcrm/lessannoyingcrm.go index 06ec4ff2ec58..0ba2316a2ed9 100644 --- a/pkg/detectors/lessannoyingcrm/lessannoyingcrm.go +++ b/pkg/detectors/lessannoyingcrm/lessannoyingcrm.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify LessAnnoyingCRM secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/lessannoyingcrm/lessannoyingcrm_test.go b/pkg/detectors/lessannoyingcrm/lessannoyingcrm_test.go index f4e7540caa40..0fd817a470ca 100644 --- a/pkg/detectors/lessannoyingcrm/lessannoyingcrm_test.go +++ b/pkg/detectors/lessannoyingcrm/lessannoyingcrm_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/lexigram/lexigram.go b/pkg/detectors/lexigram/lexigram.go index b807ac8c59b9..9d369ee6ce2d 100644 --- a/pkg/detectors/lexigram/lexigram.go +++ b/pkg/detectors/lexigram/lexigram.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Lexigram secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/lexigram/lexigram_test.go b/pkg/detectors/lexigram/lexigram_test.go index 2ce5b9aaa45d..a6cf8826092e 100644 --- a/pkg/detectors/lexigram/lexigram_test.go +++ b/pkg/detectors/lexigram/lexigram_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/linearapi/linearapi.go b/pkg/detectors/linearapi/linearapi.go index c441c9277e91..a06e71a0611a 100644 --- a/pkg/detectors/linearapi/linearapi.go +++ b/pkg/detectors/linearapi/linearapi.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify LinearAPI secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/linearapi/linearapi_test.go b/pkg/detectors/linearapi/linearapi_test.go index fee39c012dcc..c355e4bf769e 100644 --- a/pkg/detectors/linearapi/linearapi_test.go +++ b/pkg/detectors/linearapi/linearapi_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/linemessaging/linemessaging.go b/pkg/detectors/linemessaging/linemessaging.go index 477d2b320323..0bbcba50c4e4 100644 --- a/pkg/detectors/linemessaging/linemessaging.go +++ b/pkg/detectors/linemessaging/linemessaging.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify LineMessaging secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/linemessaging/linemessaging_test.go b/pkg/detectors/linemessaging/linemessaging_test.go index fe92c70a03ff..6cbcda5ff906 100644 --- a/pkg/detectors/linemessaging/linemessaging_test.go +++ b/pkg/detectors/linemessaging/linemessaging_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/linenotify/linenotify.go b/pkg/detectors/linenotify/linenotify.go index 74c42255acdc..63c4d1620443 100644 --- a/pkg/detectors/linenotify/linenotify.go +++ b/pkg/detectors/linenotify/linenotify.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify LineNotify secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/linenotify/linenotify_test.go b/pkg/detectors/linenotify/linenotify_test.go index f9e31453f748..548b813b6c19 100644 --- a/pkg/detectors/linenotify/linenotify_test.go +++ b/pkg/detectors/linenotify/linenotify_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/linkpreview/linkpreview.go b/pkg/detectors/linkpreview/linkpreview.go index 9e8aeca43c49..a185f9273d76 100644 --- a/pkg/detectors/linkpreview/linkpreview.go +++ b/pkg/detectors/linkpreview/linkpreview.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify LinkPreview secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) for _, match := range matches { if len(match) != 2 { diff --git a/pkg/detectors/linkpreview/linkpreview_test.go b/pkg/detectors/linkpreview/linkpreview_test.go index a19aafae0fa2..05f960e444b2 100644 --- a/pkg/detectors/linkpreview/linkpreview_test.go +++ b/pkg/detectors/linkpreview/linkpreview_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/liveagent/liveagent.go b/pkg/detectors/liveagent/liveagent.go index 9dfc04df859d..de07ca20bcf9 100644 --- a/pkg/detectors/liveagent/liveagent.go +++ b/pkg/detectors/liveagent/liveagent.go @@ -37,7 +37,7 @@ type response struct { // FromData will find and optionally verify LiveAgent secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) domainMatches := domainPat.FindAllStringSubmatch(dataStr, -1) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/liveagent/liveagent_test.go b/pkg/detectors/liveagent/liveagent_test.go index 083387f18100..33d0a559f15a 100644 --- a/pkg/detectors/liveagent/liveagent_test.go +++ b/pkg/detectors/liveagent/liveagent_test.go @@ -11,6 +11,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/livestorm/livestorm.go b/pkg/detectors/livestorm/livestorm.go index c00e6023336a..11c3f480ee7c 100644 --- a/pkg/detectors/livestorm/livestorm.go +++ b/pkg/detectors/livestorm/livestorm.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Livestorm secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/loadmill/loadmill.go b/pkg/detectors/loadmill/loadmill.go index 7052e3215b3c..31c8aa033858 100644 --- a/pkg/detectors/loadmill/loadmill.go +++ b/pkg/detectors/loadmill/loadmill.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Loadmill secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/loadmill/loadmill_test.go b/pkg/detectors/loadmill/loadmill_test.go index a06fa98c739f..81a0285b70b0 100644 --- a/pkg/detectors/loadmill/loadmill_test.go +++ b/pkg/detectors/loadmill/loadmill_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/lob/lob.go b/pkg/detectors/lob/lob.go index a482c13ef076..0030b95292be 100644 --- a/pkg/detectors/lob/lob.go +++ b/pkg/detectors/lob/lob.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Lob secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/lob/lob_test.go b/pkg/detectors/lob/lob_test.go index d51ab8d49636..80971158f8ff 100644 --- a/pkg/detectors/lob/lob_test.go +++ b/pkg/detectors/lob/lob_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/locationiq/locationiq.go b/pkg/detectors/locationiq/locationiq.go index 918a1a426453..4305386459ad 100644 --- a/pkg/detectors/locationiq/locationiq.go +++ b/pkg/detectors/locationiq/locationiq.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify LocationIQ secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/locationiq/locationiq_test.go b/pkg/detectors/locationiq/locationiq_test.go index d3f9e2a4c28b..b268e6a79a23 100644 --- a/pkg/detectors/locationiq/locationiq_test.go +++ b/pkg/detectors/locationiq/locationiq_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/loggly/loggly.go b/pkg/detectors/loggly/loggly.go index 1c7bcd606644..7c2d3d2425ff 100644 --- a/pkg/detectors/loggly/loggly.go +++ b/pkg/detectors/loggly/loggly.go @@ -1,15 +1,15 @@ package loggly import ( - "context" - "fmt" - "net/http" - "regexp" - "strings" - - "github.com/trufflesecurity/trufflehog/v3/pkg/common" - "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" - "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" + "context" + "fmt" + "net/http" + "regexp" + "strings" + + "github.com/trufflesecurity/trufflehog/v3/pkg/common" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" + "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" ) type Scanner struct { @@ -20,82 +20,81 @@ type Scanner struct { var _ detectors.Detector = (*Scanner)(nil) var ( - defaultClient = common.SaneHttpClient() - // Make sure that your group is surrounded in boundary characters such as below to reduce false positives. - domainPat = regexp.MustCompile(`\b([a-zA-Z0-9-]+\.loggly\.com)\b`) - keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"loggly"}) + `\b([a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12})\b`) + defaultClient = common.SaneHttpClient() + // Make sure that your group is surrounded in boundary characters such as below to reduce false positives. + domainPat = regexp.MustCompile(`\b([a-zA-Z0-9-]+\.loggly\.com)\b`) + keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"loggly"}) + `\b([a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12})\b`) ) // Keywords are used for efficiently pre-filtering chunks. // Use identifiers in the secret preferably, or the provider name. func (s Scanner) Keywords() []string { - return []string{"loggly"} + return []string{"loggly"} } // FromData will find and optionally verify Loggly secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) - - keyMatches := keyPat.FindAllStringSubmatch(dataStr, -1) - domainMatches := domainPat.FindAllStringSubmatch(dataStr, -1) - - for _, match := range keyMatches { - if len(match) != 2 { - continue - } - key := strings.TrimSpace(match[1]) - - for _, domainMatch := range domainMatches { - if len(domainMatch) != 2 { - continue - } - - domainRes := strings.TrimSpace(domainMatch[1]) - - s1 := detectors.Result{ - DetectorType: detectorspb.DetectorType_Loggly, - Raw: []byte(key), - RawV2: []byte(fmt.Sprintf("%s:%s", domainRes, key)), - - } - - if verify { - client := s.client - if client == nil { - client = defaultClient - } - req, err := http.NewRequestWithContext(ctx, "GET", "https://"+domainRes+"/apiv2/customer", nil) - if err != nil { - continue - } - req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", key)) - res, err := client.Do(req) - if err == nil { - defer res.Body.Close() - if res.StatusCode >= 200 && res.StatusCode < 300 { - s1.Verified = true - } else if res.StatusCode == 401 { - // The secret is determinately not verified (nothing to do) - } else { - s1.VerificationError = fmt.Errorf("unexpected HTTP response status %d", res.StatusCode) - } - } else { - s1.VerificationError = err - } - } - - // This function will check false positives for common test words, but also it will make sure the key appears 'random' enough to be a real key. - if !s1.Verified && detectors.IsKnownFalsePositive(key, detectors.DefaultFalsePositives, true) { - continue - } - - results = append(results, s1) - } - } - - return results, nil + dataStr := common.BytesToString(data) + + keyMatches := keyPat.FindAllStringSubmatch(dataStr, -1) + domainMatches := domainPat.FindAllStringSubmatch(dataStr, -1) + + for _, match := range keyMatches { + if len(match) != 2 { + continue + } + key := strings.TrimSpace(match[1]) + + for _, domainMatch := range domainMatches { + if len(domainMatch) != 2 { + continue + } + + domainRes := strings.TrimSpace(domainMatch[1]) + + s1 := detectors.Result{ + DetectorType: detectorspb.DetectorType_Loggly, + Raw: []byte(key), + RawV2: []byte(fmt.Sprintf("%s:%s", domainRes, key)), + } + + if verify { + client := s.client + if client == nil { + client = defaultClient + } + req, err := http.NewRequestWithContext(ctx, "GET", "https://"+domainRes+"/apiv2/customer", nil) + if err != nil { + continue + } + req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", key)) + res, err := client.Do(req) + if err == nil { + defer res.Body.Close() + if res.StatusCode >= 200 && res.StatusCode < 300 { + s1.Verified = true + } else if res.StatusCode == 401 { + // The secret is determinately not verified (nothing to do) + } else { + s1.VerificationError = fmt.Errorf("unexpected HTTP response status %d", res.StatusCode) + } + } else { + s1.VerificationError = err + } + } + + // This function will check false positives for common test words, but also it will make sure the key appears 'random' enough to be a real key. + if !s1.Verified && detectors.IsKnownFalsePositive(key, detectors.DefaultFalsePositives, true) { + continue + } + + results = append(results, s1) + } + } + + return results, nil } func (s Scanner) Type() detectorspb.DetectorType { - return detectorspb.DetectorType_Loggly + return detectorspb.DetectorType_Loggly } diff --git a/pkg/detectors/loggly/loggly_test.go b/pkg/detectors/loggly/loggly_test.go index aa19774824ed..7192dffe4857 100644 --- a/pkg/detectors/loggly/loggly_test.go +++ b/pkg/detectors/loggly/loggly_test.go @@ -6,11 +6,12 @@ package loggly import ( "context" "fmt" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "testing" "time" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/loginradius/loginradius.go b/pkg/detectors/loginradius/loginradius.go index e50b3b021445..a4523262525a 100644 --- a/pkg/detectors/loginradius/loginradius.go +++ b/pkg/detectors/loginradius/loginradius.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Loginradius secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/loginradius/loginradius_test.go b/pkg/detectors/loginradius/loginradius_test.go index 4d124751d9e6..804cf7c9d327 100644 --- a/pkg/detectors/loginradius/loginradius_test.go +++ b/pkg/detectors/loginradius/loginradius_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/logzio/logzio.go b/pkg/detectors/logzio/logzio.go index 572fe52697cd..e660389bbe16 100644 --- a/pkg/detectors/logzio/logzio.go +++ b/pkg/detectors/logzio/logzio.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Logzio secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/logzio/logzio_test.go b/pkg/detectors/logzio/logzio_test.go index d754d7f07d6b..28a17748c413 100644 --- a/pkg/detectors/logzio/logzio_test.go +++ b/pkg/detectors/logzio/logzio_test.go @@ -6,11 +6,12 @@ package logzio import ( "context" "fmt" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "testing" "time" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/lokalisetoken/lokalisetoken.go b/pkg/detectors/lokalisetoken/lokalisetoken.go index 7b9ca3baa7f3..ce5333dcd975 100644 --- a/pkg/detectors/lokalisetoken/lokalisetoken.go +++ b/pkg/detectors/lokalisetoken/lokalisetoken.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify LokaliseToken secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) // log.Println(dataStr) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/lokalisetoken/lokalisetoken_test.go b/pkg/detectors/lokalisetoken/lokalisetoken_test.go index e02d9ccbaeaa..b848c0cd3a89 100644 --- a/pkg/detectors/lokalisetoken/lokalisetoken_test.go +++ b/pkg/detectors/lokalisetoken/lokalisetoken_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/loyverse/loyverse.go b/pkg/detectors/loyverse/loyverse.go index 7654ffebbdde..13b854f6689b 100644 --- a/pkg/detectors/loyverse/loyverse.go +++ b/pkg/detectors/loyverse/loyverse.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Loyverse secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/loyverse/loyverse_test.go b/pkg/detectors/loyverse/loyverse_test.go index 064b6aa48b4b..6ab0ea33f7f8 100644 --- a/pkg/detectors/loyverse/loyverse_test.go +++ b/pkg/detectors/loyverse/loyverse_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/lunchmoney/lunchmoney.go b/pkg/detectors/lunchmoney/lunchmoney.go index 778801793dba..6a8b7fbdec08 100644 --- a/pkg/detectors/lunchmoney/lunchmoney.go +++ b/pkg/detectors/lunchmoney/lunchmoney.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify LunchMoney secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/lunchmoney/lunchmoney_test.go b/pkg/detectors/lunchmoney/lunchmoney_test.go index 43695e6cc2a4..21ebf9a73714 100644 --- a/pkg/detectors/lunchmoney/lunchmoney_test.go +++ b/pkg/detectors/lunchmoney/lunchmoney_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/luno/luno.go b/pkg/detectors/luno/luno.go index be80eb81bb9b..ee59b67972f5 100644 --- a/pkg/detectors/luno/luno.go +++ b/pkg/detectors/luno/luno.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Luno secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/luno/luno_test.go b/pkg/detectors/luno/luno_test.go index 7417286672bc..b2a20d6b6f18 100644 --- a/pkg/detectors/luno/luno_test.go +++ b/pkg/detectors/luno/luno_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/m3o/m3o.go b/pkg/detectors/m3o/m3o.go index 5c5c78f019d3..8456cf8f0363 100644 --- a/pkg/detectors/m3o/m3o.go +++ b/pkg/detectors/m3o/m3o.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify M3o secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/m3o/m3o_test.go b/pkg/detectors/m3o/m3o_test.go index 14fc9f2871cd..449ec165aae2 100644 --- a/pkg/detectors/m3o/m3o_test.go +++ b/pkg/detectors/m3o/m3o_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/macaddress/macaddress.go b/pkg/detectors/macaddress/macaddress.go index 74d26b1dd515..1bc8e87e8f77 100644 --- a/pkg/detectors/macaddress/macaddress.go +++ b/pkg/detectors/macaddress/macaddress.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Macaddress secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) for _, match := range matches { diff --git a/pkg/detectors/macaddress/macaddress_test.go b/pkg/detectors/macaddress/macaddress_test.go index e1ee91a23442..e72d010b3531 100644 --- a/pkg/detectors/macaddress/macaddress_test.go +++ b/pkg/detectors/macaddress/macaddress_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/madkudu/madkudu.go b/pkg/detectors/madkudu/madkudu.go index 1256ecd0beae..161123abcbaf 100644 --- a/pkg/detectors/madkudu/madkudu.go +++ b/pkg/detectors/madkudu/madkudu.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify MadKudu secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/magicbell/magicbell.go b/pkg/detectors/magicbell/magicbell.go index 84d2666dc702..e9b621f0befa 100644 --- a/pkg/detectors/magicbell/magicbell.go +++ b/pkg/detectors/magicbell/magicbell.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify MagicBell secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) apiKeyMatches := keyPat.FindAllStringSubmatch(dataStr, -1) emailMatches := emailPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/magicbell/magicbell_test.go b/pkg/detectors/magicbell/magicbell_test.go index ad8b34a18a6b..1e6e91587557 100644 --- a/pkg/detectors/magicbell/magicbell_test.go +++ b/pkg/detectors/magicbell/magicbell_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/magnetic/magnetic.go b/pkg/detectors/magnetic/magnetic.go index 40b7f21a5121..773670958a36 100644 --- a/pkg/detectors/magnetic/magnetic.go +++ b/pkg/detectors/magnetic/magnetic.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Magnetic secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/mailboxlayer/mailboxlayer.go b/pkg/detectors/mailboxlayer/mailboxlayer.go index c882dbaa8b5e..c71e9d3fbe3c 100644 --- a/pkg/detectors/mailboxlayer/mailboxlayer.go +++ b/pkg/detectors/mailboxlayer/mailboxlayer.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Mailboxplayer secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/mailboxlayer/mailboxlayer_test.go b/pkg/detectors/mailboxlayer/mailboxlayer_test.go index e6cbc1ba42b1..f74c18e1c640 100644 --- a/pkg/detectors/mailboxlayer/mailboxlayer_test.go +++ b/pkg/detectors/mailboxlayer/mailboxlayer_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/mailchimp/mailchimp.go b/pkg/detectors/mailchimp/mailchimp.go index a206b070ae0d..5a6215b7d5b3 100644 --- a/pkg/detectors/mailchimp/mailchimp.go +++ b/pkg/detectors/mailchimp/mailchimp.go @@ -31,9 +31,9 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Mailchimp secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) - //pretty standard regex match + // pretty standard regex match matches := keyPat.FindAllString(dataStr, -1) for _, match := range matches { diff --git a/pkg/detectors/mailchimp/mailchimp_test.go b/pkg/detectors/mailchimp/mailchimp_test.go index dae93805c52f..c2fefa03ca33 100644 --- a/pkg/detectors/mailchimp/mailchimp_test.go +++ b/pkg/detectors/mailchimp/mailchimp_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" diff --git a/pkg/detectors/mailerlite/mailerlite.go b/pkg/detectors/mailerlite/mailerlite.go index 1e33df8e24ff..bfddd6c02ab1 100644 --- a/pkg/detectors/mailerlite/mailerlite.go +++ b/pkg/detectors/mailerlite/mailerlite.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Mailerlite secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/mailerlite/mailerlite_test.go b/pkg/detectors/mailerlite/mailerlite_test.go index 21a04bfc065a..44d180ea1cd6 100644 --- a/pkg/detectors/mailerlite/mailerlite_test.go +++ b/pkg/detectors/mailerlite/mailerlite_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/mailgun/mailgun.go b/pkg/detectors/mailgun/mailgun.go index dd9556617d30..18af8a00f295 100644 --- a/pkg/detectors/mailgun/mailgun.go +++ b/pkg/detectors/mailgun/mailgun.go @@ -35,7 +35,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Mailgun secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) for _, tokenPat := range tokenPats { matches := tokenPat.FindAllStringSubmatch(dataStr, -1) @@ -55,7 +55,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result if err != nil { continue } - + // If resMatch has "key" prefix, use it as the username for basic auth. if strings.HasPrefix(resMatch, "key-") { req.SetBasicAuth("api", resMatch) diff --git a/pkg/detectors/mailgun/mailgun_test.go b/pkg/detectors/mailgun/mailgun_test.go index aaa3d0b05bf1..a7f4287de202 100644 --- a/pkg/detectors/mailgun/mailgun_test.go +++ b/pkg/detectors/mailgun/mailgun_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/mailjetbasicauth/mailjetbasicauth.go b/pkg/detectors/mailjetbasicauth/mailjetbasicauth.go index 0030e5e63857..66a2bdc85fe5 100644 --- a/pkg/detectors/mailjetbasicauth/mailjetbasicauth.go +++ b/pkg/detectors/mailjetbasicauth/mailjetbasicauth.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify MailJetBasicAuth secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/mailjetbasicauth/mailjetbasicauth_test.go b/pkg/detectors/mailjetbasicauth/mailjetbasicauth_test.go index 9df8b97abdcb..9a45759079d1 100644 --- a/pkg/detectors/mailjetbasicauth/mailjetbasicauth_test.go +++ b/pkg/detectors/mailjetbasicauth/mailjetbasicauth_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/mailjetsms/mailjetsms.go b/pkg/detectors/mailjetsms/mailjetsms.go index 43388ef9fceb..a3e4ef64e598 100644 --- a/pkg/detectors/mailjetsms/mailjetsms.go +++ b/pkg/detectors/mailjetsms/mailjetsms.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify MailJetSMS secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/mailjetsms/mailjetsms_test.go b/pkg/detectors/mailjetsms/mailjetsms_test.go index 01c184013b18..11180572e7d5 100644 --- a/pkg/detectors/mailjetsms/mailjetsms_test.go +++ b/pkg/detectors/mailjetsms/mailjetsms_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/mailmodo/mailmodo.go b/pkg/detectors/mailmodo/mailmodo.go index 2c3b093cbfb7..b90e52ff9ae9 100644 --- a/pkg/detectors/mailmodo/mailmodo.go +++ b/pkg/detectors/mailmodo/mailmodo.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Mailmodo secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/mailmodo/mailmodo_test.go b/pkg/detectors/mailmodo/mailmodo_test.go index 8c1093a63d99..11cb7f172800 100644 --- a/pkg/detectors/mailmodo/mailmodo_test.go +++ b/pkg/detectors/mailmodo/mailmodo_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/mailsac/mailsac.go b/pkg/detectors/mailsac/mailsac.go index 5504ba8db457..ae5d603c112b 100644 --- a/pkg/detectors/mailsac/mailsac.go +++ b/pkg/detectors/mailsac/mailsac.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Mailsac secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/mailsac/mailsac_test.go b/pkg/detectors/mailsac/mailsac_test.go index 0eb882535522..f98b10ccf1bb 100644 --- a/pkg/detectors/mailsac/mailsac_test.go +++ b/pkg/detectors/mailsac/mailsac_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/mandrill/mandrill.go b/pkg/detectors/mandrill/mandrill.go index c1d928d8b1b7..355a706dd116 100644 --- a/pkg/detectors/mandrill/mandrill.go +++ b/pkg/detectors/mandrill/mandrill.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Mandrill secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/mandrill/mandrill_test.go b/pkg/detectors/mandrill/mandrill_test.go index dd04d93fc6f5..6ab112049d83 100644 --- a/pkg/detectors/mandrill/mandrill_test.go +++ b/pkg/detectors/mandrill/mandrill_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/manifest/manifest.go b/pkg/detectors/manifest/manifest.go index 9521dddb6c19..d49f6bfab99f 100644 --- a/pkg/detectors/manifest/manifest.go +++ b/pkg/detectors/manifest/manifest.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Manifest secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/manifest/manifest_test.go b/pkg/detectors/manifest/manifest_test.go index 33d3cbc1892f..b952fce38207 100644 --- a/pkg/detectors/manifest/manifest_test.go +++ b/pkg/detectors/manifest/manifest_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/mapbox/mapbox.go b/pkg/detectors/mapbox/mapbox.go index 951de013ece8..7e3a16ac806d 100644 --- a/pkg/detectors/mapbox/mapbox.go +++ b/pkg/detectors/mapbox/mapbox.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify MapBox secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/mapbox/mapbox_test.go b/pkg/detectors/mapbox/mapbox_test.go index 93860db8e4e7..be637ec3123e 100644 --- a/pkg/detectors/mapbox/mapbox_test.go +++ b/pkg/detectors/mapbox/mapbox_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/mapquest/mapquest.go b/pkg/detectors/mapquest/mapquest.go index 31f52b086d85..47dcf406089e 100644 --- a/pkg/detectors/mapquest/mapquest.go +++ b/pkg/detectors/mapquest/mapquest.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Mapquest secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/mapquest/mapquest_test.go b/pkg/detectors/mapquest/mapquest_test.go index 81abcc727c30..cc9ab9e95ee9 100644 --- a/pkg/detectors/mapquest/mapquest_test.go +++ b/pkg/detectors/mapquest/mapquest_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/marketstack/marketstack.go b/pkg/detectors/marketstack/marketstack.go index 531d7594a864..018aa35b9ad2 100644 --- a/pkg/detectors/marketstack/marketstack.go +++ b/pkg/detectors/marketstack/marketstack.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Marketstack secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/marketstack/marketstack_test.go b/pkg/detectors/marketstack/marketstack_test.go index fb5ceaa8b1b6..c6daff3b854f 100644 --- a/pkg/detectors/marketstack/marketstack_test.go +++ b/pkg/detectors/marketstack/marketstack_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/mattermostpersonaltoken/mattermostpersonaltoken.go b/pkg/detectors/mattermostpersonaltoken/mattermostpersonaltoken.go index cc64e07fe897..fbf8df8e43dd 100644 --- a/pkg/detectors/mattermostpersonaltoken/mattermostpersonaltoken.go +++ b/pkg/detectors/mattermostpersonaltoken/mattermostpersonaltoken.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify MattermostPersonalToken secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) serverMatches := serverPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/mattermostpersonaltoken/mattermostpersonaltoken_test.go b/pkg/detectors/mattermostpersonaltoken/mattermostpersonaltoken_test.go index b1db37b782a1..30e3aa2f5941 100644 --- a/pkg/detectors/mattermostpersonaltoken/mattermostpersonaltoken_test.go +++ b/pkg/detectors/mattermostpersonaltoken/mattermostpersonaltoken_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/mavenlink/mavenlink.go b/pkg/detectors/mavenlink/mavenlink.go index 953b6041d2d0..5bc70a91ca26 100644 --- a/pkg/detectors/mavenlink/mavenlink.go +++ b/pkg/detectors/mavenlink/mavenlink.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Mavenlink secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/maxmindlicense/maxmindlicense.go b/pkg/detectors/maxmindlicense/maxmindlicense.go index 1e694e4238a5..81ba77978111 100644 --- a/pkg/detectors/maxmindlicense/maxmindlicense.go +++ b/pkg/detectors/maxmindlicense/maxmindlicense.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify MaxMindLicense secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) keyMatches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/maxmindlicense/maxmindlicense_test.go b/pkg/detectors/maxmindlicense/maxmindlicense_test.go index 42ff4ca1bbae..a0b12ff66af3 100644 --- a/pkg/detectors/maxmindlicense/maxmindlicense_test.go +++ b/pkg/detectors/maxmindlicense/maxmindlicense_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/meaningcloud/meaningcloud.go b/pkg/detectors/meaningcloud/meaningcloud.go index ca1814de5dc3..886da8fa5655 100644 --- a/pkg/detectors/meaningcloud/meaningcloud.go +++ b/pkg/detectors/meaningcloud/meaningcloud.go @@ -39,7 +39,7 @@ type response struct { // FromData will find and optionally verify MeaningCloud secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/meaningcloud/meaningcloud_test.go b/pkg/detectors/meaningcloud/meaningcloud_test.go index b446614e52b1..cd3cc305cc21 100644 --- a/pkg/detectors/meaningcloud/meaningcloud_test.go +++ b/pkg/detectors/meaningcloud/meaningcloud_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/mediastack/mediastack.go b/pkg/detectors/mediastack/mediastack.go index ab61cbc6403b..fa2162d14e2a 100644 --- a/pkg/detectors/mediastack/mediastack.go +++ b/pkg/detectors/mediastack/mediastack.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify MediaStack secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/mediastack/mediastack_test.go b/pkg/detectors/mediastack/mediastack_test.go index 88c2ee2ac586..57e62da819e9 100644 --- a/pkg/detectors/mediastack/mediastack_test.go +++ b/pkg/detectors/mediastack/mediastack_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/meistertask/meistertask.go b/pkg/detectors/meistertask/meistertask.go index 2a1b2b8d3b1b..7e75894963a2 100644 --- a/pkg/detectors/meistertask/meistertask.go +++ b/pkg/detectors/meistertask/meistertask.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Meistertask secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/meistertask/meistertask_test.go b/pkg/detectors/meistertask/meistertask_test.go index c12b9885eeb4..ef3011f733a8 100644 --- a/pkg/detectors/meistertask/meistertask_test.go +++ b/pkg/detectors/meistertask/meistertask_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/mesibo/mesibo.go b/pkg/detectors/mesibo/mesibo.go index 1edb719ae6f1..809ef0215da3 100644 --- a/pkg/detectors/mesibo/mesibo.go +++ b/pkg/detectors/mesibo/mesibo.go @@ -13,6 +13,7 @@ import ( ) type Scanner struct{} + // Ensure the Scanner satisfies the interface at compile time. var _ detectors.Detector = (*Scanner)(nil) @@ -31,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Mesibo secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/mesibo/mesibo_test.go b/pkg/detectors/mesibo/mesibo_test.go index 7f73d769de88..0fbd32e363cf 100644 --- a/pkg/detectors/mesibo/mesibo_test.go +++ b/pkg/detectors/mesibo/mesibo_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/messagebird/messagebird.go b/pkg/detectors/messagebird/messagebird.go index 73caffba8d28..c8b46690327e 100644 --- a/pkg/detectors/messagebird/messagebird.go +++ b/pkg/detectors/messagebird/messagebird.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify MessageBird secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/messagebird/messagebird_test.go b/pkg/detectors/messagebird/messagebird_test.go index e07856312fde..d9ecc127e674 100644 --- a/pkg/detectors/messagebird/messagebird_test.go +++ b/pkg/detectors/messagebird/messagebird_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/metaapi/metaapi.go b/pkg/detectors/metaapi/metaapi.go index a59e331068a5..d31cb97ce744 100644 --- a/pkg/detectors/metaapi/metaapi.go +++ b/pkg/detectors/metaapi/metaapi.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify MetaAPI secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) spellMatches := spellPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/metabase/metabase.go b/pkg/detectors/metabase/metabase.go index ce4e314da0fc..7f3afc03bf9b 100644 --- a/pkg/detectors/metabase/metabase.go +++ b/pkg/detectors/metabase/metabase.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Metabase secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) urlMatches := baseURL.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/metrilo/metrilo.go b/pkg/detectors/metrilo/metrilo.go index f3dfac5379b6..a26ea920af4f 100644 --- a/pkg/detectors/metrilo/metrilo.go +++ b/pkg/detectors/metrilo/metrilo.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Metrilo secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/metrilo/metrilo_test.go b/pkg/detectors/metrilo/metrilo_test.go index be56d5d02f7b..11b2f18f8cd9 100644 --- a/pkg/detectors/metrilo/metrilo_test.go +++ b/pkg/detectors/metrilo/metrilo_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/microsoftteamswebhook/microsoftteamswebhook.go b/pkg/detectors/microsoftteamswebhook/microsoftteamswebhook.go index 5047d0bb064e..fa944b7baead 100644 --- a/pkg/detectors/microsoftteamswebhook/microsoftteamswebhook.go +++ b/pkg/detectors/microsoftteamswebhook/microsoftteamswebhook.go @@ -36,7 +36,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify MicrosoftTeamsWebhook secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/microsoftteamswebhook/microsoftteamswebhook_test.go b/pkg/detectors/microsoftteamswebhook/microsoftteamswebhook_test.go index 0db3ff2b1445..c663ca271036 100644 --- a/pkg/detectors/microsoftteamswebhook/microsoftteamswebhook_test.go +++ b/pkg/detectors/microsoftteamswebhook/microsoftteamswebhook_test.go @@ -11,6 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/mindmeister/mindmeister.go b/pkg/detectors/mindmeister/mindmeister.go index 3440b873cca4..8a2f6c3a69aa 100644 --- a/pkg/detectors/mindmeister/mindmeister.go +++ b/pkg/detectors/mindmeister/mindmeister.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Mindmeister secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/mindmeister/mindmeister_test.go b/pkg/detectors/mindmeister/mindmeister_test.go index ff737f463e7d..e2a360b4edce 100644 --- a/pkg/detectors/mindmeister/mindmeister_test.go +++ b/pkg/detectors/mindmeister/mindmeister_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/miro/miro.go b/pkg/detectors/miro/miro.go index 451e9b84b85c..c1c4570a8283 100644 --- a/pkg/detectors/miro/miro.go +++ b/pkg/detectors/miro/miro.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Miro secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/miro/miro_test.go b/pkg/detectors/miro/miro_test.go index 1fa7093a28bb..5ca0dfb0f602 100644 --- a/pkg/detectors/miro/miro_test.go +++ b/pkg/detectors/miro/miro_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/mite/mite.go b/pkg/detectors/mite/mite.go index 5fe3bf7b0043..cb2faf4f8a54 100644 --- a/pkg/detectors/mite/mite.go +++ b/pkg/detectors/mite/mite.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Mite secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) urlMatches := urlPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/mite/mite_test.go b/pkg/detectors/mite/mite_test.go index 6d456d15176c..28bfd789b44d 100644 --- a/pkg/detectors/mite/mite_test.go +++ b/pkg/detectors/mite/mite_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/mixmax/mixmax.go b/pkg/detectors/mixmax/mixmax.go index 9bebb2a67fdd..51c753f0b903 100644 --- a/pkg/detectors/mixmax/mixmax.go +++ b/pkg/detectors/mixmax/mixmax.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Mixmax secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/mixmax/mixmax_test.go b/pkg/detectors/mixmax/mixmax_test.go index c4f70cddcc77..6f5064144d6f 100644 --- a/pkg/detectors/mixmax/mixmax_test.go +++ b/pkg/detectors/mixmax/mixmax_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/mixpanel/mixpanel.go b/pkg/detectors/mixpanel/mixpanel.go index 028ed97ce820..91f1729b6162 100644 --- a/pkg/detectors/mixpanel/mixpanel.go +++ b/pkg/detectors/mixpanel/mixpanel.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Mixpanel secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/mixpanel/mixpanel_test.go b/pkg/detectors/mixpanel/mixpanel_test.go index eecccd0fd022..7b7b14cdfa37 100644 --- a/pkg/detectors/mixpanel/mixpanel_test.go +++ b/pkg/detectors/mixpanel/mixpanel_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/mockaroo/mockaroo.go b/pkg/detectors/mockaroo/mockaroo.go index 0a51274157af..d678bfc85aed 100644 --- a/pkg/detectors/mockaroo/mockaroo.go +++ b/pkg/detectors/mockaroo/mockaroo.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Mockaroo secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/mockaroo/mockaroo_test.go b/pkg/detectors/mockaroo/mockaroo_test.go index e3121d181eb6..61a8f59c45ff 100644 --- a/pkg/detectors/mockaroo/mockaroo_test.go +++ b/pkg/detectors/mockaroo/mockaroo_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/moderation/moderation.go b/pkg/detectors/moderation/moderation.go index 288bd36886c0..0a535c2920ad 100644 --- a/pkg/detectors/moderation/moderation.go +++ b/pkg/detectors/moderation/moderation.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Moderation secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/monday/monday.go b/pkg/detectors/monday/monday.go index 9848e2bae51e..dc21d60e1f7c 100644 --- a/pkg/detectors/monday/monday.go +++ b/pkg/detectors/monday/monday.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Monday secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/mongodb/mongodb.go b/pkg/detectors/mongodb/mongodb.go index a98d4dbfe766..1ea4506cb105 100644 --- a/pkg/detectors/mongodb/mongodb.go +++ b/pkg/detectors/mongodb/mongodb.go @@ -12,6 +12,7 @@ import ( "go.mongodb.org/mongo-driver/x/mongo/driver/auth" "go.mongodb.org/mongo-driver/x/mongo/driver/topology" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" ) @@ -38,7 +39,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify MongoDB secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/monkeylearn/monkeylearn.go b/pkg/detectors/monkeylearn/monkeylearn.go index 3c54537fb43c..1708a576a1a1 100644 --- a/pkg/detectors/monkeylearn/monkeylearn.go +++ b/pkg/detectors/monkeylearn/monkeylearn.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify MonkeyLearn secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/monkeylearn/monkeylearn_test.go b/pkg/detectors/monkeylearn/monkeylearn_test.go index d846f5862594..b2360ea0ae81 100644 --- a/pkg/detectors/monkeylearn/monkeylearn_test.go +++ b/pkg/detectors/monkeylearn/monkeylearn_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/moonclerk/moonclerk.go b/pkg/detectors/moonclerk/moonclerk.go index ff721cbe1ad0..782ff034c61a 100644 --- a/pkg/detectors/moonclerk/moonclerk.go +++ b/pkg/detectors/moonclerk/moonclerk.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Moonclerk secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/moosend/moosend.go b/pkg/detectors/moosend/moosend.go index 4cdf7ce1a3eb..af5b1269f4cd 100644 --- a/pkg/detectors/moosend/moosend.go +++ b/pkg/detectors/moosend/moosend.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Moosend secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/moosend/moosend_test.go b/pkg/detectors/moosend/moosend_test.go index e8844d7d06b3..1a443eb5ab55 100644 --- a/pkg/detectors/moosend/moosend_test.go +++ b/pkg/detectors/moosend/moosend_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/moralis/moralis.go b/pkg/detectors/moralis/moralis.go index cf70f73aec31..6bfd3b34a421 100644 --- a/pkg/detectors/moralis/moralis.go +++ b/pkg/detectors/moralis/moralis.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Moralis secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/moralis/moralis_test.go b/pkg/detectors/moralis/moralis_test.go index b1c7bf355afb..d91b0b907fcc 100644 --- a/pkg/detectors/moralis/moralis_test.go +++ b/pkg/detectors/moralis/moralis_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/mrticktock/mrticktock.go b/pkg/detectors/mrticktock/mrticktock.go index 5b226b04f013..caa1f77502aa 100644 --- a/pkg/detectors/mrticktock/mrticktock.go +++ b/pkg/detectors/mrticktock/mrticktock.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Mrticktock secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := emailPat.FindAllStringSubmatch(dataStr, -1) passwordMatches := pwordPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/mrticktock/mrticktock_test.go b/pkg/detectors/mrticktock/mrticktock_test.go index 0a9e09075f90..6a7820db7c38 100644 --- a/pkg/detectors/mrticktock/mrticktock_test.go +++ b/pkg/detectors/mrticktock/mrticktock_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/mux/mux.go b/pkg/detectors/mux/mux.go index 7fcb6a4db217..5124c792051e 100644 --- a/pkg/detectors/mux/mux.go +++ b/pkg/detectors/mux/mux.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Mux secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) secretMatches := secretPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/mux/mux_test.go b/pkg/detectors/mux/mux_test.go index 871b44a7a35d..5d8180f05b28 100644 --- a/pkg/detectors/mux/mux_test.go +++ b/pkg/detectors/mux/mux_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/myfreshworks/myfreshworks.go b/pkg/detectors/myfreshworks/myfreshworks.go index e5cc2bcd769b..bb96d9de7332 100644 --- a/pkg/detectors/myfreshworks/myfreshworks.go +++ b/pkg/detectors/myfreshworks/myfreshworks.go @@ -35,7 +35,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Myfreshworks secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idmatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/myfreshworks/myfreshworks_test.go b/pkg/detectors/myfreshworks/myfreshworks_test.go index f260a76fc0b0..42bd62b056de 100644 --- a/pkg/detectors/myfreshworks/myfreshworks_test.go +++ b/pkg/detectors/myfreshworks/myfreshworks_test.go @@ -11,6 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" diff --git a/pkg/detectors/myintervals/myintervals.go b/pkg/detectors/myintervals/myintervals.go index 9486811d3425..fdfec3c17efe 100644 --- a/pkg/detectors/myintervals/myintervals.go +++ b/pkg/detectors/myintervals/myintervals.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Myintervals secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/myintervals/myintervals_test.go b/pkg/detectors/myintervals/myintervals_test.go index 18af6689df39..bd446dbd8083 100644 --- a/pkg/detectors/myintervals/myintervals_test.go +++ b/pkg/detectors/myintervals/myintervals_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/nasdaqdatalink/nasdaqdatalink.go b/pkg/detectors/nasdaqdatalink/nasdaqdatalink.go index 18a29d13fd59..89f7d57c4659 100644 --- a/pkg/detectors/nasdaqdatalink/nasdaqdatalink.go +++ b/pkg/detectors/nasdaqdatalink/nasdaqdatalink.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify NasdaqDataLink secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/nasdaqdatalink/nasdaqdatalink_test.go b/pkg/detectors/nasdaqdatalink/nasdaqdatalink_test.go index 831a5a523151..dcf8c6b3c7dd 100644 --- a/pkg/detectors/nasdaqdatalink/nasdaqdatalink_test.go +++ b/pkg/detectors/nasdaqdatalink/nasdaqdatalink_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/nethunt/nethunt.go b/pkg/detectors/nethunt/nethunt.go index a91abb4e796c..bbd0fd7a1679 100644 --- a/pkg/detectors/nethunt/nethunt.go +++ b/pkg/detectors/nethunt/nethunt.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Nethunt secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/nethunt/nethunt_test.go b/pkg/detectors/nethunt/nethunt_test.go index 89d5ff7499cb..69904c1b1226 100644 --- a/pkg/detectors/nethunt/nethunt_test.go +++ b/pkg/detectors/nethunt/nethunt_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/netlify/netlify.go b/pkg/detectors/netlify/netlify.go index a0c75a46559c..28d8026c5268 100644 --- a/pkg/detectors/netlify/netlify.go +++ b/pkg/detectors/netlify/netlify.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Netlify secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/netlify/netlify_test.go b/pkg/detectors/netlify/netlify_test.go index 2d8060deaf78..8fc2f5b1e48d 100644 --- a/pkg/detectors/netlify/netlify_test.go +++ b/pkg/detectors/netlify/netlify_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/neutrinoapi/neutrinoapi.go b/pkg/detectors/neutrinoapi/neutrinoapi.go index c4bbf5eeedc8..b0d0ce7c184a 100644 --- a/pkg/detectors/neutrinoapi/neutrinoapi.go +++ b/pkg/detectors/neutrinoapi/neutrinoapi.go @@ -36,7 +36,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify NeutrinoApi secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/neutrinoapi/neutrinoapi_test.go b/pkg/detectors/neutrinoapi/neutrinoapi_test.go index 599e8e543a93..bdd580d9513d 100644 --- a/pkg/detectors/neutrinoapi/neutrinoapi_test.go +++ b/pkg/detectors/neutrinoapi/neutrinoapi_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/newrelicpersonalapikey/newrelicpersonalapikey.go b/pkg/detectors/newrelicpersonalapikey/newrelicpersonalapikey.go index 2f954faa621c..b88034954f9d 100644 --- a/pkg/detectors/newrelicpersonalapikey/newrelicpersonalapikey.go +++ b/pkg/detectors/newrelicpersonalapikey/newrelicpersonalapikey.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify NewRelicPersonalApiKey secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) @@ -54,7 +54,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } req.Header.Add("X-Api-Key", resMatch) reqEU.Header.Add("X-Api-Key", resMatch) - + res, err := client.Do(req) resEU, errEU := client.Do(reqEU) diff --git a/pkg/detectors/newrelicpersonalapikey/newrelicpersonalapikey_test.go b/pkg/detectors/newrelicpersonalapikey/newrelicpersonalapikey_test.go index fbed22239ef5..64e96ace08e1 100644 --- a/pkg/detectors/newrelicpersonalapikey/newrelicpersonalapikey_test.go +++ b/pkg/detectors/newrelicpersonalapikey/newrelicpersonalapikey_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/newsapi/newsapi.go b/pkg/detectors/newsapi/newsapi.go index 99fada386e71..0ad7a78969ab 100644 --- a/pkg/detectors/newsapi/newsapi.go +++ b/pkg/detectors/newsapi/newsapi.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Newsapi secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/newsapi/newsapi_test.go b/pkg/detectors/newsapi/newsapi_test.go index 179b6cd9ec44..0d78ad1a6380 100644 --- a/pkg/detectors/newsapi/newsapi_test.go +++ b/pkg/detectors/newsapi/newsapi_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/newscatcher/newscatcher.go b/pkg/detectors/newscatcher/newscatcher.go index bfd1bca4fe83..b80839b5b9a7 100644 --- a/pkg/detectors/newscatcher/newscatcher.go +++ b/pkg/detectors/newscatcher/newscatcher.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Newscatcher secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/newscatcher/newscatcher_test.go b/pkg/detectors/newscatcher/newscatcher_test.go index 67799c9d2e6a..1e372e360365 100644 --- a/pkg/detectors/newscatcher/newscatcher_test.go +++ b/pkg/detectors/newscatcher/newscatcher_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/nexmoapikey/nexmoapikey.go b/pkg/detectors/nexmoapikey/nexmoapikey.go index 892ae6651be5..378a68c0a60b 100644 --- a/pkg/detectors/nexmoapikey/nexmoapikey.go +++ b/pkg/detectors/nexmoapikey/nexmoapikey.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify NexmoApiKey secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) secretPat := secretPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/nexmoapikey/nexmoapikey_test.go b/pkg/detectors/nexmoapikey/nexmoapikey_test.go index 40f145b55e25..acc44d02cd98 100644 --- a/pkg/detectors/nexmoapikey/nexmoapikey_test.go +++ b/pkg/detectors/nexmoapikey/nexmoapikey_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/nftport/nftport.go b/pkg/detectors/nftport/nftport.go index 6bc019268132..db5355743dd1 100644 --- a/pkg/detectors/nftport/nftport.go +++ b/pkg/detectors/nftport/nftport.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Nftport secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/nftport/nftport_test.go b/pkg/detectors/nftport/nftport_test.go index 5e4d2dc50510..0cd0d4a7d19c 100644 --- a/pkg/detectors/nftport/nftport_test.go +++ b/pkg/detectors/nftport/nftport_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/ngc/ngc.go b/pkg/detectors/ngc/ngc.go index 6d7c273a1189..6469f1584450 100644 --- a/pkg/detectors/ngc/ngc.go +++ b/pkg/detectors/ngc/ngc.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify NGC secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat1.FindAllStringSubmatch(dataStr, -1) for _, match := range matches { diff --git a/pkg/detectors/ngc/ngc_test.go b/pkg/detectors/ngc/ngc_test.go index 647c1c055994..b3397215f9b7 100644 --- a/pkg/detectors/ngc/ngc_test.go +++ b/pkg/detectors/ngc/ngc_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/ngrok/ngrok.go b/pkg/detectors/ngrok/ngrok.go index eb599f3e033b..d6e0f122f84d 100644 --- a/pkg/detectors/ngrok/ngrok.go +++ b/pkg/detectors/ngrok/ngrok.go @@ -16,12 +16,11 @@ type Scanner struct { client *http.Client } - var _ detectors.Detector = (*Scanner)(nil) var ( defaultClient = common.SaneHttpClient() - + keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"ngrok"}) + `\b2[a-zA-Z0-9]{26}_\d[a-zA-Z0-9]{20}\b`) ) @@ -30,7 +29,7 @@ func (s Scanner) Keywords() []string { } func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/nicereply/nicereply.go b/pkg/detectors/nicereply/nicereply.go index 6d9865507df6..9f5c01a06f86 100644 --- a/pkg/detectors/nicereply/nicereply.go +++ b/pkg/detectors/nicereply/nicereply.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Nicereply secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/nicereply/nicereply_test.go b/pkg/detectors/nicereply/nicereply_test.go index 5111a81cfd2f..616de0f9a855 100644 --- a/pkg/detectors/nicereply/nicereply_test.go +++ b/pkg/detectors/nicereply/nicereply_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/nightfall/nightfall.go b/pkg/detectors/nightfall/nightfall.go index ab7a853bf5ff..89807c3c7b76 100644 --- a/pkg/detectors/nightfall/nightfall.go +++ b/pkg/detectors/nightfall/nightfall.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Nightfall secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/nightfall/nightfall_test.go b/pkg/detectors/nightfall/nightfall_test.go index b3f88c6a3539..963bd25294b0 100644 --- a/pkg/detectors/nightfall/nightfall_test.go +++ b/pkg/detectors/nightfall/nightfall_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/nimble/nimble.go b/pkg/detectors/nimble/nimble.go index 5e2eff731f18..4859219c7906 100644 --- a/pkg/detectors/nimble/nimble.go +++ b/pkg/detectors/nimble/nimble.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Nimble secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/nimble/nimble_test.go b/pkg/detectors/nimble/nimble_test.go index 0803942cb672..0fe36853de8e 100644 --- a/pkg/detectors/nimble/nimble_test.go +++ b/pkg/detectors/nimble/nimble_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/nitro/nitro.go b/pkg/detectors/nitro/nitro.go index d5b6ea07f54f..dca38bbcdf6a 100644 --- a/pkg/detectors/nitro/nitro.go +++ b/pkg/detectors/nitro/nitro.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Nitro secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/nitro/nitro_test.go b/pkg/detectors/nitro/nitro_test.go index 96a41dafdb38..214415838731 100644 --- a/pkg/detectors/nitro/nitro_test.go +++ b/pkg/detectors/nitro/nitro_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/noticeable/noticeable.go b/pkg/detectors/noticeable/noticeable.go index 63858d7412f0..98f2746f103b 100644 --- a/pkg/detectors/noticeable/noticeable.go +++ b/pkg/detectors/noticeable/noticeable.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Noticeable secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/noticeable/noticeable_test.go b/pkg/detectors/noticeable/noticeable_test.go index 97aaf32b8d86..b92f9607c69f 100644 --- a/pkg/detectors/noticeable/noticeable_test.go +++ b/pkg/detectors/noticeable/noticeable_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/notion/notion.go b/pkg/detectors/notion/notion.go index 9edb7a84e7f3..1f4e14705353 100644 --- a/pkg/detectors/notion/notion.go +++ b/pkg/detectors/notion/notion.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Notion secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/notion/notion_test.go b/pkg/detectors/notion/notion_test.go index e4947d90be54..5a8b0f14fe57 100644 --- a/pkg/detectors/notion/notion_test.go +++ b/pkg/detectors/notion/notion_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/nozbeteams/nozbeteams.go b/pkg/detectors/nozbeteams/nozbeteams.go index 9b1d5402954e..03c8c2ea37a9 100644 --- a/pkg/detectors/nozbeteams/nozbeteams.go +++ b/pkg/detectors/nozbeteams/nozbeteams.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify NozbeTeams secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/npmtoken/npmtoken.go b/pkg/detectors/npmtoken/npmtoken.go index 2a624045f55d..bbc43b795be2 100644 --- a/pkg/detectors/npmtoken/npmtoken.go +++ b/pkg/detectors/npmtoken/npmtoken.go @@ -35,7 +35,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify NpmToken secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) for _, match := range matches { if len(match) != 2 { diff --git a/pkg/detectors/npmtoken/npmtoken_test.go b/pkg/detectors/npmtoken/npmtoken_test.go index a2d2b2357366..a3ccd2f6ca27 100644 --- a/pkg/detectors/npmtoken/npmtoken_test.go +++ b/pkg/detectors/npmtoken/npmtoken_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/npmtokenv2/npmtokenv2.go b/pkg/detectors/npmtokenv2/npmtokenv2.go index 56b2ef036e2a..0682bfdf94ac 100644 --- a/pkg/detectors/npmtokenv2/npmtokenv2.go +++ b/pkg/detectors/npmtokenv2/npmtokenv2.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify NpmTokenV2 secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/npmtokenv2/npmtokenv2_test.go b/pkg/detectors/npmtokenv2/npmtokenv2_test.go index 0a9d285c8d2e..7af366cca7d8 100644 --- a/pkg/detectors/npmtokenv2/npmtokenv2_test.go +++ b/pkg/detectors/npmtokenv2/npmtokenv2_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/nugetapikey/nugetapikey.go b/pkg/detectors/nugetapikey/nugetapikey.go index e598b0db4d7d..8deeeb055f5b 100644 --- a/pkg/detectors/nugetapikey/nugetapikey.go +++ b/pkg/detectors/nugetapikey/nugetapikey.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Nugetapikey secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) @@ -56,7 +56,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result res, err := client.Do(req) if err == nil { defer res.Body.Close() - // we can either match on response code "400" or "Bad Request" response + // we can either match on response code "400" or "Bad Request" response if res.StatusCode == 400 { s1.Verified = true } else { diff --git a/pkg/detectors/numverify/numverify.go b/pkg/detectors/numverify/numverify.go index 2eb1f3319916..e58c5eca7101 100644 --- a/pkg/detectors/numverify/numverify.go +++ b/pkg/detectors/numverify/numverify.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Numverify secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) for _, match := range matches { if len(match) != 2 { diff --git a/pkg/detectors/numverify/numverify_test.go b/pkg/detectors/numverify/numverify_test.go index 7de6d15bf6ce..41a22cc6ca0f 100644 --- a/pkg/detectors/numverify/numverify_test.go +++ b/pkg/detectors/numverify/numverify_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/nutritionix/nutritionix.go b/pkg/detectors/nutritionix/nutritionix.go index 0c3a9c772d82..f710915d489a 100644 --- a/pkg/detectors/nutritionix/nutritionix.go +++ b/pkg/detectors/nutritionix/nutritionix.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Nutritionix secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/nutritionix/nutritionix_test.go b/pkg/detectors/nutritionix/nutritionix_test.go index 8e37e878e5aa..f60ac283627a 100644 --- a/pkg/detectors/nutritionix/nutritionix_test.go +++ b/pkg/detectors/nutritionix/nutritionix_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/nylas/nylas.go b/pkg/detectors/nylas/nylas.go index ec564b446530..d3e282e32579 100644 --- a/pkg/detectors/nylas/nylas.go +++ b/pkg/detectors/nylas/nylas.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Nylas secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/nylas/nylas_test.go b/pkg/detectors/nylas/nylas_test.go index 0e64d99d6709..327b27cb8d72 100644 --- a/pkg/detectors/nylas/nylas_test.go +++ b/pkg/detectors/nylas/nylas_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/nytimes/nytimes.go b/pkg/detectors/nytimes/nytimes.go index e992ce304b6b..3ad117d33a08 100644 --- a/pkg/detectors/nytimes/nytimes.go +++ b/pkg/detectors/nytimes/nytimes.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Nytimes secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/nytimes/nytimes_test.go b/pkg/detectors/nytimes/nytimes_test.go index 29c9f5c9bcb9..f337c19db967 100644 --- a/pkg/detectors/nytimes/nytimes_test.go +++ b/pkg/detectors/nytimes/nytimes_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/oanda/oanda.go b/pkg/detectors/oanda/oanda.go index 051208189cad..9857bd68a934 100644 --- a/pkg/detectors/oanda/oanda.go +++ b/pkg/detectors/oanda/oanda.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Oanda secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/oanda/oanda_test.go b/pkg/detectors/oanda/oanda_test.go index adbbee09f7b6..adac768ea9ee 100644 --- a/pkg/detectors/oanda/oanda_test.go +++ b/pkg/detectors/oanda/oanda_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/okta/okta_test.go b/pkg/detectors/okta/okta_test.go index bcf2612219ae..6e404b0efc27 100644 --- a/pkg/detectors/okta/okta_test.go +++ b/pkg/detectors/okta/okta_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" diff --git a/pkg/detectors/omnisend/omnisend.go b/pkg/detectors/omnisend/omnisend.go index 7bd2dcf8000a..fcd7c9edeee6 100644 --- a/pkg/detectors/omnisend/omnisend.go +++ b/pkg/detectors/omnisend/omnisend.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Omnisend secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/onedesk/onedesk.go b/pkg/detectors/onedesk/onedesk.go index 92ab30387c86..ddab3f807193 100644 --- a/pkg/detectors/onedesk/onedesk.go +++ b/pkg/detectors/onedesk/onedesk.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Onedesk secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := emailPat.FindAllStringSubmatch(dataStr, -1) pwordMatches := pwordPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/onedesk/onedesk_test.go b/pkg/detectors/onedesk/onedesk_test.go index 1fdd5e72385a..a0143cfec57d 100644 --- a/pkg/detectors/onedesk/onedesk_test.go +++ b/pkg/detectors/onedesk/onedesk_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/onelogin/onelogin.go b/pkg/detectors/onelogin/onelogin.go index 0212a06813f1..426504522be3 100644 --- a/pkg/detectors/onelogin/onelogin.go +++ b/pkg/detectors/onelogin/onelogin.go @@ -8,6 +8,7 @@ import ( "strings" "time" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" ) @@ -36,7 +37,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Onelogin secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) for _, clientID := range oauthClientIDPat.FindAllStringSubmatch(dataStr, -1) { if len(clientID) != 2 { diff --git a/pkg/detectors/onelogin/onelogin_test.go b/pkg/detectors/onelogin/onelogin_test.go index 39b2897c76a2..5f128ba24755 100644 --- a/pkg/detectors/onelogin/onelogin_test.go +++ b/pkg/detectors/onelogin/onelogin_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" diff --git a/pkg/detectors/onepagecrm/onepagecrm.go b/pkg/detectors/onepagecrm/onepagecrm.go index 61f57f097c4d..dcea08deca63 100644 --- a/pkg/detectors/onepagecrm/onepagecrm.go +++ b/pkg/detectors/onepagecrm/onepagecrm.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify OnepageCRM secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/onepagecrm/onepagecrm_test.go b/pkg/detectors/onepagecrm/onepagecrm_test.go index 357d062d0959..92b994c4e718 100644 --- a/pkg/detectors/onepagecrm/onepagecrm_test.go +++ b/pkg/detectors/onepagecrm/onepagecrm_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/onesignal/onesignal.go b/pkg/detectors/onesignal/onesignal.go index d9ebefa664e7..02d05643a2f6 100644 --- a/pkg/detectors/onesignal/onesignal.go +++ b/pkg/detectors/onesignal/onesignal.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Onesignal secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/onesignal/onesignal_test.go b/pkg/detectors/onesignal/onesignal_test.go index 30d1508a04f6..a7d6889f0e34 100644 --- a/pkg/detectors/onesignal/onesignal_test.go +++ b/pkg/detectors/onesignal/onesignal_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/onwaterio/onwaterio.go b/pkg/detectors/onwaterio/onwaterio.go index 53182c184c29..1b3be05fba80 100644 --- a/pkg/detectors/onwaterio/onwaterio.go +++ b/pkg/detectors/onwaterio/onwaterio.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify OnWaterIO secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/onwaterio/onwaterio_test.go b/pkg/detectors/onwaterio/onwaterio_test.go index c98fce44bc1d..6e0af920ebfe 100644 --- a/pkg/detectors/onwaterio/onwaterio_test.go +++ b/pkg/detectors/onwaterio/onwaterio_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/oopspam/oopspam.go b/pkg/detectors/oopspam/oopspam.go index 3cbf45060844..38140d762bfc 100644 --- a/pkg/detectors/oopspam/oopspam.go +++ b/pkg/detectors/oopspam/oopspam.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify OOPSpam secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/oopspam/oopspam_test.go b/pkg/detectors/oopspam/oopspam_test.go index 5c5a32d4eddf..c7c57a7b6699 100644 --- a/pkg/detectors/oopspam/oopspam_test.go +++ b/pkg/detectors/oopspam/oopspam_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/openai/openai.go b/pkg/detectors/openai/openai.go index c658f6f84a10..1e78ac59d2a7 100644 --- a/pkg/detectors/openai/openai.go +++ b/pkg/detectors/openai/openai.go @@ -45,7 +45,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify OpenAI secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/openai/openai_test.go b/pkg/detectors/openai/openai_test.go index 2fda86e467c8..1c161067a8bb 100644 --- a/pkg/detectors/openai/openai_test.go +++ b/pkg/detectors/openai/openai_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" diff --git a/pkg/detectors/opencagedata/opencagedata.go b/pkg/detectors/opencagedata/opencagedata.go index 7631891490a5..0c2a6795086d 100644 --- a/pkg/detectors/opencagedata/opencagedata.go +++ b/pkg/detectors/opencagedata/opencagedata.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify OpenCageData secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/opencagedata/opencagedata_test.go b/pkg/detectors/opencagedata/opencagedata_test.go index ed11edcd25b3..b3d745c1a5a5 100644 --- a/pkg/detectors/opencagedata/opencagedata_test.go +++ b/pkg/detectors/opencagedata/opencagedata_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/opengraphr/opengraphr.go b/pkg/detectors/opengraphr/opengraphr.go index fabd0b8a8029..e54ec01cf6bd 100644 --- a/pkg/detectors/opengraphr/opengraphr.go +++ b/pkg/detectors/opengraphr/opengraphr.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Opengraphr secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/openuv/openuv.go b/pkg/detectors/openuv/openuv.go index 02981b0a35fd..dfa7f6089d65 100644 --- a/pkg/detectors/openuv/openuv.go +++ b/pkg/detectors/openuv/openuv.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Openuv secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/openuv/openuv_test.go b/pkg/detectors/openuv/openuv_test.go index e1ff7bf380b3..31bdfa32714b 100644 --- a/pkg/detectors/openuv/openuv_test.go +++ b/pkg/detectors/openuv/openuv_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/openvpn/openvpn.go b/pkg/detectors/openvpn/openvpn.go index 7a16304b21d4..81be325e4c00 100644 --- a/pkg/detectors/openvpn/openvpn.go +++ b/pkg/detectors/openvpn/openvpn.go @@ -25,8 +25,7 @@ var ( clientIDPat = regexp.MustCompile(detectors.PrefixRegex([]string{"openvpn"}) + `\b([A-Za-z0-9-]{3,40}\.[A-Za-z0-9-]{3,40})\b`) clientSecretPat = regexp.MustCompile(`\b([a-zA-Z0-9_-]{64,})\b`) - domainPat = regexp.MustCompile(`\b(https?://[A-Za-z0-9-]+\.api\.openvpn\.com)\b`) - + domainPat = regexp.MustCompile(`\b(https?://[A-Za-z0-9-]+\.api\.openvpn\.com)\b`) ) // Keywords are used for efficiently pre-filtering chunks. @@ -37,12 +36,12 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Openvpn secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) domainMatches := domainPat.FindAllStringSubmatch(dataStr, -1) clientIdMatches := clientIDPat.FindAllStringSubmatch(dataStr, -1) clientSecretMatches := clientSecretPat.FindAllStringSubmatch(dataStr, -1) - + for _, clientIdMatch := range clientIdMatches { clientIDRes := strings.TrimSpace(clientIdMatch[1]) for _, clientSecretMatch := range clientSecretMatches { @@ -65,7 +64,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result payload := strings.NewReader("grant_type=client_credentials") // OpenVPN API is in beta, We'll have to update the API endpoint once // Docs: https://openvpn.net/cloud-docs/developer/creating-api-credentials.html - req, err := http.NewRequestWithContext(ctx, "POST", domainRes + "/api/beta/oauth/token", payload) + req, err := http.NewRequestWithContext(ctx, "POST", domainRes+"/api/beta/oauth/token", payload) if err != nil { continue } @@ -97,8 +96,6 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } } - - } return results, nil diff --git a/pkg/detectors/openweather/openweather.go b/pkg/detectors/openweather/openweather.go index 172e0eac0707..6ad5b052f6d8 100644 --- a/pkg/detectors/openweather/openweather.go +++ b/pkg/detectors/openweather/openweather.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify OpenWeather secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/openweather/openweather_test.go b/pkg/detectors/openweather/openweather_test.go index d15a14d56f64..474b3955fb01 100644 --- a/pkg/detectors/openweather/openweather_test.go +++ b/pkg/detectors/openweather/openweather_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/opsgenie/opsgenie.go b/pkg/detectors/opsgenie/opsgenie.go index 2911a5357572..c60c7ba8be6b 100644 --- a/pkg/detectors/opsgenie/opsgenie.go +++ b/pkg/detectors/opsgenie/opsgenie.go @@ -36,7 +36,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Opsgenie secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/opsgenie/opsgenie_test.go b/pkg/detectors/opsgenie/opsgenie_test.go index 96aae8edf219..5d10284d516f 100644 --- a/pkg/detectors/opsgenie/opsgenie_test.go +++ b/pkg/detectors/opsgenie/opsgenie_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/optimizely/optimizely.go b/pkg/detectors/optimizely/optimizely.go index f5abf131b121..c996d8ff0b1b 100644 --- a/pkg/detectors/optimizely/optimizely.go +++ b/pkg/detectors/optimizely/optimizely.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Optimizely secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/optimizely/optimizely_test.go b/pkg/detectors/optimizely/optimizely_test.go index 02050ad82c28..1d40fea181fb 100644 --- a/pkg/detectors/optimizely/optimizely_test.go +++ b/pkg/detectors/optimizely/optimizely_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/overloop/overloop.go b/pkg/detectors/overloop/overloop.go index 2b39fc38f87c..d488656a0c7e 100644 --- a/pkg/detectors/overloop/overloop.go +++ b/pkg/detectors/overloop/overloop.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Overloop secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/overloop/overloop_test.go b/pkg/detectors/overloop/overloop_test.go index e4b2b38939a5..fa0defddc6a8 100644 --- a/pkg/detectors/overloop/overloop_test.go +++ b/pkg/detectors/overloop/overloop_test.go @@ -6,11 +6,12 @@ package overloop import ( "context" "fmt" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "testing" "time" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/owlbot/owlbot.go b/pkg/detectors/owlbot/owlbot.go index d6cad3e84aee..52edf66db97e 100644 --- a/pkg/detectors/owlbot/owlbot.go +++ b/pkg/detectors/owlbot/owlbot.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Owlbot secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/owlbot/owlbot_test.go b/pkg/detectors/owlbot/owlbot_test.go index cb4fc3be699a..c04f7bd9dfbc 100644 --- a/pkg/detectors/owlbot/owlbot_test.go +++ b/pkg/detectors/owlbot/owlbot_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/packagecloud/packagecloud.go b/pkg/detectors/packagecloud/packagecloud.go index d5f1b496a69a..fb4396fa2575 100644 --- a/pkg/detectors/packagecloud/packagecloud.go +++ b/pkg/detectors/packagecloud/packagecloud.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify PackageCloud secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/packagecloud/packagecloud_test.go b/pkg/detectors/packagecloud/packagecloud_test.go index ca8dc5c7972b..adf2a294f34c 100644 --- a/pkg/detectors/packagecloud/packagecloud_test.go +++ b/pkg/detectors/packagecloud/packagecloud_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/pagerdutyapikey/pagerdutyapikey.go b/pkg/detectors/pagerdutyapikey/pagerdutyapikey.go index f3dbcd8753f1..d39c1c4d11aa 100644 --- a/pkg/detectors/pagerdutyapikey/pagerdutyapikey.go +++ b/pkg/detectors/pagerdutyapikey/pagerdutyapikey.go @@ -35,7 +35,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify PagerDutyApiKey secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) for _, match := range matches { diff --git a/pkg/detectors/pagerdutyapikey/pagerdutyapikey_test.go b/pkg/detectors/pagerdutyapikey/pagerdutyapikey_test.go index 5f16180ed0c0..972da6d9f52b 100644 --- a/pkg/detectors/pagerdutyapikey/pagerdutyapikey_test.go +++ b/pkg/detectors/pagerdutyapikey/pagerdutyapikey_test.go @@ -11,6 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" diff --git a/pkg/detectors/pandadoc/pandadoc.go b/pkg/detectors/pandadoc/pandadoc.go index 06ca1c7f9429..8e648f109796 100644 --- a/pkg/detectors/pandadoc/pandadoc.go +++ b/pkg/detectors/pandadoc/pandadoc.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Pandadoc secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/pandadoc/pandadoc_test.go b/pkg/detectors/pandadoc/pandadoc_test.go index 52f140a88ea0..564239fcf6db 100644 --- a/pkg/detectors/pandadoc/pandadoc_test.go +++ b/pkg/detectors/pandadoc/pandadoc_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/pandascore/pandascore.go b/pkg/detectors/pandascore/pandascore.go index d9eec6a7add7..74dc7f4ff584 100644 --- a/pkg/detectors/pandascore/pandascore.go +++ b/pkg/detectors/pandascore/pandascore.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify PandaScore secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/paperform/paperform.go b/pkg/detectors/paperform/paperform.go index 2bf4fc5da0d4..59344ded7066 100644 --- a/pkg/detectors/paperform/paperform.go +++ b/pkg/detectors/paperform/paperform.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Paperform secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/paperform/paperform_test.go b/pkg/detectors/paperform/paperform_test.go index 2b3de57e298f..5c0456279792 100644 --- a/pkg/detectors/paperform/paperform_test.go +++ b/pkg/detectors/paperform/paperform_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/paralleldots/paralleldots.go b/pkg/detectors/paralleldots/paralleldots.go index 74e79626bb91..6ef57f5dad0e 100644 --- a/pkg/detectors/paralleldots/paralleldots.go +++ b/pkg/detectors/paralleldots/paralleldots.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Paralleldots secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/paralleldots/paralleldots_test.go b/pkg/detectors/paralleldots/paralleldots_test.go index e5931de4d773..ec149929bbc5 100644 --- a/pkg/detectors/paralleldots/paralleldots_test.go +++ b/pkg/detectors/paralleldots/paralleldots_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/parsehub/parsehub.go b/pkg/detectors/parsehub/parsehub.go index e82ec148f477..fbf54f8a5ff2 100644 --- a/pkg/detectors/parsehub/parsehub.go +++ b/pkg/detectors/parsehub/parsehub.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Parsehub secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/parsehub/parsehub_test.go b/pkg/detectors/parsehub/parsehub_test.go index 0e3cd456016c..cdd66cc506a0 100644 --- a/pkg/detectors/parsehub/parsehub_test.go +++ b/pkg/detectors/parsehub/parsehub_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/parsers/parsers.go b/pkg/detectors/parsers/parsers.go index 9d890a8be108..aae18160d869 100644 --- a/pkg/detectors/parsers/parsers.go +++ b/pkg/detectors/parsers/parsers.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Parsers secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/parsers/parsers_test.go b/pkg/detectors/parsers/parsers_test.go index a396b9ef38ea..a72005d9e275 100644 --- a/pkg/detectors/parsers/parsers_test.go +++ b/pkg/detectors/parsers/parsers_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/parseur/parseur.go b/pkg/detectors/parseur/parseur.go index 4cad1da9dfcd..e5442fdfe6dd 100644 --- a/pkg/detectors/parseur/parseur.go +++ b/pkg/detectors/parseur/parseur.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Parseur secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/parseur/parseur_test.go b/pkg/detectors/parseur/parseur_test.go index fcc9d0c3666c..64b29589e166 100644 --- a/pkg/detectors/parseur/parseur_test.go +++ b/pkg/detectors/parseur/parseur_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/partnerstack/partnerstack.go b/pkg/detectors/partnerstack/partnerstack.go index ba84258a9563..6de0391d4eaf 100644 --- a/pkg/detectors/partnerstack/partnerstack.go +++ b/pkg/detectors/partnerstack/partnerstack.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Partnerstack secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/partnerstack/partnerstack_test.go b/pkg/detectors/partnerstack/partnerstack_test.go index e5bcfb7770b7..23c36a45d529 100644 --- a/pkg/detectors/partnerstack/partnerstack_test.go +++ b/pkg/detectors/partnerstack/partnerstack_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/pastebin/pastebin.go b/pkg/detectors/pastebin/pastebin.go index 2911c8719587..c87b5e506032 100644 --- a/pkg/detectors/pastebin/pastebin.go +++ b/pkg/detectors/pastebin/pastebin.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Pastebin secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/pastebin/pastebin_test.go b/pkg/detectors/pastebin/pastebin_test.go index e7aca2670088..5363f4466462 100644 --- a/pkg/detectors/pastebin/pastebin_test.go +++ b/pkg/detectors/pastebin/pastebin_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/paydirtapp/paydirtapp.go b/pkg/detectors/paydirtapp/paydirtapp.go index 361054591649..4e99312ff6b6 100644 --- a/pkg/detectors/paydirtapp/paydirtapp.go +++ b/pkg/detectors/paydirtapp/paydirtapp.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify paydirtapp secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/paydirtapp/paydirtapp_test.go b/pkg/detectors/paydirtapp/paydirtapp_test.go index 950cab1a1cdc..82ad77bc0546 100644 --- a/pkg/detectors/paydirtapp/paydirtapp_test.go +++ b/pkg/detectors/paydirtapp/paydirtapp_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/paymoapp/paymoapp.go b/pkg/detectors/paymoapp/paymoapp.go index 28ba45d9e71c..7ed742ac6beb 100644 --- a/pkg/detectors/paymoapp/paymoapp.go +++ b/pkg/detectors/paymoapp/paymoapp.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Paymoapp secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/paymoapp/paymoapp_test.go b/pkg/detectors/paymoapp/paymoapp_test.go index 371bda62b1a3..198f12def759 100644 --- a/pkg/detectors/paymoapp/paymoapp_test.go +++ b/pkg/detectors/paymoapp/paymoapp_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/paymongo/paymongo.go b/pkg/detectors/paymongo/paymongo.go index 5d5d4fd12581..96070ba5a1e0 100644 --- a/pkg/detectors/paymongo/paymongo.go +++ b/pkg/detectors/paymongo/paymongo.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Paymongo secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/paymongo/paymongo_test.go b/pkg/detectors/paymongo/paymongo_test.go index cd7daf81e269..f28400739012 100644 --- a/pkg/detectors/paymongo/paymongo_test.go +++ b/pkg/detectors/paymongo/paymongo_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/paypaloauth/paypaloauth.go b/pkg/detectors/paypaloauth/paypaloauth.go index 774d4fba0eef..892f690f0162 100644 --- a/pkg/detectors/paypaloauth/paypaloauth.go +++ b/pkg/detectors/paypaloauth/paypaloauth.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify PaypalOauth secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idmatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/paypaloauth/paypaloauth_test.go b/pkg/detectors/paypaloauth/paypaloauth_test.go index f2c8e02630ae..2b7a3ec921fa 100644 --- a/pkg/detectors/paypaloauth/paypaloauth_test.go +++ b/pkg/detectors/paypaloauth/paypaloauth_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/paystack/paystack.go b/pkg/detectors/paystack/paystack.go index 0f338b4bd010..250fb144bc7d 100644 --- a/pkg/detectors/paystack/paystack.go +++ b/pkg/detectors/paystack/paystack.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Paystack secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/paystack/paystack_test.go b/pkg/detectors/paystack/paystack_test.go index 19d5531aeaf7..1044bb7ebb8a 100644 --- a/pkg/detectors/paystack/paystack_test.go +++ b/pkg/detectors/paystack/paystack_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/pdflayer/pdflayer.go b/pkg/detectors/pdflayer/pdflayer.go index e82fc0c35810..5e3b92afd516 100644 --- a/pkg/detectors/pdflayer/pdflayer.go +++ b/pkg/detectors/pdflayer/pdflayer.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify PdfLayer secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/pdflayer/pdflayer_test.go b/pkg/detectors/pdflayer/pdflayer_test.go index d803ff92151b..1e7d9270da8e 100644 --- a/pkg/detectors/pdflayer/pdflayer_test.go +++ b/pkg/detectors/pdflayer/pdflayer_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/pdfshift/pdfshift.go b/pkg/detectors/pdfshift/pdfshift.go index 902a36b0095a..8fcacf3ccc07 100644 --- a/pkg/detectors/pdfshift/pdfshift.go +++ b/pkg/detectors/pdfshift/pdfshift.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify PdfShift secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/pdfshift/pdfshift_test.go b/pkg/detectors/pdfshift/pdfshift_test.go index bbddc1251efa..6c5e41440bd0 100644 --- a/pkg/detectors/pdfshift/pdfshift_test.go +++ b/pkg/detectors/pdfshift/pdfshift_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/peopledatalabs/peopledatalabs.go b/pkg/detectors/peopledatalabs/peopledatalabs.go index b5153dc0ca47..a07fb74104c3 100644 --- a/pkg/detectors/peopledatalabs/peopledatalabs.go +++ b/pkg/detectors/peopledatalabs/peopledatalabs.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify PeopleDataLabs secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/peopledatalabs/peopledatalabs_test.go b/pkg/detectors/peopledatalabs/peopledatalabs_test.go index c913f7f0493c..1190f4d2d0ac 100644 --- a/pkg/detectors/peopledatalabs/peopledatalabs_test.go +++ b/pkg/detectors/peopledatalabs/peopledatalabs_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/pepipost/pepipost.go b/pkg/detectors/pepipost/pepipost.go index b7b7983fb4f1..78bb932ec875 100644 --- a/pkg/detectors/pepipost/pepipost.go +++ b/pkg/detectors/pepipost/pepipost.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Pepipost secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/pepipost/pepipost_test.go b/pkg/detectors/pepipost/pepipost_test.go index ced4dc843769..468c3b2fd607 100644 --- a/pkg/detectors/pepipost/pepipost_test.go +++ b/pkg/detectors/pepipost/pepipost_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/percy/percy.go b/pkg/detectors/percy/percy.go index 748f31c65808..8dee58cc0c88 100644 --- a/pkg/detectors/percy/percy.go +++ b/pkg/detectors/percy/percy.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Percy secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/percy/percy_test.go b/pkg/detectors/percy/percy_test.go index aad571e5b1dd..ef7290579e39 100644 --- a/pkg/detectors/percy/percy_test.go +++ b/pkg/detectors/percy/percy_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/pinata/pinata.go b/pkg/detectors/pinata/pinata.go index de457d4526f0..8e9cb6d957dd 100644 --- a/pkg/detectors/pinata/pinata.go +++ b/pkg/detectors/pinata/pinata.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Pinata secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/pinata/pinata_test.go b/pkg/detectors/pinata/pinata_test.go index 9231cef77902..d8479c8e054f 100644 --- a/pkg/detectors/pinata/pinata_test.go +++ b/pkg/detectors/pinata/pinata_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/pipedream/pipedream.go b/pkg/detectors/pipedream/pipedream.go index 19a469fefd95..fce83a94ccd5 100644 --- a/pkg/detectors/pipedream/pipedream.go +++ b/pkg/detectors/pipedream/pipedream.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Pipedream secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/pipedrive/pipedrive.go b/pkg/detectors/pipedrive/pipedrive.go index 878f7791cbdd..1e90f6d48880 100644 --- a/pkg/detectors/pipedrive/pipedrive.go +++ b/pkg/detectors/pipedrive/pipedrive.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Pipedrive secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/pipedrive/pipedrive_test.go b/pkg/detectors/pipedrive/pipedrive_test.go index 271a4a3f0aea..31d94f604823 100644 --- a/pkg/detectors/pipedrive/pipedrive_test.go +++ b/pkg/detectors/pipedrive/pipedrive_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/pivotaltracker/pivotaltracker.go b/pkg/detectors/pivotaltracker/pivotaltracker.go index 970e9d04f46d..7eca4bdd9def 100644 --- a/pkg/detectors/pivotaltracker/pivotaltracker.go +++ b/pkg/detectors/pivotaltracker/pivotaltracker.go @@ -28,7 +28,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify PivotalTracker secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/pivotaltracker/pivotaltracker_test.go b/pkg/detectors/pivotaltracker/pivotaltracker_test.go index 5e2809a56d8e..fa9f27a9feb0 100644 --- a/pkg/detectors/pivotaltracker/pivotaltracker_test.go +++ b/pkg/detectors/pivotaltracker/pivotaltracker_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" diff --git a/pkg/detectors/pixabay/pixabay.go b/pkg/detectors/pixabay/pixabay.go index 297cbde81552..4c740da111e8 100644 --- a/pkg/detectors/pixabay/pixabay.go +++ b/pkg/detectors/pixabay/pixabay.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Pixabay secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/plaidkey/plaidkey.go b/pkg/detectors/plaidkey/plaidkey.go index e969b7992874..3e9b78ec067d 100644 --- a/pkg/detectors/plaidkey/plaidkey.go +++ b/pkg/detectors/plaidkey/plaidkey.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify PlaidKey secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/plaidkey/plaidkey_test.go b/pkg/detectors/plaidkey/plaidkey_test.go index 624c22e2f813..051753c768e8 100644 --- a/pkg/detectors/plaidkey/plaidkey_test.go +++ b/pkg/detectors/plaidkey/plaidkey_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/planetscale/planetscale.go b/pkg/detectors/planetscale/planetscale.go index 8fe238fe7f92..dd18c8465094 100644 --- a/pkg/detectors/planetscale/planetscale.go +++ b/pkg/detectors/planetscale/planetscale.go @@ -30,7 +30,7 @@ func (s Scanner) Keywords() []string { } func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) usernameMatches := usernamePat.FindAllString(dataStr, -1) passwordMatches := passwordPat.FindAllString(dataStr, -1) diff --git a/pkg/detectors/planetscaledb/planetscaledb.go b/pkg/detectors/planetscaledb/planetscaledb.go index 63355c958ee3..8f63cf4aaf5e 100644 --- a/pkg/detectors/planetscaledb/planetscaledb.go +++ b/pkg/detectors/planetscaledb/planetscaledb.go @@ -8,6 +8,7 @@ import ( "github.com/go-sql-driver/mysql" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" ) @@ -30,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Planetscaledb secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) usernameMatches := usernamePat.FindAllStringSubmatch(dataStr, -1) passwordMatches := passwordPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/planviewleankit/planviewleankit.go b/pkg/detectors/planviewleankit/planviewleankit.go index 4901a342aba0..1744343d3628 100644 --- a/pkg/detectors/planviewleankit/planviewleankit.go +++ b/pkg/detectors/planviewleankit/planviewleankit.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify PlanviewLeanKit secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) subdomainMatches := subDomainPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/planyo/planyo.go b/pkg/detectors/planyo/planyo.go index 6eba2c098c32..ec487ec970a1 100644 --- a/pkg/detectors/planyo/planyo.go +++ b/pkg/detectors/planyo/planyo.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Planyo secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/planyo/planyo_test.go b/pkg/detectors/planyo/planyo_test.go index 03730cd2f983..0a8e1bd9a3b2 100644 --- a/pkg/detectors/planyo/planyo_test.go +++ b/pkg/detectors/planyo/planyo_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/plivo/plivo.go b/pkg/detectors/plivo/plivo.go index d04a996a73e8..8bde021e4693 100644 --- a/pkg/detectors/plivo/plivo.go +++ b/pkg/detectors/plivo/plivo.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Plivo secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/plivo/plivo_test.go b/pkg/detectors/plivo/plivo_test.go index 26db005f45a3..5fd3343264bc 100644 --- a/pkg/detectors/plivo/plivo_test.go +++ b/pkg/detectors/plivo/plivo_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/podio/podio.go b/pkg/detectors/podio/podio.go index d66baa8ec128..556ca066731f 100644 --- a/pkg/detectors/podio/podio.go +++ b/pkg/detectors/podio/podio.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Podio secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/podio/podio_test.go b/pkg/detectors/podio/podio_test.go index b7a162f03239..a553cd574db7 100644 --- a/pkg/detectors/podio/podio_test.go +++ b/pkg/detectors/podio/podio_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/pollsapi/pollsapi.go b/pkg/detectors/pollsapi/pollsapi.go index f2d28e61692a..bcbe87cf6e46 100644 --- a/pkg/detectors/pollsapi/pollsapi.go +++ b/pkg/detectors/pollsapi/pollsapi.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify PollsAPI secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/pollsapi/pollsapi_test.go b/pkg/detectors/pollsapi/pollsapi_test.go index 7e28de28d7e2..651ca92fe5db 100644 --- a/pkg/detectors/pollsapi/pollsapi_test.go +++ b/pkg/detectors/pollsapi/pollsapi_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/poloniex/poloniex.go b/pkg/detectors/poloniex/poloniex.go index bf4358e111ad..2cbaba33930f 100644 --- a/pkg/detectors/poloniex/poloniex.go +++ b/pkg/detectors/poloniex/poloniex.go @@ -38,7 +38,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Poloniex secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) secretMatches := secretPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/poloniex/poloniex_test.go b/pkg/detectors/poloniex/poloniex_test.go index 22dd53d4a4aa..cfab0199c0d5 100644 --- a/pkg/detectors/poloniex/poloniex_test.go +++ b/pkg/detectors/poloniex/poloniex_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/polygon/polygon.go b/pkg/detectors/polygon/polygon.go index 5f439f370ad6..be533064e4b9 100644 --- a/pkg/detectors/polygon/polygon.go +++ b/pkg/detectors/polygon/polygon.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Polygon secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/polygon/polygon_test.go b/pkg/detectors/polygon/polygon_test.go index 3565f38e41ce..7110a19dc2f2 100644 --- a/pkg/detectors/polygon/polygon_test.go +++ b/pkg/detectors/polygon/polygon_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/portainer/portainer.go b/pkg/detectors/portainer/portainer.go index 433f90336c96..7bcd12c9a575 100644 --- a/pkg/detectors/portainer/portainer.go +++ b/pkg/detectors/portainer/portainer.go @@ -23,7 +23,7 @@ var ( defaultClient = common.SaneHttpClient() // Make sure that your group is surrounded in boundary characters such as below to reduce false positives. endpointPat = regexp.MustCompile(detectors.PrefixRegex([]string{"portainer"}) + `\b(https?:\/\/\S+(:[0-9]{4,5})?)\b`) - tokenPat = regexp.MustCompile(detectors.PrefixRegex([]string{"portainer"}) + `\b(eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9\.[0-9A-Za-z]{50,310}\.[0-9A-Z-a-z\-_]{43})\b`) + tokenPat = regexp.MustCompile(detectors.PrefixRegex([]string{"portainer"}) + `\b(eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9\.[0-9A-Za-z]{50,310}\.[0-9A-Z-a-z\-_]{43})\b`) ) // Keywords are used for efficiently pre-filtering chunks. @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Portainer secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := tokenPat.FindAllStringSubmatch(dataStr, -1) endpointMatches := endpointPat.FindAllStringSubmatch(dataStr, -1) @@ -59,7 +59,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result if client == nil { client = defaultClient } - req, err := http.NewRequestWithContext(ctx, "GET", resEndpointMatch + "/api/endpoints", nil) + req, err := http.NewRequestWithContext(ctx, "GET", resEndpointMatch+"/api/endpoints", nil) if err != nil { continue } @@ -86,7 +86,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result if len(endpointMatches) > 0 { results = append(results, s1) } - + } } diff --git a/pkg/detectors/portainertoken/portainertoken.go b/pkg/detectors/portainertoken/portainertoken.go index 9417b5a0db03..64317c67fdf0 100644 --- a/pkg/detectors/portainertoken/portainertoken.go +++ b/pkg/detectors/portainertoken/portainertoken.go @@ -22,7 +22,7 @@ var _ detectors.Detector = (*Scanner)(nil) var ( defaultClient = common.SaneHttpClient() // Make sure that your group is surrounded in boundary characters such as below to reduce false positives. - keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"portainertoken"}) + `\b(ptr_[A-Za-z0-9\/_\-+=]{20,60})`) + keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"portainertoken"}) + `\b(ptr_[A-Za-z0-9\/_\-+=]{20,60})`) endpointPat = regexp.MustCompile(detectors.PrefixRegex([]string{"portainer"}) + `\b(https?:\/\/\S+(:[0-9]{4,5})?)\b`) ) @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Portainertoken secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) endpointMatches := endpointPat.FindAllStringSubmatch(dataStr, -1) @@ -59,7 +59,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result if client == nil { client = defaultClient } - req, err := http.NewRequestWithContext(ctx, "GET", resEndpointMatch + "/api/stacks", nil) + req, err := http.NewRequestWithContext(ctx, "GET", resEndpointMatch+"/api/stacks", nil) if err != nil { continue } @@ -67,7 +67,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result req.Header.Add("X-API-Key", resMatch) res, err := client.Do(req) - + if err == nil { defer res.Body.Close() if res.StatusCode >= 200 && res.StatusCode < 300 { diff --git a/pkg/detectors/positionstack/positionstack.go b/pkg/detectors/positionstack/positionstack.go index 628a86a651e0..49509154c2b7 100644 --- a/pkg/detectors/positionstack/positionstack.go +++ b/pkg/detectors/positionstack/positionstack.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify PositionStack secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/positionstack/positionstack_test.go b/pkg/detectors/positionstack/positionstack_test.go index f7494337b072..e5fb57ff8d50 100644 --- a/pkg/detectors/positionstack/positionstack_test.go +++ b/pkg/detectors/positionstack/positionstack_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/postageapp/postageapp.go b/pkg/detectors/postageapp/postageapp.go index f47eb2bf1849..4e9f5f8b82cd 100644 --- a/pkg/detectors/postageapp/postageapp.go +++ b/pkg/detectors/postageapp/postageapp.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify PostageApp secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/postageapp/postageapp_test.go b/pkg/detectors/postageapp/postageapp_test.go index 37e7596f76cc..8f7f75a57628 100644 --- a/pkg/detectors/postageapp/postageapp_test.go +++ b/pkg/detectors/postageapp/postageapp_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/postbacks/postbacks.go b/pkg/detectors/postbacks/postbacks.go index e25a53c8010c..a6a1299fc683 100644 --- a/pkg/detectors/postbacks/postbacks.go +++ b/pkg/detectors/postbacks/postbacks.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Postbacks secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/postbacks/postbacks_test.go b/pkg/detectors/postbacks/postbacks_test.go index fd032f3f1a42..005dd2b3577d 100644 --- a/pkg/detectors/postbacks/postbacks_test.go +++ b/pkg/detectors/postbacks/postbacks_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/posthog/posthog.go b/pkg/detectors/posthog/posthog.go index 853321d6ac92..9929104c0ef4 100644 --- a/pkg/detectors/posthog/posthog.go +++ b/pkg/detectors/posthog/posthog.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify AppPosthog secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) @@ -62,7 +62,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result if res.StatusCode >= 200 && res.StatusCode < 300 { s1.Verified = true } else if res.StatusCode == 401 { - //Try EU Endpoint only if other one fails. + // Try EU Endpoint only if other one fails. res, err := client.Do(reqEU) if err == nil { defer res.Body.Close() diff --git a/pkg/detectors/posthog/posthog_test.go b/pkg/detectors/posthog/posthog_test.go index 70091659e30f..163c555518ee 100644 --- a/pkg/detectors/posthog/posthog_test.go +++ b/pkg/detectors/posthog/posthog_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/postman/postman.go b/pkg/detectors/postman/postman.go index 227071fa3153..ae12863539dc 100644 --- a/pkg/detectors/postman/postman.go +++ b/pkg/detectors/postman/postman.go @@ -36,7 +36,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Postman secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/postman/postman_test.go b/pkg/detectors/postman/postman_test.go index df7a0b402088..5924ec47f6cc 100644 --- a/pkg/detectors/postman/postman_test.go +++ b/pkg/detectors/postman/postman_test.go @@ -11,6 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/postmark/postmark.go b/pkg/detectors/postmark/postmark.go index 16b64224f39f..ea771b46c0b4 100644 --- a/pkg/detectors/postmark/postmark.go +++ b/pkg/detectors/postmark/postmark.go @@ -30,7 +30,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Postmark secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/powrbot/powrbot.go b/pkg/detectors/powrbot/powrbot.go index f4f90ec1b078..70339541d472 100644 --- a/pkg/detectors/powrbot/powrbot.go +++ b/pkg/detectors/powrbot/powrbot.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Powrbot secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/powrbot/powrbot_test.go b/pkg/detectors/powrbot/powrbot_test.go index 0b7b184ab8c5..739fac922b54 100644 --- a/pkg/detectors/powrbot/powrbot_test.go +++ b/pkg/detectors/powrbot/powrbot_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/prefect/prefect.go b/pkg/detectors/prefect/prefect.go index cd7eaad91d49..2da4e9fda3bc 100644 --- a/pkg/detectors/prefect/prefect.go +++ b/pkg/detectors/prefect/prefect.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Prefect secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/prefect/prefect_test.go b/pkg/detectors/prefect/prefect_test.go index d748c86deb28..9b5c04835ddc 100644 --- a/pkg/detectors/prefect/prefect_test.go +++ b/pkg/detectors/prefect/prefect_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/privacy/privacy.go b/pkg/detectors/privacy/privacy.go index 7b030232b304..e895dd43dcdd 100644 --- a/pkg/detectors/privacy/privacy.go +++ b/pkg/detectors/privacy/privacy.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Privacy secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/privacy/privacy_test.go b/pkg/detectors/privacy/privacy_test.go index b520577494c2..e962b50642bc 100644 --- a/pkg/detectors/privacy/privacy_test.go +++ b/pkg/detectors/privacy/privacy_test.go @@ -6,11 +6,12 @@ package privacy import ( "context" "fmt" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "testing" "time" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/privatekey/privatekey.go b/pkg/detectors/privatekey/privatekey.go index eb4fe6dfa13b..01c1f2b6728d 100644 --- a/pkg/detectors/privatekey/privatekey.go +++ b/pkg/detectors/privatekey/privatekey.go @@ -10,10 +10,11 @@ import ( "time" "github.com/AzureAD/microsoft-authentication-library-for-go/apps/errors" + "golang.org/x/crypto/ssh" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" - "golang.org/x/crypto/ssh" ) type Scanner struct { @@ -38,7 +39,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Privatekey secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) ([]detectors.Result, error) { results := []detectors.Result{} - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllString(dataStr, -1) diff --git a/pkg/detectors/privatekey/privatekey_test.go b/pkg/detectors/privatekey/privatekey_test.go index 4fae4587cb60..371fa6c3be56 100644 --- a/pkg/detectors/privatekey/privatekey_test.go +++ b/pkg/detectors/privatekey/privatekey_test.go @@ -12,6 +12,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" diff --git a/pkg/detectors/privatekey/ssh_test.go b/pkg/detectors/privatekey/ssh_test.go index 9dbb6bd6f31d..63eb0d459e0b 100644 --- a/pkg/detectors/privatekey/ssh_test.go +++ b/pkg/detectors/privatekey/ssh_test.go @@ -5,8 +5,9 @@ import ( "testing" "time" - "github.com/trufflesecurity/trufflehog/v3/pkg/common" "golang.org/x/crypto/ssh" + + "github.com/trufflesecurity/trufflehog/v3/pkg/common" ) func TestFirstResponseFromSSH(t *testing.T) { diff --git a/pkg/detectors/prodpad/prodpad.go b/pkg/detectors/prodpad/prodpad.go index eaa10d1e4197..51e19c4eaa66 100644 --- a/pkg/detectors/prodpad/prodpad.go +++ b/pkg/detectors/prodpad/prodpad.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Prodpad secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/prodpad/prodpad_test.go b/pkg/detectors/prodpad/prodpad_test.go index 80fd2a5e734c..323a417febc3 100644 --- a/pkg/detectors/prodpad/prodpad_test.go +++ b/pkg/detectors/prodpad/prodpad_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/prospectcrm/prospectcrm.go b/pkg/detectors/prospectcrm/prospectcrm.go index 46245f5e5720..4bf146c2dfba 100644 --- a/pkg/detectors/prospectcrm/prospectcrm.go +++ b/pkg/detectors/prospectcrm/prospectcrm.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ProspectCRM secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/prospectcrm/prospectcrm_test.go b/pkg/detectors/prospectcrm/prospectcrm_test.go index af0f8f0fb81f..c612bba97b83 100644 --- a/pkg/detectors/prospectcrm/prospectcrm_test.go +++ b/pkg/detectors/prospectcrm/prospectcrm_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/protocolsio/protocolsio.go b/pkg/detectors/protocolsio/protocolsio.go index 60ebe28573ed..a516da146527 100644 --- a/pkg/detectors/protocolsio/protocolsio.go +++ b/pkg/detectors/protocolsio/protocolsio.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ProtocolsIO secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/protocolsio/protocolsio_test.go b/pkg/detectors/protocolsio/protocolsio_test.go index 495d2218f323..9a086ba8e561 100644 --- a/pkg/detectors/protocolsio/protocolsio_test.go +++ b/pkg/detectors/protocolsio/protocolsio_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/proxycrawl/proxycrawl.go b/pkg/detectors/proxycrawl/proxycrawl.go index 9cd7b522cbdd..710272f24ade 100644 --- a/pkg/detectors/proxycrawl/proxycrawl.go +++ b/pkg/detectors/proxycrawl/proxycrawl.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ProxyCrawl secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/proxycrawl/proxycrawl_test.go b/pkg/detectors/proxycrawl/proxycrawl_test.go index 7eea9e70aaa9..807509e44e90 100644 --- a/pkg/detectors/proxycrawl/proxycrawl_test.go +++ b/pkg/detectors/proxycrawl/proxycrawl_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/pubnubpublishkey/pubnubpublishkey.go b/pkg/detectors/pubnubpublishkey/pubnubpublishkey.go index f83296d940a1..b4b19b346501 100644 --- a/pkg/detectors/pubnubpublishkey/pubnubpublishkey.go +++ b/pkg/detectors/pubnubpublishkey/pubnubpublishkey.go @@ -35,7 +35,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify PubNubPublishKey secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := pubPat.FindAllStringSubmatch(dataStr, -1) subMatches := subPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/pubnubsubscriptionkey/pubnubsubscriptionkey.go b/pkg/detectors/pubnubsubscriptionkey/pubnubsubscriptionkey.go index 2229bb5248f2..ad90a7474613 100644 --- a/pkg/detectors/pubnubsubscriptionkey/pubnubsubscriptionkey.go +++ b/pkg/detectors/pubnubsubscriptionkey/pubnubsubscriptionkey.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify PubNubSubscriptionKey secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/pubnubsubscriptionkey/pubnubsubscriptionkey_test.go b/pkg/detectors/pubnubsubscriptionkey/pubnubsubscriptionkey_test.go index bbeac7afb1cc..00dacd267c85 100644 --- a/pkg/detectors/pubnubsubscriptionkey/pubnubsubscriptionkey_test.go +++ b/pkg/detectors/pubnubsubscriptionkey/pubnubsubscriptionkey_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/pulumi/pulumi.go b/pkg/detectors/pulumi/pulumi.go index ce098fb2b5bf..e2b3504b815c 100644 --- a/pkg/detectors/pulumi/pulumi.go +++ b/pkg/detectors/pulumi/pulumi.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Pulumi secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/pulumi/pulumi_test.go b/pkg/detectors/pulumi/pulumi_test.go index 2276bddcfd20..87a8a908acf0 100644 --- a/pkg/detectors/pulumi/pulumi_test.go +++ b/pkg/detectors/pulumi/pulumi_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/purestake/purestake.go b/pkg/detectors/purestake/purestake.go index c38db8f30b9c..8dcdca579de4 100644 --- a/pkg/detectors/purestake/purestake.go +++ b/pkg/detectors/purestake/purestake.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify PureStake secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/purestake/purestake_test.go b/pkg/detectors/purestake/purestake_test.go index 90c408e4262c..4149c40fd723 100644 --- a/pkg/detectors/purestake/purestake_test.go +++ b/pkg/detectors/purestake/purestake_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/pushbulletapikey/pushbulletapikey.go b/pkg/detectors/pushbulletapikey/pushbulletapikey.go index e5e30f870ce9..6fa51468c9ca 100644 --- a/pkg/detectors/pushbulletapikey/pushbulletapikey.go +++ b/pkg/detectors/pushbulletapikey/pushbulletapikey.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify PushBulletApiKey secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/pushbulletapikey/pushbulletapikey_test.go b/pkg/detectors/pushbulletapikey/pushbulletapikey_test.go index 81aeb603dd46..5d4cd3243255 100644 --- a/pkg/detectors/pushbulletapikey/pushbulletapikey_test.go +++ b/pkg/detectors/pushbulletapikey/pushbulletapikey_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/pusherchannelkey/pusherchannelkey.go b/pkg/detectors/pusherchannelkey/pusherchannelkey.go index 69cefa1467b8..dc133d965e84 100644 --- a/pkg/detectors/pusherchannelkey/pusherchannelkey.go +++ b/pkg/detectors/pusherchannelkey/pusherchannelkey.go @@ -45,7 +45,7 @@ const ( // FromData will find and optionally verify PusherChannelKey secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) keyMatches := keyPat.FindAllStringSubmatch(dataStr, -1) appMatches := appIdPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/pusherchannelkey/pusherchannelkey_test.go b/pkg/detectors/pusherchannelkey/pusherchannelkey_test.go index e6eac14832d7..a36b0045a9db 100644 --- a/pkg/detectors/pusherchannelkey/pusherchannelkey_test.go +++ b/pkg/detectors/pusherchannelkey/pusherchannelkey_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/qase/qase.go b/pkg/detectors/qase/qase.go index 23a2b3450a31..ba5f9eb3123a 100644 --- a/pkg/detectors/qase/qase.go +++ b/pkg/detectors/qase/qase.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Qase secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/qase/qase_test.go b/pkg/detectors/qase/qase_test.go index 271d7d2f9fae..fb92a3212f4e 100644 --- a/pkg/detectors/qase/qase_test.go +++ b/pkg/detectors/qase/qase_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/qualaroo/qualaroo.go b/pkg/detectors/qualaroo/qualaroo.go index e67a26246119..2fdcbdf9360d 100644 --- a/pkg/detectors/qualaroo/qualaroo.go +++ b/pkg/detectors/qualaroo/qualaroo.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Qualaroo secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/qualaroo/qualaroo_test.go b/pkg/detectors/qualaroo/qualaroo_test.go index 92637db43e13..0a5912090c42 100644 --- a/pkg/detectors/qualaroo/qualaroo_test.go +++ b/pkg/detectors/qualaroo/qualaroo_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/qubole/qubole.go b/pkg/detectors/qubole/qubole.go index 855f091ffcc0..1723031b0aeb 100644 --- a/pkg/detectors/qubole/qubole.go +++ b/pkg/detectors/qubole/qubole.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Qubole secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/qubole/qubole_test.go b/pkg/detectors/qubole/qubole_test.go index ccd8c83e0bd2..173ee0194025 100644 --- a/pkg/detectors/qubole/qubole_test.go +++ b/pkg/detectors/qubole/qubole_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/rabbitmq/rabbitmq.go b/pkg/detectors/rabbitmq/rabbitmq.go index 436e14e059d6..8d2f47de6bfc 100644 --- a/pkg/detectors/rabbitmq/rabbitmq.go +++ b/pkg/detectors/rabbitmq/rabbitmq.go @@ -8,6 +8,7 @@ import ( amqp "github.com/rabbitmq/amqp091-go" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" ) @@ -29,7 +30,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify RabbitMQ secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/rabbitmq/rabbitmq_test.go b/pkg/detectors/rabbitmq/rabbitmq_test.go index 77a5ffcd62fd..fc16478a2818 100644 --- a/pkg/detectors/rabbitmq/rabbitmq_test.go +++ b/pkg/detectors/rabbitmq/rabbitmq_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/ramp/ramp.go b/pkg/detectors/ramp/ramp.go index 67031c97a21e..e4cab77c2eb8 100644 --- a/pkg/detectors/ramp/ramp.go +++ b/pkg/detectors/ramp/ramp.go @@ -3,13 +3,14 @@ package ramp import ( "context" "fmt" - "github.com/trufflesecurity/trufflehog/v3/pkg/common" - "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" - "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" "net/http" "net/url" "regexp" "strings" + + "github.com/trufflesecurity/trufflehog/v3/pkg/common" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" + "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" ) type Scanner struct { @@ -34,7 +35,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Ramp secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) secretMatches := secretPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/ramp/ramp_test.go b/pkg/detectors/ramp/ramp_test.go index 69bb3ab4464d..f2ddc854f755 100644 --- a/pkg/detectors/ramp/ramp_test.go +++ b/pkg/detectors/ramp/ramp_test.go @@ -6,11 +6,12 @@ package ramp import ( "context" "fmt" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "testing" "time" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/rapidapi/rapidapi.go b/pkg/detectors/rapidapi/rapidapi.go index ff3102f318fc..f6bff3996b5a 100644 --- a/pkg/detectors/rapidapi/rapidapi.go +++ b/pkg/detectors/rapidapi/rapidapi.go @@ -30,7 +30,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify RapidApi secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/rapidapi/rapidapi_test.go b/pkg/detectors/rapidapi/rapidapi_test.go index 3deee3a8ae21..c04535dc295e 100644 --- a/pkg/detectors/rapidapi/rapidapi_test.go +++ b/pkg/detectors/rapidapi/rapidapi_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/raven/raven.go b/pkg/detectors/raven/raven.go index e7845e93b5e4..9e7ba2f2f8d9 100644 --- a/pkg/detectors/raven/raven.go +++ b/pkg/detectors/raven/raven.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Raven secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/raven/raven_test.go b/pkg/detectors/raven/raven_test.go index 0558e15a26b7..f5bc0d1a0023 100644 --- a/pkg/detectors/raven/raven_test.go +++ b/pkg/detectors/raven/raven_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/rawg/rawg.go b/pkg/detectors/rawg/rawg.go index 526a9431f114..2f151a2888da 100644 --- a/pkg/detectors/rawg/rawg.go +++ b/pkg/detectors/rawg/rawg.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Rawg secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/rawg/rawg_test.go b/pkg/detectors/rawg/rawg_test.go index 8fc636833796..6f7638e472fe 100644 --- a/pkg/detectors/rawg/rawg_test.go +++ b/pkg/detectors/rawg/rawg_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/razorpay/razorpay.go b/pkg/detectors/razorpay/razorpay.go index 4071ddc73c48..9f20019c980b 100644 --- a/pkg/detectors/razorpay/razorpay.go +++ b/pkg/detectors/razorpay/razorpay.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify RazorPay secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) keyMatches := keyPat.FindAllString(dataStr, -1) diff --git a/pkg/detectors/razorpay/razorpay_test.go b/pkg/detectors/razorpay/razorpay_test.go index 2e39ec1608c5..21703bfff6ea 100644 --- a/pkg/detectors/razorpay/razorpay_test.go +++ b/pkg/detectors/razorpay/razorpay_test.go @@ -11,6 +11,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" diff --git a/pkg/detectors/reachmail/reachmail.go b/pkg/detectors/reachmail/reachmail.go index 204a11443f13..be365f7324f1 100644 --- a/pkg/detectors/reachmail/reachmail.go +++ b/pkg/detectors/reachmail/reachmail.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Reachmail secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/reachmail/reachmail_test.go b/pkg/detectors/reachmail/reachmail_test.go index f33fa67e1420..c471940d6358 100644 --- a/pkg/detectors/reachmail/reachmail_test.go +++ b/pkg/detectors/reachmail/reachmail_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/readme/readme.go b/pkg/detectors/readme/readme.go index 80ff3c94df05..bd2b87a4e784 100644 --- a/pkg/detectors/readme/readme.go +++ b/pkg/detectors/readme/readme.go @@ -6,6 +6,7 @@ import ( "regexp" "strings" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" ) @@ -29,7 +30,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ReadMe secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/readme/readme_test.go b/pkg/detectors/readme/readme_test.go index 1648b60f193a..91ff08a24e68 100644 --- a/pkg/detectors/readme/readme_test.go +++ b/pkg/detectors/readme/readme_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/reallysimplesystems/reallysimplesystems.go b/pkg/detectors/reallysimplesystems/reallysimplesystems.go index dc01ec28d484..11724e3b70d4 100644 --- a/pkg/detectors/reallysimplesystems/reallysimplesystems.go +++ b/pkg/detectors/reallysimplesystems/reallysimplesystems.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ReallySimpleSystems secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/reallysimplesystems/reallysimplesystems_test.go b/pkg/detectors/reallysimplesystems/reallysimplesystems_test.go index 631bac585cc0..9764ab528cba 100644 --- a/pkg/detectors/reallysimplesystems/reallysimplesystems_test.go +++ b/pkg/detectors/reallysimplesystems/reallysimplesystems_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/rebrandly/rebrandly.go b/pkg/detectors/rebrandly/rebrandly.go index 8c9543109a5a..e7d1574e0c07 100644 --- a/pkg/detectors/rebrandly/rebrandly.go +++ b/pkg/detectors/rebrandly/rebrandly.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Rebrandly secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/rebrandly/rebrandly_test.go b/pkg/detectors/rebrandly/rebrandly_test.go index f1b85b2ad142..c70f7d1eca95 100644 --- a/pkg/detectors/rebrandly/rebrandly_test.go +++ b/pkg/detectors/rebrandly/rebrandly_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/rechargepayments/rechargepayments.go b/pkg/detectors/rechargepayments/rechargepayments.go index 773a84f9f133..4458a667129e 100644 --- a/pkg/detectors/rechargepayments/rechargepayments.go +++ b/pkg/detectors/rechargepayments/rechargepayments.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Recharge Payment secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) for _, tokenPat := range tokenPats { tokens := tokenPat.FindAllString(dataStr, -1) diff --git a/pkg/detectors/rechargepayments/rechargepayments_test.go b/pkg/detectors/rechargepayments/rechargepayments_test.go index 919b739096e1..666ab262f0bb 100644 --- a/pkg/detectors/rechargepayments/rechargepayments_test.go +++ b/pkg/detectors/rechargepayments/rechargepayments_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/redis/redis.go b/pkg/detectors/redis/redis.go index 5aa4efdd8b0e..5b7fe2ba158e 100644 --- a/pkg/detectors/redis/redis.go +++ b/pkg/detectors/redis/redis.go @@ -9,6 +9,7 @@ import ( "github.com/go-redis/redis" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" ) @@ -31,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify URI secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) azureMatches := azureRedisPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/redis/redis_test.go b/pkg/detectors/redis/redis_test.go index 92b58dece5a1..12996b7a14d8 100644 --- a/pkg/detectors/redis/redis_test.go +++ b/pkg/detectors/redis/redis_test.go @@ -8,6 +8,7 @@ import ( "testing" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" ) diff --git a/pkg/detectors/refiner/refiner.go b/pkg/detectors/refiner/refiner.go index e3da1e3c667a..ae449daf5661 100644 --- a/pkg/detectors/refiner/refiner.go +++ b/pkg/detectors/refiner/refiner.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Refiner secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/refiner/refiner_test.go b/pkg/detectors/refiner/refiner_test.go index 68a9207de47f..f02c1e6b6187 100644 --- a/pkg/detectors/refiner/refiner_test.go +++ b/pkg/detectors/refiner/refiner_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/rentman/rentman.go b/pkg/detectors/rentman/rentman.go index d952b74d574a..83a0a804d2e4 100644 --- a/pkg/detectors/rentman/rentman.go +++ b/pkg/detectors/rentman/rentman.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Rentman secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/rentman/rentman_test.go b/pkg/detectors/rentman/rentman_test.go index 5bd67861688e..52bd6bf7dff8 100644 --- a/pkg/detectors/rentman/rentman_test.go +++ b/pkg/detectors/rentman/rentman_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/repairshopr/repairshopr.go b/pkg/detectors/repairshopr/repairshopr.go index e5ef9695b2e6..ec77ebcf81f4 100644 --- a/pkg/detectors/repairshopr/repairshopr.go +++ b/pkg/detectors/repairshopr/repairshopr.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Sugester secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) domainMatches := domainPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/replicate/replicate.go b/pkg/detectors/replicate/replicate.go index f1a05db7b4fd..dbe0afc98567 100644 --- a/pkg/detectors/replicate/replicate.go +++ b/pkg/detectors/replicate/replicate.go @@ -21,7 +21,7 @@ var _ detectors.Detector = (*Scanner)(nil) var ( defaultClient = common.SaneHttpClient() - keyPat = regexp.MustCompile(`\b(r8_[0-9A-Za-z-_]{37})\b`) + keyPat = regexp.MustCompile(`\b(r8_[0-9A-Za-z-_]{37})\b`) ) func (s Scanner) Keywords() []string { @@ -29,7 +29,7 @@ func (s Scanner) Keywords() []string { } func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/replyio/replyio.go b/pkg/detectors/replyio/replyio.go index f9c8f72c9a6d..610c451716a3 100644 --- a/pkg/detectors/replyio/replyio.go +++ b/pkg/detectors/replyio/replyio.go @@ -30,7 +30,7 @@ func (s Scanner) Keywords() []string { } func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/requestfinance/requestfinance.go b/pkg/detectors/requestfinance/requestfinance.go index c55c64d2ec41..91d8423c4d09 100644 --- a/pkg/detectors/requestfinance/requestfinance.go +++ b/pkg/detectors/requestfinance/requestfinance.go @@ -21,7 +21,7 @@ var _ detectors.Detector = (*Scanner)(nil) var ( defaultClient = common.SaneHttpClient() - keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"requestfinance"}) + `\b([0-9A-Z]{7}-[0-9A-Z]{7}-[0-9A-Z]{7}-[0-9A-Z]{7})\b`) + keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"requestfinance"}) + `\b([0-9A-Z]{7}-[0-9A-Z]{7}-[0-9A-Z]{7}-[0-9A-Z]{7})\b`) ) // Keywords are used for efficiently pre-filtering chunks. @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Requestfinance secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/restpack/restpack.go b/pkg/detectors/restpack/restpack.go index ddc09c3f6610..02584dfd6e5e 100644 --- a/pkg/detectors/restpack/restpack.go +++ b/pkg/detectors/restpack/restpack.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Restpack secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/restpack/restpack_test.go b/pkg/detectors/restpack/restpack_test.go index ff3404f3c918..b13f69a8a8f6 100644 --- a/pkg/detectors/restpack/restpack_test.go +++ b/pkg/detectors/restpack/restpack_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/restpackhtmltopdfapi/restpackhtmltopdfapi.go b/pkg/detectors/restpackhtmltopdfapi/restpackhtmltopdfapi.go index d39cbc068c6a..4bad5e79fd44 100644 --- a/pkg/detectors/restpackhtmltopdfapi/restpackhtmltopdfapi.go +++ b/pkg/detectors/restpackhtmltopdfapi/restpackhtmltopdfapi.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify RestpackHtmlToPdfAPI secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/restpackhtmltopdfapi/restpackhtmltopdfapi_test.go b/pkg/detectors/restpackhtmltopdfapi/restpackhtmltopdfapi_test.go index 9666074eaafb..e0edce3362bc 100644 --- a/pkg/detectors/restpackhtmltopdfapi/restpackhtmltopdfapi_test.go +++ b/pkg/detectors/restpackhtmltopdfapi/restpackhtmltopdfapi_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/restpackscreenshotapi/restpackscreenshotapi.go b/pkg/detectors/restpackscreenshotapi/restpackscreenshotapi.go index ed052c5cdb30..236834d12e34 100644 --- a/pkg/detectors/restpackscreenshotapi/restpackscreenshotapi.go +++ b/pkg/detectors/restpackscreenshotapi/restpackscreenshotapi.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify RestpackScreenshotAPI secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/rev/rev.go b/pkg/detectors/rev/rev.go index af8de9321d4e..889faebfb6aa 100644 --- a/pkg/detectors/rev/rev.go +++ b/pkg/detectors/rev/rev.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Rev secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) userMatches := userKeyPat.FindAllStringSubmatch(dataStr, -1) clientMatches := clientKeyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/rev/rev_test.go b/pkg/detectors/rev/rev_test.go index 885a1dace78d..08f7edb1519b 100644 --- a/pkg/detectors/rev/rev_test.go +++ b/pkg/detectors/rev/rev_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/revampcrm/revampcrm.go b/pkg/detectors/revampcrm/revampcrm.go index 8c8d3ae0578a..1016322178a3 100644 --- a/pkg/detectors/revampcrm/revampcrm.go +++ b/pkg/detectors/revampcrm/revampcrm.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify RevampCRM secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/revampcrm/revampcrm_test.go b/pkg/detectors/revampcrm/revampcrm_test.go index 1101321f67f3..5609ddc1f71b 100644 --- a/pkg/detectors/revampcrm/revampcrm_test.go +++ b/pkg/detectors/revampcrm/revampcrm_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/ringcentral/ringcentral.go b/pkg/detectors/ringcentral/ringcentral.go index a57daf212439..88ea80fcdb3f 100644 --- a/pkg/detectors/ringcentral/ringcentral.go +++ b/pkg/detectors/ringcentral/ringcentral.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Ringcentral secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) uriMatches := uriPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/ringcentral/ringcentral_test.go b/pkg/detectors/ringcentral/ringcentral_test.go index 360028638c28..eb9bc9846603 100644 --- a/pkg/detectors/ringcentral/ringcentral_test.go +++ b/pkg/detectors/ringcentral/ringcentral_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/ritekit/ritekit.go b/pkg/detectors/ritekit/ritekit.go index 7aaab9cc1188..fce4f10688dc 100644 --- a/pkg/detectors/ritekit/ritekit.go +++ b/pkg/detectors/ritekit/ritekit.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify RiteKit secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/ritekit/ritekit_test.go b/pkg/detectors/ritekit/ritekit_test.go index 063651feb145..fc8713f1b1e4 100644 --- a/pkg/detectors/ritekit/ritekit_test.go +++ b/pkg/detectors/ritekit/ritekit_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/roaring/roaring.go b/pkg/detectors/roaring/roaring.go index dee74da36152..0848908fca61 100644 --- a/pkg/detectors/roaring/roaring.go +++ b/pkg/detectors/roaring/roaring.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Roaring secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) clientMatches := clientPat.FindAllStringSubmatch(dataStr, -1) secretMatches := secretPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/roaring/roaring_test.go b/pkg/detectors/roaring/roaring_test.go index 640ddb5247ad..d538e29bd17d 100644 --- a/pkg/detectors/roaring/roaring_test.go +++ b/pkg/detectors/roaring/roaring_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/rocketreach/rocketreach.go b/pkg/detectors/rocketreach/rocketreach.go index c444111598d5..12df21232903 100644 --- a/pkg/detectors/rocketreach/rocketreach.go +++ b/pkg/detectors/rocketreach/rocketreach.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify RocketReach secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/rockset/rockset.go b/pkg/detectors/rockset/rockset.go index f79d6e0051d9..1c403efe98e0 100644 --- a/pkg/detectors/rockset/rockset.go +++ b/pkg/detectors/rockset/rockset.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Rockset secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/rockset/rockset_test.go b/pkg/detectors/rockset/rockset_test.go index 4d18254b1985..9614450acf34 100644 --- a/pkg/detectors/rockset/rockset_test.go +++ b/pkg/detectors/rockset/rockset_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/roninapp/roninapp.go b/pkg/detectors/roninapp/roninapp.go index 8e22e80deb73..e3120ecdf471 100644 --- a/pkg/detectors/roninapp/roninapp.go +++ b/pkg/detectors/roninapp/roninapp.go @@ -2,13 +2,12 @@ package roninapp import ( "context" + b64 "encoding/base64" "fmt" + "net/http" "regexp" "strings" - b64 "encoding/base64" - "net/http" - "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" @@ -35,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify RoninApp secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idmatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/roninapp/roninapp_test.go b/pkg/detectors/roninapp/roninapp_test.go index 67a47781e603..e1d77f72e2d7 100644 --- a/pkg/detectors/roninapp/roninapp_test.go +++ b/pkg/detectors/roninapp/roninapp_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/route4me/route4me.go b/pkg/detectors/route4me/route4me.go index 0428e45046a6..9764ede2c593 100644 --- a/pkg/detectors/route4me/route4me.go +++ b/pkg/detectors/route4me/route4me.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Route4me secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/route4me/route4me_test.go b/pkg/detectors/route4me/route4me_test.go index de2b1e24e4fc..4d50d66f36c8 100644 --- a/pkg/detectors/route4me/route4me_test.go +++ b/pkg/detectors/route4me/route4me_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/rownd/rownd.go b/pkg/detectors/rownd/rownd.go index 1d2d86434afb..112a59fff68e 100644 --- a/pkg/detectors/rownd/rownd.go +++ b/pkg/detectors/rownd/rownd.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Rownd secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) keyMatches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/rubygems/rubygems.go b/pkg/detectors/rubygems/rubygems.go index 0f3e9d0f95e1..8c63fe61e1a9 100644 --- a/pkg/detectors/rubygems/rubygems.go +++ b/pkg/detectors/rubygems/rubygems.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify RubyGems secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/rubygems/rubygems_test.go b/pkg/detectors/rubygems/rubygems_test.go index aa681f83b855..9b06357aa216 100644 --- a/pkg/detectors/rubygems/rubygems_test.go +++ b/pkg/detectors/rubygems/rubygems_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/runrunit/runrunit.go b/pkg/detectors/runrunit/runrunit.go index 5ac22e2df49a..73f1cec6d4c2 100644 --- a/pkg/detectors/runrunit/runrunit.go +++ b/pkg/detectors/runrunit/runrunit.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify RunRunIt secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) userTokenMatches := userTokenPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/runrunit/runrunit_test.go b/pkg/detectors/runrunit/runrunit_test.go index 8cdeabd2e764..cd8578039ded 100644 --- a/pkg/detectors/runrunit/runrunit_test.go +++ b/pkg/detectors/runrunit/runrunit_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/salesblink/salesblink.go b/pkg/detectors/salesblink/salesblink.go index d2b4e880bb02..dad8ac86d578 100644 --- a/pkg/detectors/salesblink/salesblink.go +++ b/pkg/detectors/salesblink/salesblink.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Salesblink secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/salesblink/salesblink_test.go b/pkg/detectors/salesblink/salesblink_test.go index 43b662ccc0e4..3ac45863a43f 100644 --- a/pkg/detectors/salesblink/salesblink_test.go +++ b/pkg/detectors/salesblink/salesblink_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/salescookie/salescookie.go b/pkg/detectors/salescookie/salescookie.go index 43073adef6a8..6de47a3536a4 100644 --- a/pkg/detectors/salescookie/salescookie.go +++ b/pkg/detectors/salescookie/salescookie.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Salescookie secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/salescookie/salescookie_test.go b/pkg/detectors/salescookie/salescookie_test.go index 48196acf887d..27db5e70275d 100644 --- a/pkg/detectors/salescookie/salescookie_test.go +++ b/pkg/detectors/salescookie/salescookie_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/salesflare/salesflare.go b/pkg/detectors/salesflare/salesflare.go index faa1c1752d46..08b9c0db0e6f 100644 --- a/pkg/detectors/salesflare/salesflare.go +++ b/pkg/detectors/salesflare/salesflare.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Salesflare secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/salesflare/salesflare_test.go b/pkg/detectors/salesflare/salesflare_test.go index e3b0490c79d2..f7239d537dc6 100644 --- a/pkg/detectors/salesflare/salesflare_test.go +++ b/pkg/detectors/salesflare/salesflare_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/salesforce/salesforce.go b/pkg/detectors/salesforce/salesforce.go index 0623621d4af0..8fa5624e5fb0 100644 --- a/pkg/detectors/salesforce/salesforce.go +++ b/pkg/detectors/salesforce/salesforce.go @@ -38,7 +38,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Salesforce secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) instanceMatches := instancePat.FindAllStringSubmatch(dataStr, -1) tokenMatches := accessTokenPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/salesforce/salesforce_test.go b/pkg/detectors/salesforce/salesforce_test.go index 77ff55c4b011..469b51a9fbaa 100644 --- a/pkg/detectors/salesforce/salesforce_test.go +++ b/pkg/detectors/salesforce/salesforce_test.go @@ -6,11 +6,12 @@ package salesforce import ( "context" "fmt" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "testing" "time" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/salesmate/salesmate.go b/pkg/detectors/salesmate/salesmate.go index f68336079c95..c28e12dfa827 100644 --- a/pkg/detectors/salesmate/salesmate.go +++ b/pkg/detectors/salesmate/salesmate.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Salesmate secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idmatches := domainPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/salesmate/salesmate_test.go b/pkg/detectors/salesmate/salesmate_test.go index d440be9aa20a..9babc98974b6 100644 --- a/pkg/detectors/salesmate/salesmate_test.go +++ b/pkg/detectors/salesmate/salesmate_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/satismeterprojectkey/satismeterprojectkey.go b/pkg/detectors/satismeterprojectkey/satismeterprojectkey.go index 88c85b575b3b..36293c906bfc 100644 --- a/pkg/detectors/satismeterprojectkey/satismeterprojectkey.go +++ b/pkg/detectors/satismeterprojectkey/satismeterprojectkey.go @@ -35,7 +35,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify SatismeterProjectkey secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) emailmatches := emailPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/satismeterprojectkey/satismeterprojectkey_test.go b/pkg/detectors/satismeterprojectkey/satismeterprojectkey_test.go index 8b0a3bfcd249..7db3b71b21dc 100644 --- a/pkg/detectors/satismeterprojectkey/satismeterprojectkey_test.go +++ b/pkg/detectors/satismeterprojectkey/satismeterprojectkey_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/satismeterwritekey/satismeterwritekey.go b/pkg/detectors/satismeterwritekey/satismeterwritekey.go index 143f5645d2a4..ed065b342789 100644 --- a/pkg/detectors/satismeterwritekey/satismeterwritekey.go +++ b/pkg/detectors/satismeterwritekey/satismeterwritekey.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify SatismeterWritekey secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/satismeterwritekey/satismeterwritekey_test.go b/pkg/detectors/satismeterwritekey/satismeterwritekey_test.go index 26f3d00fe886..f511991348f7 100644 --- a/pkg/detectors/satismeterwritekey/satismeterwritekey_test.go +++ b/pkg/detectors/satismeterwritekey/satismeterwritekey_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/saucelabs/saucelabs.go b/pkg/detectors/saucelabs/saucelabs.go index 24ad11649969..986704438d8a 100644 --- a/pkg/detectors/saucelabs/saucelabs.go +++ b/pkg/detectors/saucelabs/saucelabs.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify SauceLabs secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) keyMatches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/saucelabs/saucelabs_test.go b/pkg/detectors/saucelabs/saucelabs_test.go index 7f92957f283d..3c91cc0bfd4f 100644 --- a/pkg/detectors/saucelabs/saucelabs_test.go +++ b/pkg/detectors/saucelabs/saucelabs_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/scalewaykey/scalewaykey.go b/pkg/detectors/scalewaykey/scalewaykey.go index c82b4a0d0ace..e7ce7bb9af7e 100644 --- a/pkg/detectors/scalewaykey/scalewaykey.go +++ b/pkg/detectors/scalewaykey/scalewaykey.go @@ -30,7 +30,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ScalewayKey secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/scalewaykey/scalewaykey_test.go b/pkg/detectors/scalewaykey/scalewaykey_test.go index 58bbd79a04e3..0a07906cd60d 100644 --- a/pkg/detectors/scalewaykey/scalewaykey_test.go +++ b/pkg/detectors/scalewaykey/scalewaykey_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/scalr/scalr.go b/pkg/detectors/scalr/scalr.go index 77b750a3f374..8f5c76f8a496 100644 --- a/pkg/detectors/scalr/scalr.go +++ b/pkg/detectors/scalr/scalr.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Scalr secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idmatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/scalr/scalr_test.go b/pkg/detectors/scalr/scalr_test.go index 758c8ce3ad06..fc6d3c63b886 100644 --- a/pkg/detectors/scalr/scalr_test.go +++ b/pkg/detectors/scalr/scalr_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/scrapeowl/scrapeowl.go b/pkg/detectors/scrapeowl/scrapeowl.go index 70707e81c8d2..ef78cf82747d 100644 --- a/pkg/detectors/scrapeowl/scrapeowl.go +++ b/pkg/detectors/scrapeowl/scrapeowl.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Scrapeowl secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/scrapeowl/scrapeowl_test.go b/pkg/detectors/scrapeowl/scrapeowl_test.go index 519f9a03c820..9ea6ba2fe6cf 100644 --- a/pkg/detectors/scrapeowl/scrapeowl_test.go +++ b/pkg/detectors/scrapeowl/scrapeowl_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/scraperapi/scraperapi.go b/pkg/detectors/scraperapi/scraperapi.go index d6283a64eb7d..fcbd0cca5777 100644 --- a/pkg/detectors/scraperapi/scraperapi.go +++ b/pkg/detectors/scraperapi/scraperapi.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ScraperAPI secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) for _, match := range matches { if len(match) != 2 { diff --git a/pkg/detectors/scraperapi/scraperapi_test.go b/pkg/detectors/scraperapi/scraperapi_test.go index c809f33d8408..c1191581b194 100644 --- a/pkg/detectors/scraperapi/scraperapi_test.go +++ b/pkg/detectors/scraperapi/scraperapi_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/scraperbox/scraperbox.go b/pkg/detectors/scraperbox/scraperbox.go index 89fd4039776a..872f9cdee8b4 100644 --- a/pkg/detectors/scraperbox/scraperbox.go +++ b/pkg/detectors/scraperbox/scraperbox.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ScraperBox secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/scraperbox/scraperbox_test.go b/pkg/detectors/scraperbox/scraperbox_test.go index 4a867efbf033..5e4ea1d156fe 100644 --- a/pkg/detectors/scraperbox/scraperbox_test.go +++ b/pkg/detectors/scraperbox/scraperbox_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/scrapestack/scrapestack.go b/pkg/detectors/scrapestack/scrapestack.go index 119d915ed100..30184e79dfcc 100644 --- a/pkg/detectors/scrapestack/scrapestack.go +++ b/pkg/detectors/scrapestack/scrapestack.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ScrapeStack secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/scrapestack/scrapestack_test.go b/pkg/detectors/scrapestack/scrapestack_test.go index 0fdb025580ca..5e6a9285a861 100644 --- a/pkg/detectors/scrapestack/scrapestack_test.go +++ b/pkg/detectors/scrapestack/scrapestack_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/scrapfly/scrapfly.go b/pkg/detectors/scrapfly/scrapfly.go index fb6db5edc1d1..ffee3949e0fd 100644 --- a/pkg/detectors/scrapfly/scrapfly.go +++ b/pkg/detectors/scrapfly/scrapfly.go @@ -37,7 +37,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Scrapfly secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/scrapfly/scrapfly_test.go b/pkg/detectors/scrapfly/scrapfly_test.go index 34a7ff5b0b37..9dd19700db23 100644 --- a/pkg/detectors/scrapfly/scrapfly_test.go +++ b/pkg/detectors/scrapfly/scrapfly_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/scrapingant/scrapingant.go b/pkg/detectors/scrapingant/scrapingant.go index ab5c4b6c10be..24feb9af9365 100644 --- a/pkg/detectors/scrapingant/scrapingant.go +++ b/pkg/detectors/scrapingant/scrapingant.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ScrapingAnt secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/scrapingant/scrapingant_test.go b/pkg/detectors/scrapingant/scrapingant_test.go index 311550c8ebd8..90db24d9cd5f 100644 --- a/pkg/detectors/scrapingant/scrapingant_test.go +++ b/pkg/detectors/scrapingant/scrapingant_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/scrapingbee/scrapingbee.go b/pkg/detectors/scrapingbee/scrapingbee.go index 628c1d691291..786cf12c6c96 100644 --- a/pkg/detectors/scrapingbee/scrapingbee.go +++ b/pkg/detectors/scrapingbee/scrapingbee.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ScrapingBee secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/scrapingbee/scrapingbee_test.go b/pkg/detectors/scrapingbee/scrapingbee_test.go index 561c67eb24f2..81dc2ab99028 100644 --- a/pkg/detectors/scrapingbee/scrapingbee_test.go +++ b/pkg/detectors/scrapingbee/scrapingbee_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/screenshotapi/screenshotapi.go b/pkg/detectors/screenshotapi/screenshotapi.go index e2b453050f28..631318508f6b 100644 --- a/pkg/detectors/screenshotapi/screenshotapi.go +++ b/pkg/detectors/screenshotapi/screenshotapi.go @@ -37,7 +37,7 @@ type response struct { // FromData will find and optionally verify ScreenshotAPI secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/screenshotapi/screenshotapi_test.go b/pkg/detectors/screenshotapi/screenshotapi_test.go index 34601e49bfed..dad833294e25 100644 --- a/pkg/detectors/screenshotapi/screenshotapi_test.go +++ b/pkg/detectors/screenshotapi/screenshotapi_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/screenshotlayer/screenshotlayer.go b/pkg/detectors/screenshotlayer/screenshotlayer.go index e06f7291fd28..53287a31ddd0 100644 --- a/pkg/detectors/screenshotlayer/screenshotlayer.go +++ b/pkg/detectors/screenshotlayer/screenshotlayer.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ScreenshotLayer secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/screenshotlayer/screenshotlayer_test.go b/pkg/detectors/screenshotlayer/screenshotlayer_test.go index 15f03a2d768c..63848c4fe70b 100644 --- a/pkg/detectors/screenshotlayer/screenshotlayer_test.go +++ b/pkg/detectors/screenshotlayer/screenshotlayer_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/scrutinizerci/scrutinizerci.go b/pkg/detectors/scrutinizerci/scrutinizerci.go index 9399992cffdf..c7ef4cd5febd 100644 --- a/pkg/detectors/scrutinizerci/scrutinizerci.go +++ b/pkg/detectors/scrutinizerci/scrutinizerci.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ScrutinizerCi secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/scrutinizerci/scrutinizerci_test.go b/pkg/detectors/scrutinizerci/scrutinizerci_test.go index f43c24e8e29d..a68095a725cd 100644 --- a/pkg/detectors/scrutinizerci/scrutinizerci_test.go +++ b/pkg/detectors/scrutinizerci/scrutinizerci_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/securitytrails/securitytrails.go b/pkg/detectors/securitytrails/securitytrails.go index c0b79e0bf411..e7114cbbbf34 100644 --- a/pkg/detectors/securitytrails/securitytrails.go +++ b/pkg/detectors/securitytrails/securitytrails.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify SecurityTrails secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/securitytrails/securitytrails_test.go b/pkg/detectors/securitytrails/securitytrails_test.go index 95202372034b..d25c1b41fd97 100644 --- a/pkg/detectors/securitytrails/securitytrails_test.go +++ b/pkg/detectors/securitytrails/securitytrails_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/segmentapikey/segmentapikey.go b/pkg/detectors/segmentapikey/segmentapikey.go index d55a0d897ccb..e4e819368395 100644 --- a/pkg/detectors/segmentapikey/segmentapikey.go +++ b/pkg/detectors/segmentapikey/segmentapikey.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify SegmentApiKey secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/segmentapikey/segmentapikey_test.go b/pkg/detectors/segmentapikey/segmentapikey_test.go index 133f92853885..90b847b95df0 100644 --- a/pkg/detectors/segmentapikey/segmentapikey_test.go +++ b/pkg/detectors/segmentapikey/segmentapikey_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/selectpdf/selectpdf.go b/pkg/detectors/selectpdf/selectpdf.go index 2a80d4c3bcfe..ee341f0ce84f 100644 --- a/pkg/detectors/selectpdf/selectpdf.go +++ b/pkg/detectors/selectpdf/selectpdf.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify SelectPDF secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/selectpdf/selectpdf_test.go b/pkg/detectors/selectpdf/selectpdf_test.go index 6757a7f1fc0a..962053be26ad 100644 --- a/pkg/detectors/selectpdf/selectpdf_test.go +++ b/pkg/detectors/selectpdf/selectpdf_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/semaphore/semaphore.go b/pkg/detectors/semaphore/semaphore.go index 073abb867d79..56768a5a8337 100644 --- a/pkg/detectors/semaphore/semaphore.go +++ b/pkg/detectors/semaphore/semaphore.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Semaphore secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/semaphore/semaphore_test.go b/pkg/detectors/semaphore/semaphore_test.go index 116535e06a1d..34092e4d563e 100644 --- a/pkg/detectors/semaphore/semaphore_test.go +++ b/pkg/detectors/semaphore/semaphore_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/sendbird/sendbird.go b/pkg/detectors/sendbird/sendbird.go index f632083a60af..3bdb6d1508c2 100644 --- a/pkg/detectors/sendbird/sendbird.go +++ b/pkg/detectors/sendbird/sendbird.go @@ -40,7 +40,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Sendbird secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) appIdMatches := appIdPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/sendbird/sendbird_test.go b/pkg/detectors/sendbird/sendbird_test.go index 6f987718b5e6..0a1fac3b2bc3 100644 --- a/pkg/detectors/sendbird/sendbird_test.go +++ b/pkg/detectors/sendbird/sendbird_test.go @@ -11,6 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" diff --git a/pkg/detectors/sendbirdorganizationapi/sendbirdorganizationapi.go b/pkg/detectors/sendbirdorganizationapi/sendbirdorganizationapi.go index 52f22ce6c072..7972dbe9bccb 100644 --- a/pkg/detectors/sendbirdorganizationapi/sendbirdorganizationapi.go +++ b/pkg/detectors/sendbirdorganizationapi/sendbirdorganizationapi.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify SendbirdOrganizationAPI secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/sendgrid/sendgrid.go b/pkg/detectors/sendgrid/sendgrid.go index 9760cffec4fe..a6689928d2c8 100644 --- a/pkg/detectors/sendgrid/sendgrid.go +++ b/pkg/detectors/sendgrid/sendgrid.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Sendgrid secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/sendgrid/sendgrid_test.go b/pkg/detectors/sendgrid/sendgrid_test.go index bd95329da55c..f40899730e13 100644 --- a/pkg/detectors/sendgrid/sendgrid_test.go +++ b/pkg/detectors/sendgrid/sendgrid_test.go @@ -11,6 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" diff --git a/pkg/detectors/sendinbluev2/sendinbluev2.go b/pkg/detectors/sendinbluev2/sendinbluev2.go index 69473743893f..ec084a0c9cb1 100644 --- a/pkg/detectors/sendinbluev2/sendinbluev2.go +++ b/pkg/detectors/sendinbluev2/sendinbluev2.go @@ -30,7 +30,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify SendinBlueV2 secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/sentrytoken/sentrytoken.go b/pkg/detectors/sentrytoken/sentrytoken.go index 0362c52cd80c..43da79a4e336 100644 --- a/pkg/detectors/sentrytoken/sentrytoken.go +++ b/pkg/detectors/sentrytoken/sentrytoken.go @@ -39,7 +39,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify SentryToken secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/serphouse/serphouse.go b/pkg/detectors/serphouse/serphouse.go index 09a330a8bc34..2b15090e6377 100644 --- a/pkg/detectors/serphouse/serphouse.go +++ b/pkg/detectors/serphouse/serphouse.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Serphouse secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/serphouse/serphouse_test.go b/pkg/detectors/serphouse/serphouse_test.go index 9182a9e4c4a7..26642d7100f1 100644 --- a/pkg/detectors/serphouse/serphouse_test.go +++ b/pkg/detectors/serphouse/serphouse_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/serpstack/serpstack.go b/pkg/detectors/serpstack/serpstack.go index 7b643b1aa9d8..0da85aad2290 100644 --- a/pkg/detectors/serpstack/serpstack.go +++ b/pkg/detectors/serpstack/serpstack.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify SerpStack secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/sheety/sheety.go b/pkg/detectors/sheety/sheety.go index c2c12e0e1bee..9684dd617191 100644 --- a/pkg/detectors/sheety/sheety.go +++ b/pkg/detectors/sheety/sheety.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Sheety secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idmatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/sheety/sheety_test.go b/pkg/detectors/sheety/sheety_test.go index d79b45a5fd08..ea6d8a038839 100644 --- a/pkg/detectors/sheety/sheety_test.go +++ b/pkg/detectors/sheety/sheety_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/sherpadesk/sherpadesk.go b/pkg/detectors/sherpadesk/sherpadesk.go index fa9039a4fd7a..20ec74b74055 100644 --- a/pkg/detectors/sherpadesk/sherpadesk.go +++ b/pkg/detectors/sherpadesk/sherpadesk.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Sherpadesk secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/sherpadesk/sherpadesk_test.go b/pkg/detectors/sherpadesk/sherpadesk_test.go index c99dd325da8b..428614cf548a 100644 --- a/pkg/detectors/sherpadesk/sherpadesk_test.go +++ b/pkg/detectors/sherpadesk/sherpadesk_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/shipday/shipday.go b/pkg/detectors/shipday/shipday.go index 278f87b1078b..394995892894 100644 --- a/pkg/detectors/shipday/shipday.go +++ b/pkg/detectors/shipday/shipday.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Shipday secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/shipday/shipday_test.go b/pkg/detectors/shipday/shipday_test.go index c6cc50bf318e..b66cc6de2ca9 100644 --- a/pkg/detectors/shipday/shipday_test.go +++ b/pkg/detectors/shipday/shipday_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/shodankey/shodankey.go b/pkg/detectors/shodankey/shodankey.go index c6600151cc9d..91495f8dbc53 100644 --- a/pkg/detectors/shodankey/shodankey.go +++ b/pkg/detectors/shodankey/shodankey.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ShodanKey secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) // log.Println(dataStr) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/shopify/shopify.go b/pkg/detectors/shopify/shopify.go index bca4636ce92f..e36c84c6ec8d 100644 --- a/pkg/detectors/shopify/shopify.go +++ b/pkg/detectors/shopify/shopify.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Shopify secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) keyMatches := keyPat.FindAllString(dataStr, -1) domainMatches := domainPat.FindAllString(dataStr, -1) diff --git a/pkg/detectors/shopify/shopify_test.go b/pkg/detectors/shopify/shopify_test.go index 5dfd2ba22f1b..79770a8b486e 100644 --- a/pkg/detectors/shopify/shopify_test.go +++ b/pkg/detectors/shopify/shopify_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/shortcut/shortcut.go b/pkg/detectors/shortcut/shortcut.go index f5032853f945..e00fbce26c87 100644 --- a/pkg/detectors/shortcut/shortcut.go +++ b/pkg/detectors/shortcut/shortcut.go @@ -2,11 +2,12 @@ package shortcut import ( "context" - "github.com/go-errors/errors" "net/http" "regexp" "strings" + "github.com/go-errors/errors" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" @@ -32,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Shortcut secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/shotstack/shotstack.go b/pkg/detectors/shotstack/shotstack.go index 2cd96dd6ea93..0d878b22a695 100644 --- a/pkg/detectors/shotstack/shotstack.go +++ b/pkg/detectors/shotstack/shotstack.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Shotstack secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/shotstack/shotstack_test.go b/pkg/detectors/shotstack/shotstack_test.go index 5a2ec0483369..d5323aeeea32 100644 --- a/pkg/detectors/shotstack/shotstack_test.go +++ b/pkg/detectors/shotstack/shotstack_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/shutterstock/shutterstock.go b/pkg/detectors/shutterstock/shutterstock.go index d657c209e852..dc25fe62ec95 100644 --- a/pkg/detectors/shutterstock/shutterstock.go +++ b/pkg/detectors/shutterstock/shutterstock.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Shutterstock secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) secretMatches := secretPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/shutterstock/shutterstock_test.go b/pkg/detectors/shutterstock/shutterstock_test.go index 00fbe034fecb..66767f766532 100644 --- a/pkg/detectors/shutterstock/shutterstock_test.go +++ b/pkg/detectors/shutterstock/shutterstock_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/shutterstockoauth/shutterstockoauth.go b/pkg/detectors/shutterstockoauth/shutterstockoauth.go index 53e0a5fc429f..7b304a72f77a 100644 --- a/pkg/detectors/shutterstockoauth/shutterstockoauth.go +++ b/pkg/detectors/shutterstockoauth/shutterstockoauth.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ShutterstockOAuth secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/shutterstockoauth/shutterstockoauth_test.go b/pkg/detectors/shutterstockoauth/shutterstockoauth_test.go index d73d4771fd7c..57159c0105ff 100644 --- a/pkg/detectors/shutterstockoauth/shutterstockoauth_test.go +++ b/pkg/detectors/shutterstockoauth/shutterstockoauth_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/signable/signable.go b/pkg/detectors/signable/signable.go index d3e9c539afac..65fdcb94bb1c 100644 --- a/pkg/detectors/signable/signable.go +++ b/pkg/detectors/signable/signable.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Signable secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/signable/signable_test.go b/pkg/detectors/signable/signable_test.go index 9287a53c8c65..42b8d9839208 100644 --- a/pkg/detectors/signable/signable_test.go +++ b/pkg/detectors/signable/signable_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/signalwire/signalwire.go b/pkg/detectors/signalwire/signalwire.go index 95e6c756c5f6..d32f51d86ef6 100644 --- a/pkg/detectors/signalwire/signalwire.go +++ b/pkg/detectors/signalwire/signalwire.go @@ -35,7 +35,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Signalwire secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/signalwire/signalwire_test.go b/pkg/detectors/signalwire/signalwire_test.go index 50fc14142f1f..3da8786dc271 100644 --- a/pkg/detectors/signalwire/signalwire_test.go +++ b/pkg/detectors/signalwire/signalwire_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/signaturit/signaturit.go b/pkg/detectors/signaturit/signaturit.go index 626139a09e26..e73d73c5cf2f 100644 --- a/pkg/detectors/signaturit/signaturit.go +++ b/pkg/detectors/signaturit/signaturit.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Signaturit secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/signaturit/signaturit_test.go b/pkg/detectors/signaturit/signaturit_test.go index b706d742e259..2a8e387500d8 100644 --- a/pkg/detectors/signaturit/signaturit_test.go +++ b/pkg/detectors/signaturit/signaturit_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/signupgenius/signupgenius.go b/pkg/detectors/signupgenius/signupgenius.go index ae9b40428d10..eb8c751c0822 100644 --- a/pkg/detectors/signupgenius/signupgenius.go +++ b/pkg/detectors/signupgenius/signupgenius.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Signupgenius secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/signupgenius/signupgenius_test.go b/pkg/detectors/signupgenius/signupgenius_test.go index ffb74e529816..34b2ce08517c 100644 --- a/pkg/detectors/signupgenius/signupgenius_test.go +++ b/pkg/detectors/signupgenius/signupgenius_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/sigopt/sigopt.go b/pkg/detectors/sigopt/sigopt.go index 5fa5cf807ce2..65e8e510b63a 100644 --- a/pkg/detectors/sigopt/sigopt.go +++ b/pkg/detectors/sigopt/sigopt.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Sigopt secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/sigopt/sigopt_test.go b/pkg/detectors/sigopt/sigopt_test.go index c461d56d0fc2..cbad7a80e84f 100644 --- a/pkg/detectors/sigopt/sigopt_test.go +++ b/pkg/detectors/sigopt/sigopt_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/simfin/simfin.go b/pkg/detectors/simfin/simfin.go index 139b6a5953fe..f7353de63660 100644 --- a/pkg/detectors/simfin/simfin.go +++ b/pkg/detectors/simfin/simfin.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify SimFin secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/simfin/simfin_test.go b/pkg/detectors/simfin/simfin_test.go index 7ee417e72cd0..4daa7df72ce6 100644 --- a/pkg/detectors/simfin/simfin_test.go +++ b/pkg/detectors/simfin/simfin_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/simplesat/simplesat.go b/pkg/detectors/simplesat/simplesat.go index ec8aa9a259ed..fd8f03ad77ec 100644 --- a/pkg/detectors/simplesat/simplesat.go +++ b/pkg/detectors/simplesat/simplesat.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Simplesat secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/simplynoted/simplynoted.go b/pkg/detectors/simplynoted/simplynoted.go index 8ad3b0bca170..0b6a90e0cc89 100644 --- a/pkg/detectors/simplynoted/simplynoted.go +++ b/pkg/detectors/simplynoted/simplynoted.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify SimplyNoted secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/simplynoted/simplynoted_test.go b/pkg/detectors/simplynoted/simplynoted_test.go index aaf8f3ec83e6..a43dd1913c55 100644 --- a/pkg/detectors/simplynoted/simplynoted_test.go +++ b/pkg/detectors/simplynoted/simplynoted_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/simvoly/simvoly.go b/pkg/detectors/simvoly/simvoly.go index 7916444480ef..9271922c73b8 100644 --- a/pkg/detectors/simvoly/simvoly.go +++ b/pkg/detectors/simvoly/simvoly.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Simvoly secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/simvoly/simvoly_test.go b/pkg/detectors/simvoly/simvoly_test.go index 99585908c243..a4f3f08afbfa 100644 --- a/pkg/detectors/simvoly/simvoly_test.go +++ b/pkg/detectors/simvoly/simvoly_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/sinchmessage/sinchmessage.go b/pkg/detectors/sinchmessage/sinchmessage.go index 82571f21ad77..f8c3306c3285 100644 --- a/pkg/detectors/sinchmessage/sinchmessage.go +++ b/pkg/detectors/sinchmessage/sinchmessage.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify SinchMessage secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idmatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/sinchmessage/sinchmessage_test.go b/pkg/detectors/sinchmessage/sinchmessage_test.go index 022f04419616..9645fc98f2d3 100644 --- a/pkg/detectors/sinchmessage/sinchmessage_test.go +++ b/pkg/detectors/sinchmessage/sinchmessage_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/sirv/sirv.go b/pkg/detectors/sirv/sirv.go index f0a8f781211a..a10bf4718980 100644 --- a/pkg/detectors/sirv/sirv.go +++ b/pkg/detectors/sirv/sirv.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Sirv secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/siteleaf/siteleaf.go b/pkg/detectors/siteleaf/siteleaf.go index 6c8cea8dfd16..7c16d6c79f75 100644 --- a/pkg/detectors/siteleaf/siteleaf.go +++ b/pkg/detectors/siteleaf/siteleaf.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Siteleaf secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idmatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/siteleaf/siteleaf_test.go b/pkg/detectors/siteleaf/siteleaf_test.go index 64da43b0645b..096a6b1fc015 100644 --- a/pkg/detectors/siteleaf/siteleaf_test.go +++ b/pkg/detectors/siteleaf/siteleaf_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/skrappio/skrappio.go b/pkg/detectors/skrappio/skrappio.go index 0634170dde9f..132db684ca9f 100644 --- a/pkg/detectors/skrappio/skrappio.go +++ b/pkg/detectors/skrappio/skrappio.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Skrapio secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/skrappio/skrappio_test.go b/pkg/detectors/skrappio/skrappio_test.go index a1520533d0f7..b31e58a1bb23 100644 --- a/pkg/detectors/skrappio/skrappio_test.go +++ b/pkg/detectors/skrappio/skrappio_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/skybiometry/skybiometry.go b/pkg/detectors/skybiometry/skybiometry.go index ce1d7a11d576..6ad87bb270ac 100644 --- a/pkg/detectors/skybiometry/skybiometry.go +++ b/pkg/detectors/skybiometry/skybiometry.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify SkyBiometry secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) secretMatches := secretPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/skybiometry/skybiometry_test.go b/pkg/detectors/skybiometry/skybiometry_test.go index 2d829723fcce..ecb0d7eef543 100644 --- a/pkg/detectors/skybiometry/skybiometry_test.go +++ b/pkg/detectors/skybiometry/skybiometry_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/slack/slack.go b/pkg/detectors/slack/slack.go index 9e105bb86512..069c8c60ec6a 100644 --- a/pkg/detectors/slack/slack.go +++ b/pkg/detectors/slack/slack.go @@ -50,7 +50,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Slack secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) for _, tokenPat := range tokenPats { tokens := tokenPat.FindAllString(dataStr, -1) diff --git a/pkg/detectors/slackwebhook/slackwebhook.go b/pkg/detectors/slackwebhook/slackwebhook.go index 16bf24f0fde1..411ca0b8b06e 100644 --- a/pkg/detectors/slackwebhook/slackwebhook.go +++ b/pkg/detectors/slackwebhook/slackwebhook.go @@ -35,7 +35,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify SlackWebhook secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/smartsheets/smartsheets.go b/pkg/detectors/smartsheets/smartsheets.go index efbc5c25681d..d7ef1fbbd38c 100644 --- a/pkg/detectors/smartsheets/smartsheets.go +++ b/pkg/detectors/smartsheets/smartsheets.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Smartsheets secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/smartsheets/smartsheets_test.go b/pkg/detectors/smartsheets/smartsheets_test.go index 81facebc8e36..7cdfabd598fa 100644 --- a/pkg/detectors/smartsheets/smartsheets_test.go +++ b/pkg/detectors/smartsheets/smartsheets_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/smartystreets/smartystreets.go b/pkg/detectors/smartystreets/smartystreets.go index ad70f3d697f4..da00da092a31 100644 --- a/pkg/detectors/smartystreets/smartystreets.go +++ b/pkg/detectors/smartystreets/smartystreets.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify SmartyStreets secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/smartystreets/smartystreets_test.go b/pkg/detectors/smartystreets/smartystreets_test.go index b293f5914ebd..8513a676c42b 100644 --- a/pkg/detectors/smartystreets/smartystreets_test.go +++ b/pkg/detectors/smartystreets/smartystreets_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/smooch/smooch.go b/pkg/detectors/smooch/smooch.go index b967f2e5cc2c..49485dc0a353 100644 --- a/pkg/detectors/smooch/smooch.go +++ b/pkg/detectors/smooch/smooch.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Smooch secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) secretMatches := secretPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/smooch/smooch_test.go b/pkg/detectors/smooch/smooch_test.go index 7c5030306d0a..ce48b469b4e3 100644 --- a/pkg/detectors/smooch/smooch_test.go +++ b/pkg/detectors/smooch/smooch_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/snipcart/snipcart.go b/pkg/detectors/snipcart/snipcart.go index 748116fb5aa4..c962ac435c5f 100644 --- a/pkg/detectors/snipcart/snipcart.go +++ b/pkg/detectors/snipcart/snipcart.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Snipcart secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/snipcart/snipcart_test.go b/pkg/detectors/snipcart/snipcart_test.go index be3328a7f969..13075f338b2d 100644 --- a/pkg/detectors/snipcart/snipcart_test.go +++ b/pkg/detectors/snipcart/snipcart_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/snowflake/snowflake.go b/pkg/detectors/snowflake/snowflake.go index 2f7db62c7e3e..396a3e750d5d 100644 --- a/pkg/detectors/snowflake/snowflake.go +++ b/pkg/detectors/snowflake/snowflake.go @@ -4,13 +4,15 @@ import ( "context" "database/sql" "fmt" + "regexp" + "strings" + "unicode" + _ "github.com/snowflakedb/gosnowflake" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" - "regexp" - "strings" - "unicode" ) type Scanner struct { @@ -65,7 +67,7 @@ func meetsSnowflakePasswordRequirements(password string) (string, bool) { // FromData will find and optionally verify Snowflake secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) accountMatches := accountIdentifierPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/snowflake/snowflake_test.go b/pkg/detectors/snowflake/snowflake_test.go index 87af00365dfd..9339e77066bb 100644 --- a/pkg/detectors/snowflake/snowflake_test.go +++ b/pkg/detectors/snowflake/snowflake_test.go @@ -6,11 +6,12 @@ package snowflake import ( "context" "fmt" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "testing" "time" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/snykkey/snykkey.go b/pkg/detectors/snykkey/snykkey.go index 3a7b49830b48..4239da8302ff 100644 --- a/pkg/detectors/snykkey/snykkey.go +++ b/pkg/detectors/snykkey/snykkey.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify SnykKey secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/snykkey/snykkey_test.go b/pkg/detectors/snykkey/snykkey_test.go index 215677bb35df..6c00cbe4307a 100644 --- a/pkg/detectors/snykkey/snykkey_test.go +++ b/pkg/detectors/snykkey/snykkey_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/sonarcloud/sonarcloud.go b/pkg/detectors/sonarcloud/sonarcloud.go index 1b45f18a7eb3..5c085c23b890 100644 --- a/pkg/detectors/sonarcloud/sonarcloud.go +++ b/pkg/detectors/sonarcloud/sonarcloud.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify SonarCloud secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/sonarcloud/sonarcloud_test.go b/pkg/detectors/sonarcloud/sonarcloud_test.go index 2d1720b2cd94..2c69cf7c8a53 100644 --- a/pkg/detectors/sonarcloud/sonarcloud_test.go +++ b/pkg/detectors/sonarcloud/sonarcloud_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/sourcegraph/sourcegraph.go b/pkg/detectors/sourcegraph/sourcegraph.go index bf463fceb4ab..dfcc3bddbb9f 100644 --- a/pkg/detectors/sourcegraph/sourcegraph.go +++ b/pkg/detectors/sourcegraph/sourcegraph.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Sourcegraph secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/sourcegraph/sourcegraph_test.go b/pkg/detectors/sourcegraph/sourcegraph_test.go index d95181c52254..a14579673fd5 100644 --- a/pkg/detectors/sourcegraph/sourcegraph_test.go +++ b/pkg/detectors/sourcegraph/sourcegraph_test.go @@ -6,11 +6,12 @@ package sourcegraph import ( "context" "fmt" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "testing" "time" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/sourcegraphcody/sourcegraphcody.go b/pkg/detectors/sourcegraphcody/sourcegraphcody.go index b4fd7579f48c..273ad1b403ba 100644 --- a/pkg/detectors/sourcegraphcody/sourcegraphcody.go +++ b/pkg/detectors/sourcegraphcody/sourcegraphcody.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Sourcegraphcody secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/sparkpost/sparkpost.go b/pkg/detectors/sparkpost/sparkpost.go index ded611d2077c..a5011be4982a 100644 --- a/pkg/detectors/sparkpost/sparkpost.go +++ b/pkg/detectors/sparkpost/sparkpost.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Sparkpost secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/sparkpost/sparkpost_test.go b/pkg/detectors/sparkpost/sparkpost_test.go index f82992dda08e..b5599c4bc095 100644 --- a/pkg/detectors/sparkpost/sparkpost_test.go +++ b/pkg/detectors/sparkpost/sparkpost_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/speechtextai/speechtextai.go b/pkg/detectors/speechtextai/speechtextai.go index 2703fb0c8e99..b44715fa5720 100644 --- a/pkg/detectors/speechtextai/speechtextai.go +++ b/pkg/detectors/speechtextai/speechtextai.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify SpeechTextAI secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/speechtextai/speechtextai_test.go b/pkg/detectors/speechtextai/speechtextai_test.go index f759c6ce9b47..120e179c61c6 100644 --- a/pkg/detectors/speechtextai/speechtextai_test.go +++ b/pkg/detectors/speechtextai/speechtextai_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/splunkobservabilitytoken/splunkobservabilitytoken.go b/pkg/detectors/splunkobservabilitytoken/splunkobservabilitytoken.go index d9b2f56b3a5a..10a892662f56 100644 --- a/pkg/detectors/splunkobservabilitytoken/splunkobservabilitytoken.go +++ b/pkg/detectors/splunkobservabilitytoken/splunkobservabilitytoken.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify SplunkAccessToken secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) // log.Println(dataStr) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/splunkobservabilitytoken/splunkobservabilitytoken_test.go b/pkg/detectors/splunkobservabilitytoken/splunkobservabilitytoken_test.go index 6d172f8faa42..c1509d6f778c 100644 --- a/pkg/detectors/splunkobservabilitytoken/splunkobservabilitytoken_test.go +++ b/pkg/detectors/splunkobservabilitytoken/splunkobservabilitytoken_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/spoonacular/spoonacular.go b/pkg/detectors/spoonacular/spoonacular.go index 0dcf9caa3df5..27efc5023b2a 100644 --- a/pkg/detectors/spoonacular/spoonacular.go +++ b/pkg/detectors/spoonacular/spoonacular.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Spoonacular secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/spoonacular/spoonacular_test.go b/pkg/detectors/spoonacular/spoonacular_test.go index f4a786aca9e9..6f0731436d03 100644 --- a/pkg/detectors/spoonacular/spoonacular_test.go +++ b/pkg/detectors/spoonacular/spoonacular_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/sportradar/sportradar.go b/pkg/detectors/sportradar/sportradar.go index 49b49be3f9dd..c9f1c6ed7db2 100644 --- a/pkg/detectors/sportradar/sportradar.go +++ b/pkg/detectors/sportradar/sportradar.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify SportRadar secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/sportradar/sportradar_test.go b/pkg/detectors/sportradar/sportradar_test.go index c95c3c6194ff..0e8c5a6696ec 100644 --- a/pkg/detectors/sportradar/sportradar_test.go +++ b/pkg/detectors/sportradar/sportradar_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/sportsmonk/sportsmonk.go b/pkg/detectors/sportsmonk/sportsmonk.go index 2ea8030a5122..96bd66d53502 100644 --- a/pkg/detectors/sportsmonk/sportsmonk.go +++ b/pkg/detectors/sportsmonk/sportsmonk.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Sportsmonk secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/sportsmonk/sportsmonk_test.go b/pkg/detectors/sportsmonk/sportsmonk_test.go index a04837313d5a..578dca512ecc 100644 --- a/pkg/detectors/sportsmonk/sportsmonk_test.go +++ b/pkg/detectors/sportsmonk/sportsmonk_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/spotifykey/spotifykey.go b/pkg/detectors/spotifykey/spotifykey.go index e123c3adb40e..c5b0f1d90310 100644 --- a/pkg/detectors/spotifykey/spotifykey.go +++ b/pkg/detectors/spotifykey/spotifykey.go @@ -2,11 +2,11 @@ package spotifykey import ( "context" - "golang.org/x/oauth2" - "regexp" "strings" + "golang.org/x/oauth2" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" @@ -36,7 +36,7 @@ func (s Scanner) Keywords() []string { func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { ctx = context.WithValue(ctx, oauth2.HTTPClient, common.SaneHttpClient()) - dataStr := string(data) + dataStr := common.BytesToString(data) matches := secretPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/spotifykey/spotifykey_test.go b/pkg/detectors/spotifykey/spotifykey_test.go index 3aff9fe77336..ee999713aa04 100644 --- a/pkg/detectors/spotifykey/spotifykey_test.go +++ b/pkg/detectors/spotifykey/spotifykey_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/sqlserver/sqlserver.go b/pkg/detectors/sqlserver/sqlserver.go index 71798cc74069..dafbd0152a3e 100644 --- a/pkg/detectors/sqlserver/sqlserver.go +++ b/pkg/detectors/sqlserver/sqlserver.go @@ -7,6 +7,7 @@ import ( mssql "github.com/denisenkom/go-mssqldb" "github.com/denisenkom/go-mssqldb/msdsn" + "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" diff --git a/pkg/detectors/square/square.go b/pkg/detectors/square/square.go index 481ddb9ff5f1..e8c74e7f2745 100644 --- a/pkg/detectors/square/square.go +++ b/pkg/detectors/square/square.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Square secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) // Surprisingly there are still a lot of false positives! So, also doing substring check for square. if !strings.Contains(strings.ToLower(dataStr), "square") { @@ -68,7 +68,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", res)) req.Header.Add("Content-Type", "application/json") // unclear if this version needs to be set or matters, seems to work without, but docs want it - //req.Header.Add("Square-Version", "2020-08-12") + // req.Header.Add("Square-Version", "2020-08-12") res, err := client.Do(req) if err == nil { res.Body.Close() // The request body is unused. diff --git a/pkg/detectors/square/square_test.go b/pkg/detectors/square/square_test.go index 913cf9d0ebc0..8cf64d25c846 100644 --- a/pkg/detectors/square/square_test.go +++ b/pkg/detectors/square/square_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" diff --git a/pkg/detectors/squareapp/squareapp.go b/pkg/detectors/squareapp/squareapp.go index 6b388fbc2906..99467f18def2 100644 --- a/pkg/detectors/squareapp/squareapp.go +++ b/pkg/detectors/squareapp/squareapp.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify SquareApp secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllString(dataStr, -1) secMatches := secPat.FindAllString(dataStr, -1) diff --git a/pkg/detectors/squareapp/squareapp_test.go b/pkg/detectors/squareapp/squareapp_test.go index ad9874c6fe34..e36008c59ce2 100644 --- a/pkg/detectors/squareapp/squareapp_test.go +++ b/pkg/detectors/squareapp/squareapp_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" diff --git a/pkg/detectors/squarespace/squarespace.go b/pkg/detectors/squarespace/squarespace.go index 174e66a44e4a..d35e2fd02de1 100644 --- a/pkg/detectors/squarespace/squarespace.go +++ b/pkg/detectors/squarespace/squarespace.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Squarespace secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/squarespace/squarespace_test.go b/pkg/detectors/squarespace/squarespace_test.go index 1874e5816f68..9ca6cc342212 100644 --- a/pkg/detectors/squarespace/squarespace_test.go +++ b/pkg/detectors/squarespace/squarespace_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/squareup/squareup.go b/pkg/detectors/squareup/squareup.go index 62497ed3f30a..5dd77a8f74e6 100644 --- a/pkg/detectors/squareup/squareup.go +++ b/pkg/detectors/squareup/squareup.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Squareup secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/sslmate/sslmate.go b/pkg/detectors/sslmate/sslmate.go index 276e1ce34674..dc59c5c8c620 100644 --- a/pkg/detectors/sslmate/sslmate.go +++ b/pkg/detectors/sslmate/sslmate.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify SslMate secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/sslmate/sslmate_test.go b/pkg/detectors/sslmate/sslmate_test.go index 8244136b1fc8..44b6d78c2171 100644 --- a/pkg/detectors/sslmate/sslmate_test.go +++ b/pkg/detectors/sslmate/sslmate_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/statuscake/statuscake.go b/pkg/detectors/statuscake/statuscake.go index 92640ca58e3a..895e086c5233 100644 --- a/pkg/detectors/statuscake/statuscake.go +++ b/pkg/detectors/statuscake/statuscake.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Statuscake secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/statuscake/statuscake_test.go b/pkg/detectors/statuscake/statuscake_test.go index 291347382cc6..6be0d6b4c4f2 100644 --- a/pkg/detectors/statuscake/statuscake_test.go +++ b/pkg/detectors/statuscake/statuscake_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/statuspage/statuspage.go b/pkg/detectors/statuspage/statuspage.go index acc01afb87d6..3a4672d02ec6 100644 --- a/pkg/detectors/statuspage/statuspage.go +++ b/pkg/detectors/statuspage/statuspage.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Statuspage secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/statuspage/statuspage_test.go b/pkg/detectors/statuspage/statuspage_test.go index f66e0a71d2aa..ad106b06180b 100644 --- a/pkg/detectors/statuspage/statuspage_test.go +++ b/pkg/detectors/statuspage/statuspage_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/statuspal/statuspal.go b/pkg/detectors/statuspal/statuspal.go index 36d9b737ddf9..5ab65a562411 100644 --- a/pkg/detectors/statuspal/statuspal.go +++ b/pkg/detectors/statuspal/statuspal.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Statuspal secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/statuspal/statuspal_test.go b/pkg/detectors/statuspal/statuspal_test.go index 8f43e61416b0..5aca72e195fe 100644 --- a/pkg/detectors/statuspal/statuspal_test.go +++ b/pkg/detectors/statuspal/statuspal_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/stitchdata/stitchdata.go b/pkg/detectors/stitchdata/stitchdata.go index c66ef7a08a9a..0a2790c5dbde 100644 --- a/pkg/detectors/stitchdata/stitchdata.go +++ b/pkg/detectors/stitchdata/stitchdata.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Stitchdata secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/stitchdata/stitchdata_test.go b/pkg/detectors/stitchdata/stitchdata_test.go index 42120ff0379d..9ec0416de401 100644 --- a/pkg/detectors/stitchdata/stitchdata_test.go +++ b/pkg/detectors/stitchdata/stitchdata_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/stockdata/stockdata.go b/pkg/detectors/stockdata/stockdata.go index d105d35286c0..1ba264a76c32 100644 --- a/pkg/detectors/stockdata/stockdata.go +++ b/pkg/detectors/stockdata/stockdata.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Stockdata secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/stockdata/stockdata_test.go b/pkg/detectors/stockdata/stockdata_test.go index dd4654864b26..cc546a9b6036 100644 --- a/pkg/detectors/stockdata/stockdata_test.go +++ b/pkg/detectors/stockdata/stockdata_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/storecove/storecove.go b/pkg/detectors/storecove/storecove.go index 0ea29d40f420..f8a83a5fef1f 100644 --- a/pkg/detectors/storecove/storecove.go +++ b/pkg/detectors/storecove/storecove.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Storecove secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/storecove/storecove_test.go b/pkg/detectors/storecove/storecove_test.go index 42013daad65f..cdde11e746e3 100644 --- a/pkg/detectors/storecove/storecove_test.go +++ b/pkg/detectors/storecove/storecove_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/stormboard/stormboard.go b/pkg/detectors/stormboard/stormboard.go index 96996dfe2d64..bab00664d287 100644 --- a/pkg/detectors/stormboard/stormboard.go +++ b/pkg/detectors/stormboard/stormboard.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Stormboard secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/stormboard/stormboard_test.go b/pkg/detectors/stormboard/stormboard_test.go index 2f1618fa1d95..d263812c714d 100644 --- a/pkg/detectors/stormboard/stormboard_test.go +++ b/pkg/detectors/stormboard/stormboard_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/stormglass/stormglass.go b/pkg/detectors/stormglass/stormglass.go index cc21564fbdbe..926f2292c237 100644 --- a/pkg/detectors/stormglass/stormglass.go +++ b/pkg/detectors/stormglass/stormglass.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Stormglass secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/stormglass/stormglass_test.go b/pkg/detectors/stormglass/stormglass_test.go index d4474a05febb..1c25f2dc201c 100644 --- a/pkg/detectors/stormglass/stormglass_test.go +++ b/pkg/detectors/stormglass/stormglass_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/storyblok/storyblok.go b/pkg/detectors/storyblok/storyblok.go index 938cf24e891b..c3b83ffb697a 100644 --- a/pkg/detectors/storyblok/storyblok.go +++ b/pkg/detectors/storyblok/storyblok.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Storyblok secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/storyblok/storyblok_test.go b/pkg/detectors/storyblok/storyblok_test.go index 85c41035a600..209a64c4fd87 100644 --- a/pkg/detectors/storyblok/storyblok_test.go +++ b/pkg/detectors/storyblok/storyblok_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/storychief/storychief.go b/pkg/detectors/storychief/storychief.go index dbc8b2dd88b2..460ec74adfb1 100644 --- a/pkg/detectors/storychief/storychief.go +++ b/pkg/detectors/storychief/storychief.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Storychief secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/strava/strava.go b/pkg/detectors/strava/strava.go index 50e934015cfb..29dad9c0e89d 100644 --- a/pkg/detectors/strava/strava.go +++ b/pkg/detectors/strava/strava.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Strava secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) secretMatches := secretPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/strava/strava_test.go b/pkg/detectors/strava/strava_test.go index 93b10ddea2b0..b2e6bb893b02 100644 --- a/pkg/detectors/strava/strava_test.go +++ b/pkg/detectors/strava/strava_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/streak/streak.go b/pkg/detectors/streak/streak.go index d473e405db68..250f356e808a 100644 --- a/pkg/detectors/streak/streak.go +++ b/pkg/detectors/streak/streak.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Streak secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/streak/streak_test.go b/pkg/detectors/streak/streak_test.go index a9d256ae06ff..556407e090b6 100644 --- a/pkg/detectors/streak/streak_test.go +++ b/pkg/detectors/streak/streak_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/stripe/stripe.go b/pkg/detectors/stripe/stripe.go index 98c3a7682072..bce8da912282 100644 --- a/pkg/detectors/stripe/stripe.go +++ b/pkg/detectors/stripe/stripe.go @@ -17,7 +17,7 @@ type Scanner struct{} var _ detectors.Detector = (*Scanner)(nil) var ( - //doesn't include test keys with "sk_test" + // doesn't include test keys with "sk_test" secretKey = regexp.MustCompile(`[rs]k_live_[a-zA-Z0-9]{20,30}`) ) @@ -30,7 +30,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Stripe secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := secretKey.FindAllString(dataStr, -1) diff --git a/pkg/detectors/stripe/stripe_test.go b/pkg/detectors/stripe/stripe_test.go index 61696eaaeab5..0611e0c96dc7 100644 --- a/pkg/detectors/stripe/stripe_test.go +++ b/pkg/detectors/stripe/stripe_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" diff --git a/pkg/detectors/stripo/stripo.go b/pkg/detectors/stripo/stripo.go index e79cb8582704..b3eabc08a7e4 100644 --- a/pkg/detectors/stripo/stripo.go +++ b/pkg/detectors/stripo/stripo.go @@ -30,7 +30,7 @@ func (s Scanner) Keywords() []string { } func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/stytch/stytch.go b/pkg/detectors/stytch/stytch.go index 0d907609a5e9..e162c568af95 100644 --- a/pkg/detectors/stytch/stytch.go +++ b/pkg/detectors/stytch/stytch.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Stytch secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/stytch/stytch_test.go b/pkg/detectors/stytch/stytch_test.go index 0d1722dae686..ccb5d1cfa34f 100644 --- a/pkg/detectors/stytch/stytch_test.go +++ b/pkg/detectors/stytch/stytch_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/sugester/sugester.go b/pkg/detectors/sugester/sugester.go index 80681dd6c6e1..c35a4b40c1d6 100644 --- a/pkg/detectors/sugester/sugester.go +++ b/pkg/detectors/sugester/sugester.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Sugester secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) domainMatches := domainPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/sumologickey/sumologickey.go b/pkg/detectors/sumologickey/sumologickey.go index 8f7312bc922a..55ff2a828347 100644 --- a/pkg/detectors/sumologickey/sumologickey.go +++ b/pkg/detectors/sumologickey/sumologickey.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify SumoLogicKey secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/sumologickey/sumologickey_test.go b/pkg/detectors/sumologickey/sumologickey_test.go index e95e34041d37..ac7c37db5f49 100644 --- a/pkg/detectors/sumologickey/sumologickey_test.go +++ b/pkg/detectors/sumologickey/sumologickey_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/supabasetoken/supabasetoken.go b/pkg/detectors/supabasetoken/supabasetoken.go index 7f5b3cb94458..ad1aa2eaa1f5 100644 --- a/pkg/detectors/supabasetoken/supabasetoken.go +++ b/pkg/detectors/supabasetoken/supabasetoken.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Supabasetoken secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/supernotesapi/supernotesapi.go b/pkg/detectors/supernotesapi/supernotesapi.go index 98b2c5eb04ca..e7fde15413c9 100644 --- a/pkg/detectors/supernotesapi/supernotesapi.go +++ b/pkg/detectors/supernotesapi/supernotesapi.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify SuperNotesAPI secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/surveyanyplace/surveyanyplace.go b/pkg/detectors/surveyanyplace/surveyanyplace.go index dd143ecb6faf..2aba405df90c 100644 --- a/pkg/detectors/surveyanyplace/surveyanyplace.go +++ b/pkg/detectors/surveyanyplace/surveyanyplace.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify SurveyAnyplace secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idmatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/surveyanyplace/surveyanyplace_test.go b/pkg/detectors/surveyanyplace/surveyanyplace_test.go index 4f57a6215fe3..48daf94efafa 100644 --- a/pkg/detectors/surveyanyplace/surveyanyplace_test.go +++ b/pkg/detectors/surveyanyplace/surveyanyplace_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/surveybot/surveybot.go b/pkg/detectors/surveybot/surveybot.go index 90119f17b1e1..5a2b2adba2a8 100644 --- a/pkg/detectors/surveybot/surveybot.go +++ b/pkg/detectors/surveybot/surveybot.go @@ -36,7 +36,7 @@ type response struct { // FromData will find and optionally verify SurveyBot secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/surveybot/surveybot_test.go b/pkg/detectors/surveybot/surveybot_test.go index 9fe32246e014..824b6fae4ada 100644 --- a/pkg/detectors/surveybot/surveybot_test.go +++ b/pkg/detectors/surveybot/surveybot_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/surveysparrow/surveysparrow.go b/pkg/detectors/surveysparrow/surveysparrow.go index cf7e998df597..af5b678f2218 100644 --- a/pkg/detectors/surveysparrow/surveysparrow.go +++ b/pkg/detectors/surveysparrow/surveysparrow.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify SurveySparrow secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/surveysparrow/surveysparrow_test.go b/pkg/detectors/surveysparrow/surveysparrow_test.go index 2a7c7be7018b..fa9c196e1652 100644 --- a/pkg/detectors/surveysparrow/surveysparrow_test.go +++ b/pkg/detectors/surveysparrow/surveysparrow_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/survicate/survicate.go b/pkg/detectors/survicate/survicate.go index c1848ca2f5fd..fd3a3f604157 100644 --- a/pkg/detectors/survicate/survicate.go +++ b/pkg/detectors/survicate/survicate.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Survicate secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/survicate/survicate_test.go b/pkg/detectors/survicate/survicate_test.go index c9c93ca73d39..114fe6631e9f 100644 --- a/pkg/detectors/survicate/survicate_test.go +++ b/pkg/detectors/survicate/survicate_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/swell/swell.go b/pkg/detectors/swell/swell.go index 9830266dcc39..240928319398 100644 --- a/pkg/detectors/swell/swell.go +++ b/pkg/detectors/swell/swell.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Swell secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/swell/swell_test.go b/pkg/detectors/swell/swell_test.go index 1994ea9231c4..28b8bc343aa4 100644 --- a/pkg/detectors/swell/swell_test.go +++ b/pkg/detectors/swell/swell_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/swiftype/swiftype.go b/pkg/detectors/swiftype/swiftype.go index d6066fb74c3d..5a1ee816ddff 100644 --- a/pkg/detectors/swiftype/swiftype.go +++ b/pkg/detectors/swiftype/swiftype.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Swiftype secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/swiftype/swiftype_test.go b/pkg/detectors/swiftype/swiftype_test.go index 95930c642216..33a6392b697b 100644 --- a/pkg/detectors/swiftype/swiftype_test.go +++ b/pkg/detectors/swiftype/swiftype_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/tailscale/tailscale.go b/pkg/detectors/tailscale/tailscale.go index cc51b3c2eb64..de5ca6190657 100644 --- a/pkg/detectors/tailscale/tailscale.go +++ b/pkg/detectors/tailscale/tailscale.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Tailscaleapi secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/tallyfy/tallyfy.go b/pkg/detectors/tallyfy/tallyfy.go index bb48e03924b2..37f0fbdfcd78 100644 --- a/pkg/detectors/tallyfy/tallyfy.go +++ b/pkg/detectors/tallyfy/tallyfy.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Tallyfy secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/tatumio/tatumio.go b/pkg/detectors/tatumio/tatumio.go index f98c4fb497c0..380bfe08cd09 100644 --- a/pkg/detectors/tatumio/tatumio.go +++ b/pkg/detectors/tatumio/tatumio.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify TatumIO secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/tatumio/tatumio_test.go b/pkg/detectors/tatumio/tatumio_test.go index 885ed5268f9b..f922a3d2abac 100644 --- a/pkg/detectors/tatumio/tatumio_test.go +++ b/pkg/detectors/tatumio/tatumio_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/taxjar/taxjar.go b/pkg/detectors/taxjar/taxjar.go index ead1aedf385a..cd340e0d05de 100644 --- a/pkg/detectors/taxjar/taxjar.go +++ b/pkg/detectors/taxjar/taxjar.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Taxjar secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/taxjar/taxjar_test.go b/pkg/detectors/taxjar/taxjar_test.go index 1eb5ea716137..478e2a803fd6 100644 --- a/pkg/detectors/taxjar/taxjar_test.go +++ b/pkg/detectors/taxjar/taxjar_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/teamgate/teamgate.go b/pkg/detectors/teamgate/teamgate.go index 9ed1f861bbfa..7d79f5cd4f76 100644 --- a/pkg/detectors/teamgate/teamgate.go +++ b/pkg/detectors/teamgate/teamgate.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Teamgate secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := tokenPat.FindAllStringSubmatch(dataStr, -1) keyMatches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/teamgate/teamgate_test.go b/pkg/detectors/teamgate/teamgate_test.go index 8ff2b5e7d61e..ef7a662dc476 100644 --- a/pkg/detectors/teamgate/teamgate_test.go +++ b/pkg/detectors/teamgate/teamgate_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/teamworkcrm/teamworkcrm.go b/pkg/detectors/teamworkcrm/teamworkcrm.go index 5c324addd970..670440d10cd4 100644 --- a/pkg/detectors/teamworkcrm/teamworkcrm.go +++ b/pkg/detectors/teamworkcrm/teamworkcrm.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify TeamworkCRM secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/teamworkdesk/teamworkdesk.go b/pkg/detectors/teamworkdesk/teamworkdesk.go index 0f4dbe089fad..3134f688152d 100644 --- a/pkg/detectors/teamworkdesk/teamworkdesk.go +++ b/pkg/detectors/teamworkdesk/teamworkdesk.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify TeamworkDesk secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/teamworkspaces/teamworkspaces.go b/pkg/detectors/teamworkspaces/teamworkspaces.go index c142753d8963..32b3457f83b9 100644 --- a/pkg/detectors/teamworkspaces/teamworkspaces.go +++ b/pkg/detectors/teamworkspaces/teamworkspaces.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify TeamworkSpaces secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/technicalanalysisapi/technicalanalysisapi.go b/pkg/detectors/technicalanalysisapi/technicalanalysisapi.go index d23bab7ad3ca..2c2a0f28ee59 100644 --- a/pkg/detectors/technicalanalysisapi/technicalanalysisapi.go +++ b/pkg/detectors/technicalanalysisapi/technicalanalysisapi.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify TechnicalAnalysisApi secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/technicalanalysisapi/technicalanalysisapi_test.go b/pkg/detectors/technicalanalysisapi/technicalanalysisapi_test.go index b3ca4b3cb613..2ded647d638d 100644 --- a/pkg/detectors/technicalanalysisapi/technicalanalysisapi_test.go +++ b/pkg/detectors/technicalanalysisapi/technicalanalysisapi_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/tefter/tefter.go b/pkg/detectors/tefter/tefter.go index 009ddc8186d2..3d93a0089e5c 100644 --- a/pkg/detectors/tefter/tefter.go +++ b/pkg/detectors/tefter/tefter.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Tefter secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/tefter/tefter_test.go b/pkg/detectors/tefter/tefter_test.go index 607e8e421364..53ba7c35b413 100644 --- a/pkg/detectors/tefter/tefter_test.go +++ b/pkg/detectors/tefter/tefter_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/telegrambottoken/telegrambottoken.go b/pkg/detectors/telegrambottoken/telegrambottoken.go index a42b9cd60fb7..7b0795350b9f 100644 --- a/pkg/detectors/telegrambottoken/telegrambottoken.go +++ b/pkg/detectors/telegrambottoken/telegrambottoken.go @@ -3,7 +3,6 @@ package telegrambottoken import ( "context" "encoding/json" - // "fmt" "net/http" "regexp" @@ -37,7 +36,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify TelegramBotToken secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/telegrambottoken/telegrambottoken_test.go b/pkg/detectors/telegrambottoken/telegrambottoken_test.go index bd7aab393043..93e698c96754 100644 --- a/pkg/detectors/telegrambottoken/telegrambottoken_test.go +++ b/pkg/detectors/telegrambottoken/telegrambottoken_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/teletype/teletype.go b/pkg/detectors/teletype/teletype.go index c01c77e93bc7..7905e8106c14 100644 --- a/pkg/detectors/teletype/teletype.go +++ b/pkg/detectors/teletype/teletype.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Teletype secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/teletype/teletype_test.go b/pkg/detectors/teletype/teletype_test.go index c36edd0e604e..11f25b8ff74d 100644 --- a/pkg/detectors/teletype/teletype_test.go +++ b/pkg/detectors/teletype/teletype_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/telnyx/telnyx.go b/pkg/detectors/telnyx/telnyx.go index a044993c1c50..f06253a55854 100644 --- a/pkg/detectors/telnyx/telnyx.go +++ b/pkg/detectors/telnyx/telnyx.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Telnyx secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/telnyx/telnyx_test.go b/pkg/detectors/telnyx/telnyx_test.go index 7eb3a8848482..a17c2160ae85 100644 --- a/pkg/detectors/telnyx/telnyx_test.go +++ b/pkg/detectors/telnyx/telnyx_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/terraformcloudpersonaltoken/terraformcloudpersonaltoken.go b/pkg/detectors/terraformcloudpersonaltoken/terraformcloudpersonaltoken.go index dbb54c7a181c..4d8d6664cfc8 100644 --- a/pkg/detectors/terraformcloudpersonaltoken/terraformcloudpersonaltoken.go +++ b/pkg/detectors/terraformcloudpersonaltoken/terraformcloudpersonaltoken.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify TerraformCloudPersonalToken secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/terraformcloudpersonaltoken/terraformcloudpersonaltoken_test.go b/pkg/detectors/terraformcloudpersonaltoken/terraformcloudpersonaltoken_test.go index 2d0f54d3bb6d..2f1c90907bd0 100644 --- a/pkg/detectors/terraformcloudpersonaltoken/terraformcloudpersonaltoken_test.go +++ b/pkg/detectors/terraformcloudpersonaltoken/terraformcloudpersonaltoken_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/testingbot/testingbot.go b/pkg/detectors/testingbot/testingbot.go index 93240bd56e15..41ea895c7033 100644 --- a/pkg/detectors/testingbot/testingbot.go +++ b/pkg/detectors/testingbot/testingbot.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify TestingBot secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idmatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/testingbot/testingbot_test.go b/pkg/detectors/testingbot/testingbot_test.go index a0a9b2a8a21d..6695f4685a2d 100644 --- a/pkg/detectors/testingbot/testingbot_test.go +++ b/pkg/detectors/testingbot/testingbot_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/text2data/text2data.go b/pkg/detectors/text2data/text2data.go index 7c602f4debf9..14b4b85a9a9b 100644 --- a/pkg/detectors/text2data/text2data.go +++ b/pkg/detectors/text2data/text2data.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Text2Data secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/text2data/text2data_test.go b/pkg/detectors/text2data/text2data_test.go index da39cafcfabf..c3714491edaf 100644 --- a/pkg/detectors/text2data/text2data_test.go +++ b/pkg/detectors/text2data/text2data_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/textmagic/textmagic.go b/pkg/detectors/textmagic/textmagic.go index 641f712b0534..3d27fbedcff0 100644 --- a/pkg/detectors/textmagic/textmagic.go +++ b/pkg/detectors/textmagic/textmagic.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Textmagic secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) userMatches := userPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/textmagic/textmagic_test.go b/pkg/detectors/textmagic/textmagic_test.go index 251e20b12f57..49dee418c158 100644 --- a/pkg/detectors/textmagic/textmagic_test.go +++ b/pkg/detectors/textmagic/textmagic_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/theoddsapi/theoddsapi.go b/pkg/detectors/theoddsapi/theoddsapi.go index 5161a81ee876..e61cc3136838 100644 --- a/pkg/detectors/theoddsapi/theoddsapi.go +++ b/pkg/detectors/theoddsapi/theoddsapi.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify TheOddsApi secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/thinkific/thinkific.go b/pkg/detectors/thinkific/thinkific.go index b34c442b64bc..9f70a96ffd87 100644 --- a/pkg/detectors/thinkific/thinkific.go +++ b/pkg/detectors/thinkific/thinkific.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Thinkific secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) domainMatches := domainPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/thinkific/thinkific_test.go b/pkg/detectors/thinkific/thinkific_test.go index d9445616c73f..78def909ef21 100644 --- a/pkg/detectors/thinkific/thinkific_test.go +++ b/pkg/detectors/thinkific/thinkific_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/thousandeyes/thousandeyes.go b/pkg/detectors/thousandeyes/thousandeyes.go index 14fcb0c28154..4b84ff05d5e9 100644 --- a/pkg/detectors/thousandeyes/thousandeyes.go +++ b/pkg/detectors/thousandeyes/thousandeyes.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ThousandEyes secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) emailMatches := email.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/thousandeyes/thousandeyes_test.go b/pkg/detectors/thousandeyes/thousandeyes_test.go index 8a5ea0bead86..8a0681ccb69c 100644 --- a/pkg/detectors/thousandeyes/thousandeyes_test.go +++ b/pkg/detectors/thousandeyes/thousandeyes_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/ticketmaster/ticketmaster.go b/pkg/detectors/ticketmaster/ticketmaster.go index 0d8864423d6d..2f0fab2f88d8 100644 --- a/pkg/detectors/ticketmaster/ticketmaster.go +++ b/pkg/detectors/ticketmaster/ticketmaster.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify TicketMaster secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/ticketmaster/ticketmaster_test.go b/pkg/detectors/ticketmaster/ticketmaster_test.go index 6cdbefb91d97..e0bbf35efe0f 100644 --- a/pkg/detectors/ticketmaster/ticketmaster_test.go +++ b/pkg/detectors/ticketmaster/ticketmaster_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/tickettailor/tickettailor.go b/pkg/detectors/tickettailor/tickettailor.go index 8c363ca3a407..c60ba6bb4644 100644 --- a/pkg/detectors/tickettailor/tickettailor.go +++ b/pkg/detectors/tickettailor/tickettailor.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Tickettailor secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/tickettailor/tickettailor_test.go b/pkg/detectors/tickettailor/tickettailor_test.go index c391c47d6d0e..d4feac9011e0 100644 --- a/pkg/detectors/tickettailor/tickettailor_test.go +++ b/pkg/detectors/tickettailor/tickettailor_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/tiingo/tiingo.go b/pkg/detectors/tiingo/tiingo.go index 54af3a52b981..f148d3f55a3b 100644 --- a/pkg/detectors/tiingo/tiingo.go +++ b/pkg/detectors/tiingo/tiingo.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Tiingo secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/tiingo/tiingo_test.go b/pkg/detectors/tiingo/tiingo_test.go index 64e75d3dca19..46044d5c2acf 100644 --- a/pkg/detectors/tiingo/tiingo_test.go +++ b/pkg/detectors/tiingo/tiingo_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/timecamp/timecamp.go b/pkg/detectors/timecamp/timecamp.go index 53d833f012a3..83110d9d4435 100644 --- a/pkg/detectors/timecamp/timecamp.go +++ b/pkg/detectors/timecamp/timecamp.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify TimeCamp secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/timecamp/timecamp_test.go b/pkg/detectors/timecamp/timecamp_test.go index d091ae3ec4c8..d9ac2569f076 100644 --- a/pkg/detectors/timecamp/timecamp_test.go +++ b/pkg/detectors/timecamp/timecamp_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/timezoneapi/timezoneapi.go b/pkg/detectors/timezoneapi/timezoneapi.go index 7f6ab3cc47a0..60199e173a65 100644 --- a/pkg/detectors/timezoneapi/timezoneapi.go +++ b/pkg/detectors/timezoneapi/timezoneapi.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Timezoneapi secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/tineswebhook/tineswebhook.go b/pkg/detectors/tineswebhook/tineswebhook.go index 78aa4e64d600..f03b673acb53 100644 --- a/pkg/detectors/tineswebhook/tineswebhook.go +++ b/pkg/detectors/tineswebhook/tineswebhook.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify TinesWebhook secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/tineswebhook/tineswebhook_test.go b/pkg/detectors/tineswebhook/tineswebhook_test.go index f80b9e7fb626..4c7b460ac324 100644 --- a/pkg/detectors/tineswebhook/tineswebhook_test.go +++ b/pkg/detectors/tineswebhook/tineswebhook_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/tly/tly.go b/pkg/detectors/tly/tly.go index 220ca34aff0a..18ebe9cc8f40 100644 --- a/pkg/detectors/tly/tly.go +++ b/pkg/detectors/tly/tly.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify TLy secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/tmetric/tmetric.go b/pkg/detectors/tmetric/tmetric.go index d14387504965..e006ff1e3ce7 100644 --- a/pkg/detectors/tmetric/tmetric.go +++ b/pkg/detectors/tmetric/tmetric.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Tmetric secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/tmetric/tmetric_test.go b/pkg/detectors/tmetric/tmetric_test.go index dfe3154dd306..86a928fc42f9 100644 --- a/pkg/detectors/tmetric/tmetric_test.go +++ b/pkg/detectors/tmetric/tmetric_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/todoist/todoist.go b/pkg/detectors/todoist/todoist.go index 0681bf2a7335..56a239a9b63c 100644 --- a/pkg/detectors/todoist/todoist.go +++ b/pkg/detectors/todoist/todoist.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Todoist secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/todoist/todoist_test.go b/pkg/detectors/todoist/todoist_test.go index de8f825b06bc..aa10700fea47 100644 --- a/pkg/detectors/todoist/todoist_test.go +++ b/pkg/detectors/todoist/todoist_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/toggltrack/toggltrack.go b/pkg/detectors/toggltrack/toggltrack.go index 0baeec3a07b7..1698551e75c1 100644 --- a/pkg/detectors/toggltrack/toggltrack.go +++ b/pkg/detectors/toggltrack/toggltrack.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify TogglTrack secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/toggltrack/toggltrack_test.go b/pkg/detectors/toggltrack/toggltrack_test.go index 2e21c7ef7e17..0fa0657e8d5f 100644 --- a/pkg/detectors/toggltrack/toggltrack_test.go +++ b/pkg/detectors/toggltrack/toggltrack_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/tokeet/tokeet.go b/pkg/detectors/tokeet/tokeet.go index 20b1d99356e5..a682da67c4a1 100644 --- a/pkg/detectors/tokeet/tokeet.go +++ b/pkg/detectors/tokeet/tokeet.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Tokeet secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idmatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/tokeet/tokeet_test.go b/pkg/detectors/tokeet/tokeet_test.go index 0b8ce70f3b40..6de5343554a2 100644 --- a/pkg/detectors/tokeet/tokeet_test.go +++ b/pkg/detectors/tokeet/tokeet_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/tomorrowio/tomorrowio.go b/pkg/detectors/tomorrowio/tomorrowio.go index a8d48cdf9d86..cbab7129ebad 100644 --- a/pkg/detectors/tomorrowio/tomorrowio.go +++ b/pkg/detectors/tomorrowio/tomorrowio.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify TomorrowIO secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/tomorrowio/tomorrowio_test.go b/pkg/detectors/tomorrowio/tomorrowio_test.go index 4e76e8475daf..06e5e7971210 100644 --- a/pkg/detectors/tomorrowio/tomorrowio_test.go +++ b/pkg/detectors/tomorrowio/tomorrowio_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/tomtom/tomtom.go b/pkg/detectors/tomtom/tomtom.go index 1d5f82e0b680..1b1c58858088 100644 --- a/pkg/detectors/tomtom/tomtom.go +++ b/pkg/detectors/tomtom/tomtom.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Tomtom secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/tomtom/tomtom_test.go b/pkg/detectors/tomtom/tomtom_test.go index 2a5c854124a2..bbb53b43455f 100644 --- a/pkg/detectors/tomtom/tomtom_test.go +++ b/pkg/detectors/tomtom/tomtom_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/tradier/tradier.go b/pkg/detectors/tradier/tradier.go index d255293574b1..22b4bdb3ddcf 100644 --- a/pkg/detectors/tradier/tradier.go +++ b/pkg/detectors/tradier/tradier.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Tradier secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/transferwise/transferwise.go b/pkg/detectors/transferwise/transferwise.go index 10165f27e2e3..f3d32a6d73fe 100644 --- a/pkg/detectors/transferwise/transferwise.go +++ b/pkg/detectors/transferwise/transferwise.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Transferwise secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/transferwise/transferwise_test.go b/pkg/detectors/transferwise/transferwise_test.go index 4c0cb0a9e056..15e678d4f540 100644 --- a/pkg/detectors/transferwise/transferwise_test.go +++ b/pkg/detectors/transferwise/transferwise_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/travelpayouts/travelpayouts.go b/pkg/detectors/travelpayouts/travelpayouts.go index a2464087fe7d..99983371df58 100644 --- a/pkg/detectors/travelpayouts/travelpayouts.go +++ b/pkg/detectors/travelpayouts/travelpayouts.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify TravelPayouts secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/travelpayouts/travelpayouts_test.go b/pkg/detectors/travelpayouts/travelpayouts_test.go index 3d057f1986b0..9b21d7d0cc4b 100644 --- a/pkg/detectors/travelpayouts/travelpayouts_test.go +++ b/pkg/detectors/travelpayouts/travelpayouts_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/travisci/travisci.go b/pkg/detectors/travisci/travisci.go index 07d607c4a0a8..2149a7092fbd 100644 --- a/pkg/detectors/travisci/travisci.go +++ b/pkg/detectors/travisci/travisci.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify TravisCI secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/travisci/travisci_test.go b/pkg/detectors/travisci/travisci_test.go index 77e9fc0bd320..f08d23408ce2 100644 --- a/pkg/detectors/travisci/travisci_test.go +++ b/pkg/detectors/travisci/travisci_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/trelloapikey/trelloapikey.go b/pkg/detectors/trelloapikey/trelloapikey.go index be78c210c354..a1ffa9ec3caa 100644 --- a/pkg/detectors/trelloapikey/trelloapikey.go +++ b/pkg/detectors/trelloapikey/trelloapikey.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify TrelloApiKey secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) tokenMatches := tokenPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/trelloapikey/trelloapikey_test.go b/pkg/detectors/trelloapikey/trelloapikey_test.go index b2aff40aafd0..65553a3a3ee0 100644 --- a/pkg/detectors/trelloapikey/trelloapikey_test.go +++ b/pkg/detectors/trelloapikey/trelloapikey_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/tru/tru.go b/pkg/detectors/tru/tru.go index 2a40812f99dd..2f0852743827 100644 --- a/pkg/detectors/tru/tru.go +++ b/pkg/detectors/tru/tru.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Tru secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) secretMatches := secrePat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/tru/tru_test.go b/pkg/detectors/tru/tru_test.go index 17d56acf6bee..d0ce32b49a9c 100644 --- a/pkg/detectors/tru/tru_test.go +++ b/pkg/detectors/tru/tru_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/trufflehogenterprise/trufflehogenterprise.go b/pkg/detectors/trufflehogenterprise/trufflehogenterprise.go index d9880bde1cb3..d90ae87a05a8 100644 --- a/pkg/detectors/trufflehogenterprise/trufflehogenterprise.go +++ b/pkg/detectors/trufflehogenterprise/trufflehogenterprise.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Trufflehog Enterprise secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) keyMatches := keyPat.FindAllStringSubmatch(dataStr, -1) secretMatches := secretPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/trufflehogenterprise/trufflehogenterprise_test.go b/pkg/detectors/trufflehogenterprise/trufflehogenterprise_test.go index 56e10f2b9416..1e39d2d99853 100644 --- a/pkg/detectors/trufflehogenterprise/trufflehogenterprise_test.go +++ b/pkg/detectors/trufflehogenterprise/trufflehogenterprise_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/twelvedata/twelvedata.go b/pkg/detectors/twelvedata/twelvedata.go index 8cb6f1092028..639520231a6f 100644 --- a/pkg/detectors/twelvedata/twelvedata.go +++ b/pkg/detectors/twelvedata/twelvedata.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify TwelveData secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/twelvedata/twelvedata_test.go b/pkg/detectors/twelvedata/twelvedata_test.go index f46b777a429d..c7a08e6ca235 100644 --- a/pkg/detectors/twelvedata/twelvedata_test.go +++ b/pkg/detectors/twelvedata/twelvedata_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/twilio/twilio.go b/pkg/detectors/twilio/twilio.go index 9588e858ef1c..a4379be9e510 100644 --- a/pkg/detectors/twilio/twilio.go +++ b/pkg/detectors/twilio/twilio.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Twilio secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) identifierMatches := identifierPat.FindAllString(dataStr, -1) diff --git a/pkg/detectors/twilio/twilio_test.go b/pkg/detectors/twilio/twilio_test.go index a6f53eab4e60..3d6748df82a1 100644 --- a/pkg/detectors/twilio/twilio_test.go +++ b/pkg/detectors/twilio/twilio_test.go @@ -6,11 +6,12 @@ package twilio import ( "context" "fmt" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "testing" "time" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" diff --git a/pkg/detectors/twist/twist.go b/pkg/detectors/twist/twist.go index 0b59b6c4b1da..ed439c67d8b5 100644 --- a/pkg/detectors/twist/twist.go +++ b/pkg/detectors/twist/twist.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Twist secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := accessToken.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/twist/twist_test.go b/pkg/detectors/twist/twist_test.go index 88027608c823..9048e1318e29 100644 --- a/pkg/detectors/twist/twist_test.go +++ b/pkg/detectors/twist/twist_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/twitch/twitch.go b/pkg/detectors/twitch/twitch.go index 99d3a1b579c9..173eeb586a9e 100644 --- a/pkg/detectors/twitch/twitch.go +++ b/pkg/detectors/twitch/twitch.go @@ -39,7 +39,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Twitch secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/twitch/twitch_test.go b/pkg/detectors/twitch/twitch_test.go index f0d5039d4d92..b4ba7bc88b8f 100644 --- a/pkg/detectors/twitch/twitch_test.go +++ b/pkg/detectors/twitch/twitch_test.go @@ -11,6 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" diff --git a/pkg/detectors/twitter/twitter.go b/pkg/detectors/twitter/twitter.go index 9d4d9c121dd9..9b3070f5a094 100644 --- a/pkg/detectors/twitter/twitter.go +++ b/pkg/detectors/twitter/twitter.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Twitter secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/twitter/twitter_test.go b/pkg/detectors/twitter/twitter_test.go index 0b072140326d..14d873447030 100644 --- a/pkg/detectors/twitter/twitter_test.go +++ b/pkg/detectors/twitter/twitter_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/tyntec/tyntec.go b/pkg/detectors/tyntec/tyntec.go index 7fde801e666a..60ace2376ad9 100644 --- a/pkg/detectors/tyntec/tyntec.go +++ b/pkg/detectors/tyntec/tyntec.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Tyntec secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/tyntec/tyntec_test.go b/pkg/detectors/tyntec/tyntec_test.go index ddb10f9f8cc1..c8f984d575be 100644 --- a/pkg/detectors/tyntec/tyntec_test.go +++ b/pkg/detectors/tyntec/tyntec_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/typeform/typeform.go b/pkg/detectors/typeform/typeform.go index 41767e3454a9..087c62519684 100644 --- a/pkg/detectors/typeform/typeform.go +++ b/pkg/detectors/typeform/typeform.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Typeform secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/typeform/typeform_test.go b/pkg/detectors/typeform/typeform_test.go index ac5971a37458..34b00fb5a6bc 100644 --- a/pkg/detectors/typeform/typeform_test.go +++ b/pkg/detectors/typeform/typeform_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/typetalk/typetalk.go b/pkg/detectors/typetalk/typetalk.go index 493cc3fc65b5..02c799e312bd 100644 --- a/pkg/detectors/typetalk/typetalk.go +++ b/pkg/detectors/typetalk/typetalk.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Typetalk secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/typetalk/typetalk_test.go b/pkg/detectors/typetalk/typetalk_test.go index f99d6484c56f..6f150ba851a1 100644 --- a/pkg/detectors/typetalk/typetalk_test.go +++ b/pkg/detectors/typetalk/typetalk_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/ubidots/ubidots.go b/pkg/detectors/ubidots/ubidots.go index bbc0e2bee016..e22d590ba061 100644 --- a/pkg/detectors/ubidots/ubidots.go +++ b/pkg/detectors/ubidots/ubidots.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Ubidots secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/ubidots/ubidots_test.go b/pkg/detectors/ubidots/ubidots_test.go index 4dd26f2fc9d2..bc2cf29827df 100644 --- a/pkg/detectors/ubidots/ubidots_test.go +++ b/pkg/detectors/ubidots/ubidots_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/uclassify/uclassify.go b/pkg/detectors/uclassify/uclassify.go index 757fa2a02789..9d87b3dec23a 100644 --- a/pkg/detectors/uclassify/uclassify.go +++ b/pkg/detectors/uclassify/uclassify.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Uclassify secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/uclassify/uclassify_test.go b/pkg/detectors/uclassify/uclassify_test.go index f3b4e2a4041d..5488dcc95b76 100644 --- a/pkg/detectors/uclassify/uclassify_test.go +++ b/pkg/detectors/uclassify/uclassify_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/unifyid/unifyid.go b/pkg/detectors/unifyid/unifyid.go index 8b83a78342d0..f1fcc986eb97 100644 --- a/pkg/detectors/unifyid/unifyid.go +++ b/pkg/detectors/unifyid/unifyid.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Unifyid secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/unifyid/unifyid_test.go b/pkg/detectors/unifyid/unifyid_test.go index 4e59fce1e1b8..7845f34ca211 100644 --- a/pkg/detectors/unifyid/unifyid_test.go +++ b/pkg/detectors/unifyid/unifyid_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/unplugg/unplugg.go b/pkg/detectors/unplugg/unplugg.go index a7081bd46e23..9f8ab02951bf 100644 --- a/pkg/detectors/unplugg/unplugg.go +++ b/pkg/detectors/unplugg/unplugg.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Unplugg secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/unplugg/unplugg_test.go b/pkg/detectors/unplugg/unplugg_test.go index f021bfa7c9de..ef129e2abbd6 100644 --- a/pkg/detectors/unplugg/unplugg_test.go +++ b/pkg/detectors/unplugg/unplugg_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/unsplash/unsplash.go b/pkg/detectors/unsplash/unsplash.go index b8856c96ac74..99b87dde1e62 100644 --- a/pkg/detectors/unsplash/unsplash.go +++ b/pkg/detectors/unsplash/unsplash.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Unsplash secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/unsplash/unsplash_test.go b/pkg/detectors/unsplash/unsplash_test.go index 20941b87e0a0..cbd202d81c04 100644 --- a/pkg/detectors/unsplash/unsplash_test.go +++ b/pkg/detectors/unsplash/unsplash_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/upcdatabase/upcdatabase.go b/pkg/detectors/upcdatabase/upcdatabase.go index 015d4b54703a..601c2d68876c 100644 --- a/pkg/detectors/upcdatabase/upcdatabase.go +++ b/pkg/detectors/upcdatabase/upcdatabase.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify UPCDatabase secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/upcdatabase/upcdatabase_test.go b/pkg/detectors/upcdatabase/upcdatabase_test.go index 1bf3e3a28f16..99b118141c3a 100644 --- a/pkg/detectors/upcdatabase/upcdatabase_test.go +++ b/pkg/detectors/upcdatabase/upcdatabase_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/uplead/uplead.go b/pkg/detectors/uplead/uplead.go index c2b882438fdd..364751253d6d 100644 --- a/pkg/detectors/uplead/uplead.go +++ b/pkg/detectors/uplead/uplead.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Uplead secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/uplead/uplead_test.go b/pkg/detectors/uplead/uplead_test.go index 6268796550b7..270c3007a8fa 100644 --- a/pkg/detectors/uplead/uplead_test.go +++ b/pkg/detectors/uplead/uplead_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/uploadcare/uploadcare.go b/pkg/detectors/uploadcare/uploadcare.go index 825f6164bea6..7ed8cd45fe3e 100644 --- a/pkg/detectors/uploadcare/uploadcare.go +++ b/pkg/detectors/uploadcare/uploadcare.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify UploadCare secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) publicMatches := publicKeyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/uptimerobot/uptimerobot.go b/pkg/detectors/uptimerobot/uptimerobot.go index cc6e6c2427f0..7475301f732f 100644 --- a/pkg/detectors/uptimerobot/uptimerobot.go +++ b/pkg/detectors/uptimerobot/uptimerobot.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify UptimeRobot secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/uptimerobot/uptimerobot_test.go b/pkg/detectors/uptimerobot/uptimerobot_test.go index 7e6637138151..92dc978df59a 100644 --- a/pkg/detectors/uptimerobot/uptimerobot_test.go +++ b/pkg/detectors/uptimerobot/uptimerobot_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/upwave/upwave.go b/pkg/detectors/upwave/upwave.go index fbb5498f1249..84fa9e71a60e 100644 --- a/pkg/detectors/upwave/upwave.go +++ b/pkg/detectors/upwave/upwave.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Upwave secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/upwave/upwave_test.go b/pkg/detectors/upwave/upwave_test.go index 15371ebe1789..148830cb3885 100644 --- a/pkg/detectors/upwave/upwave_test.go +++ b/pkg/detectors/upwave/upwave_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/uri/uri.go b/pkg/detectors/uri/uri.go index 8667ee617a81..1d813e39b580 100644 --- a/pkg/detectors/uri/uri.go +++ b/pkg/detectors/uri/uri.go @@ -35,7 +35,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify URI secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/uri/uri_test.go b/pkg/detectors/uri/uri_test.go index c1c1f840e0dc..964630f038ef 100644 --- a/pkg/detectors/uri/uri_test.go +++ b/pkg/detectors/uri/uri_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" diff --git a/pkg/detectors/urlscan/urlscan.go b/pkg/detectors/urlscan/urlscan.go index 0dc90d0e0658..bab9ca2836a6 100644 --- a/pkg/detectors/urlscan/urlscan.go +++ b/pkg/detectors/urlscan/urlscan.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Urlscan secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/urlscan/urlscan_test.go b/pkg/detectors/urlscan/urlscan_test.go index 7008388c7fd1..23c0e4b64ce0 100644 --- a/pkg/detectors/urlscan/urlscan_test.go +++ b/pkg/detectors/urlscan/urlscan_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/user/user.go b/pkg/detectors/user/user.go index 2cbfe116bb66..76aa31224ab8 100644 --- a/pkg/detectors/user/user.go +++ b/pkg/detectors/user/user.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify User secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/user/user_test.go b/pkg/detectors/user/user_test.go index 970e0877e235..09e099adcacf 100644 --- a/pkg/detectors/user/user_test.go +++ b/pkg/detectors/user/user_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/userflow/userflow.go b/pkg/detectors/userflow/userflow.go index b0ba91114301..0cdb12b1981f 100644 --- a/pkg/detectors/userflow/userflow.go +++ b/pkg/detectors/userflow/userflow.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Userflow secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/userflow/userflow_test.go b/pkg/detectors/userflow/userflow_test.go index 6321e454bf58..01b18c76ba3f 100644 --- a/pkg/detectors/userflow/userflow_test.go +++ b/pkg/detectors/userflow/userflow_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/userstack/userstack.go b/pkg/detectors/userstack/userstack.go index d8662ee3e0f0..2f3f310968f1 100644 --- a/pkg/detectors/userstack/userstack.go +++ b/pkg/detectors/userstack/userstack.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify UserStack secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/userstack/userstack_test.go b/pkg/detectors/userstack/userstack_test.go index d436c0ddf949..392dfe96ff60 100644 --- a/pkg/detectors/userstack/userstack_test.go +++ b/pkg/detectors/userstack/userstack_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/vagrantcloudpersonaltoken/vagrantcloudpersonaltoken.go b/pkg/detectors/vagrantcloudpersonaltoken/vagrantcloudpersonaltoken.go index c78dbde27f61..990ccc67fb1b 100644 --- a/pkg/detectors/vagrantcloudpersonaltoken/vagrantcloudpersonaltoken.go +++ b/pkg/detectors/vagrantcloudpersonaltoken/vagrantcloudpersonaltoken.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Vagrantcloudpersonaltoken secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) @@ -44,7 +44,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result resMatch := strings.TrimSpace(match[1]) s1 := detectors.Result{ - DetectorType: detectorspb.DetectorType_VagrantCloudPersonalToken, + DetectorType: detectorspb.DetectorType_VagrantCloudPersonalToken, Raw: []byte(resMatch), } @@ -53,7 +53,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result if client == nil { client = defaultClient } - + req, err := http.NewRequestWithContext(ctx, "GET", "https://app.vagrantup.com/api/v2/authenticate", nil) if err != nil { continue diff --git a/pkg/detectors/vatlayer/vatlayer.go b/pkg/detectors/vatlayer/vatlayer.go index bd0155c5ae1f..0e0986cacec8 100644 --- a/pkg/detectors/vatlayer/vatlayer.go +++ b/pkg/detectors/vatlayer/vatlayer.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify VatLayer secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/vatlayer/vatlayer_test.go b/pkg/detectors/vatlayer/vatlayer_test.go index 57ac61124fe3..43078b9252e3 100644 --- a/pkg/detectors/vatlayer/vatlayer_test.go +++ b/pkg/detectors/vatlayer/vatlayer_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/vbout/vbout.go b/pkg/detectors/vbout/vbout.go index 04df4949971b..89ad800f83c0 100644 --- a/pkg/detectors/vbout/vbout.go +++ b/pkg/detectors/vbout/vbout.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Vbout secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/vbout/vbout_test.go b/pkg/detectors/vbout/vbout_test.go index c8eaa6575b46..4e8fcbb6784c 100644 --- a/pkg/detectors/vbout/vbout_test.go +++ b/pkg/detectors/vbout/vbout_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/vercel/vercel.go b/pkg/detectors/vercel/vercel.go index 55d6f23e4fe1..0f80fd30032b 100644 --- a/pkg/detectors/vercel/vercel.go +++ b/pkg/detectors/vercel/vercel.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Vercel secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/vercel/vercel_test.go b/pkg/detectors/vercel/vercel_test.go index d9726d83fecf..21347ef59cb9 100644 --- a/pkg/detectors/vercel/vercel_test.go +++ b/pkg/detectors/vercel/vercel_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/verifier/verifier.go b/pkg/detectors/verifier/verifier.go index 324f76a1dc3e..640194adaff1 100644 --- a/pkg/detectors/verifier/verifier.go +++ b/pkg/detectors/verifier/verifier.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Verifier secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := emailPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/verifier/verifier_test.go b/pkg/detectors/verifier/verifier_test.go index d6e55a1861e3..dd7cd602efed 100644 --- a/pkg/detectors/verifier/verifier_test.go +++ b/pkg/detectors/verifier/verifier_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/verimail/verimail.go b/pkg/detectors/verimail/verimail.go index 19345aedf190..803f9e3b2098 100644 --- a/pkg/detectors/verimail/verimail.go +++ b/pkg/detectors/verimail/verimail.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Verimail secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/verimail/verimail_test.go b/pkg/detectors/verimail/verimail_test.go index 87165a4c00f4..75612145da2b 100644 --- a/pkg/detectors/verimail/verimail_test.go +++ b/pkg/detectors/verimail/verimail_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/veriphone/veriphone.go b/pkg/detectors/veriphone/veriphone.go index 6b4f43006aff..934c5f867487 100644 --- a/pkg/detectors/veriphone/veriphone.go +++ b/pkg/detectors/veriphone/veriphone.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Veriphone secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/veriphone/veriphone_test.go b/pkg/detectors/veriphone/veriphone_test.go index af712d5db67d..bdac1a7500fb 100644 --- a/pkg/detectors/veriphone/veriphone_test.go +++ b/pkg/detectors/veriphone/veriphone_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/versioneye/versioneye.go b/pkg/detectors/versioneye/versioneye.go index 5148a99d412e..f55849e634d6 100644 --- a/pkg/detectors/versioneye/versioneye.go +++ b/pkg/detectors/versioneye/versioneye.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify VersionEye secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/versioneye/versioneye_test.go b/pkg/detectors/versioneye/versioneye_test.go index 336405d4206e..7993f4751d91 100644 --- a/pkg/detectors/versioneye/versioneye_test.go +++ b/pkg/detectors/versioneye/versioneye_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/viewneo/viewneo.go b/pkg/detectors/viewneo/viewneo.go index fa35a06317a6..1218ad3ca6be 100644 --- a/pkg/detectors/viewneo/viewneo.go +++ b/pkg/detectors/viewneo/viewneo.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Viewneo secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) for _, match := range matches { diff --git a/pkg/detectors/viewneo/viewneo_test.go b/pkg/detectors/viewneo/viewneo_test.go index ff6c82645570..d31c108e34bd 100644 --- a/pkg/detectors/viewneo/viewneo_test.go +++ b/pkg/detectors/viewneo/viewneo_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/virustotal/virustotal.go b/pkg/detectors/virustotal/virustotal.go index 465b1c060d59..2e2e795c234c 100644 --- a/pkg/detectors/virustotal/virustotal.go +++ b/pkg/detectors/virustotal/virustotal.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify VirusTotal secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/visualcrossing/visualcrossing.go b/pkg/detectors/visualcrossing/visualcrossing.go index ea9dd2491ddd..69fb5756b683 100644 --- a/pkg/detectors/visualcrossing/visualcrossing.go +++ b/pkg/detectors/visualcrossing/visualcrossing.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Visualcrossing secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/voiceflow/voiceflow.go b/pkg/detectors/voiceflow/voiceflow.go index 0795abdf497d..02df584355d0 100644 --- a/pkg/detectors/voiceflow/voiceflow.go +++ b/pkg/detectors/voiceflow/voiceflow.go @@ -25,7 +25,7 @@ var ( defaultClient = common.SaneHttpClient() // Reference: https://developer.voiceflow.com/reference/project#dialog-manager-api-keys // - //TODO: This includes Workspace and Legacy Workspace API keys; I haven't validated whether these actually work. + // TODO: This includes Workspace and Legacy Workspace API keys; I haven't validated whether these actually work. // https://github.com/voiceflow/general-runtime/blob/master/tests/runtime/lib/DataAPI/utils.unit.ts keyPat = regexp.MustCompile(`\b(VF\.(?:(?:DM|WS)\.)?[a-fA-F0-9]{24}\.[a-zA-Z0-9]{16})\b`) ) @@ -38,7 +38,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Voiceflow secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) for _, match := range matches { diff --git a/pkg/detectors/voiceflow/voiceflow_test.go b/pkg/detectors/voiceflow/voiceflow_test.go index 87cb56cc9d44..eca90d717f64 100644 --- a/pkg/detectors/voiceflow/voiceflow_test.go +++ b/pkg/detectors/voiceflow/voiceflow_test.go @@ -6,11 +6,12 @@ package voiceflow import ( "context" "fmt" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "testing" "time" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/voicegain/voicegain.go b/pkg/detectors/voicegain/voicegain.go index 67741e25b73d..c566b3f23a4f 100644 --- a/pkg/detectors/voicegain/voicegain.go +++ b/pkg/detectors/voicegain/voicegain.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Voicegain secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/voicegain/voicegain_test.go b/pkg/detectors/voicegain/voicegain_test.go index 4a3ce826faa5..3fac76c07870 100644 --- a/pkg/detectors/voicegain/voicegain_test.go +++ b/pkg/detectors/voicegain/voicegain_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/voodoosms/voodoosms.go b/pkg/detectors/voodoosms/voodoosms.go index c382d0933bef..71aea4733148 100644 --- a/pkg/detectors/voodoosms/voodoosms.go +++ b/pkg/detectors/voodoosms/voodoosms.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify VoodooSMS secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/voodoosms/voodoosms_test.go b/pkg/detectors/voodoosms/voodoosms_test.go index 3728dde96026..ea7a92f31a7b 100644 --- a/pkg/detectors/voodoosms/voodoosms_test.go +++ b/pkg/detectors/voodoosms/voodoosms_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/vouchery/vouchery.go b/pkg/detectors/vouchery/vouchery.go index ec917e564c51..62f7dcc2b225 100644 --- a/pkg/detectors/vouchery/vouchery.go +++ b/pkg/detectors/vouchery/vouchery.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Vouchery secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) subMatches := subPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/vouchery/vouchery_test.go b/pkg/detectors/vouchery/vouchery_test.go index bf0f879703dd..6e654af17316 100644 --- a/pkg/detectors/vouchery/vouchery_test.go +++ b/pkg/detectors/vouchery/vouchery_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/vpnapi/vpnapi.go b/pkg/detectors/vpnapi/vpnapi.go index 5593e0d4eaf3..70d104223139 100644 --- a/pkg/detectors/vpnapi/vpnapi.go +++ b/pkg/detectors/vpnapi/vpnapi.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Vpnapi secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/vpnapi/vpnapi_test.go b/pkg/detectors/vpnapi/vpnapi_test.go index 34583d05b839..9fafb0b0d373 100644 --- a/pkg/detectors/vpnapi/vpnapi_test.go +++ b/pkg/detectors/vpnapi/vpnapi_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/vultrapikey/vultrapikey.go b/pkg/detectors/vultrapikey/vultrapikey.go index 536a27c924ed..31dffd891e65 100644 --- a/pkg/detectors/vultrapikey/vultrapikey.go +++ b/pkg/detectors/vultrapikey/vultrapikey.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify VultrApiKey secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/vultrapikey/vultrapikey_test.go b/pkg/detectors/vultrapikey/vultrapikey_test.go index 575713d4f005..2b68f4c365f3 100644 --- a/pkg/detectors/vultrapikey/vultrapikey_test.go +++ b/pkg/detectors/vultrapikey/vultrapikey_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/vyte/vyte.go b/pkg/detectors/vyte/vyte.go index 0671be79f451..dde4d1214236 100644 --- a/pkg/detectors/vyte/vyte.go +++ b/pkg/detectors/vyte/vyte.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Vyte secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/vyte/vyte_test.go b/pkg/detectors/vyte/vyte_test.go index 7cce3162fdca..7a6c4cd63f47 100644 --- a/pkg/detectors/vyte/vyte_test.go +++ b/pkg/detectors/vyte/vyte_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/walkscore/walkscore.go b/pkg/detectors/walkscore/walkscore.go index 4400afaa4e90..c7b3569ae983 100644 --- a/pkg/detectors/walkscore/walkscore.go +++ b/pkg/detectors/walkscore/walkscore.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Walkscore secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/walkscore/walkscore_test.go b/pkg/detectors/walkscore/walkscore_test.go index 51da77862870..c98e13e87a91 100644 --- a/pkg/detectors/walkscore/walkscore_test.go +++ b/pkg/detectors/walkscore/walkscore_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/weatherbit/weatherbit.go b/pkg/detectors/weatherbit/weatherbit.go index 04a8ebad7679..3dd669763e97 100644 --- a/pkg/detectors/weatherbit/weatherbit.go +++ b/pkg/detectors/weatherbit/weatherbit.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Weatherbit secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/weatherbit/weatherbit_test.go b/pkg/detectors/weatherbit/weatherbit_test.go index 09cbc57e89e8..fbae2f82775d 100644 --- a/pkg/detectors/weatherbit/weatherbit_test.go +++ b/pkg/detectors/weatherbit/weatherbit_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/weatherstack/weatherstack.go b/pkg/detectors/weatherstack/weatherstack.go index d5255a209aa6..7752ca70dfb2 100644 --- a/pkg/detectors/weatherstack/weatherstack.go +++ b/pkg/detectors/weatherstack/weatherstack.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Weatherstack secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/weatherstack/weatherstack_test.go b/pkg/detectors/weatherstack/weatherstack_test.go index 6ce95f28c6bd..6e9daa147ee0 100644 --- a/pkg/detectors/weatherstack/weatherstack_test.go +++ b/pkg/detectors/weatherstack/weatherstack_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/web3storage/web3storage.go b/pkg/detectors/web3storage/web3storage.go index 359362e93f66..4bb64b6fa0c4 100644 --- a/pkg/detectors/web3storage/web3storage.go +++ b/pkg/detectors/web3storage/web3storage.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Web3storage secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/web3storage/web3storage_test.go b/pkg/detectors/web3storage/web3storage_test.go index 53d0f43fefe5..f79d5b3320f9 100644 --- a/pkg/detectors/web3storage/web3storage_test.go +++ b/pkg/detectors/web3storage/web3storage_test.go @@ -6,11 +6,12 @@ package web3storage import ( "context" "fmt" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "testing" "time" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/webex/webex.go b/pkg/detectors/webex/webex.go index 38c732ca1133..179ac93bc0c7 100644 --- a/pkg/detectors/webex/webex.go +++ b/pkg/detectors/webex/webex.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Webex secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/webex/webex_test.go b/pkg/detectors/webex/webex_test.go index 42aee0ff8d2f..bca033ca4aba 100644 --- a/pkg/detectors/webex/webex_test.go +++ b/pkg/detectors/webex/webex_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/webflow/webflow.go b/pkg/detectors/webflow/webflow.go index 25ab7c84bdd7..fcf84248a06d 100644 --- a/pkg/detectors/webflow/webflow.go +++ b/pkg/detectors/webflow/webflow.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Webflow secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/webscraper/webscraper.go b/pkg/detectors/webscraper/webscraper.go index 9b374f6dfd62..84f26a375e1c 100644 --- a/pkg/detectors/webscraper/webscraper.go +++ b/pkg/detectors/webscraper/webscraper.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify WebScraper secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/webscraper/webscraper_test.go b/pkg/detectors/webscraper/webscraper_test.go index 539cb40e5c9f..60ad84dc41e1 100644 --- a/pkg/detectors/webscraper/webscraper_test.go +++ b/pkg/detectors/webscraper/webscraper_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/webscraping/webscraping.go b/pkg/detectors/webscraping/webscraping.go index 5d5118ab7bc5..40256ee387dc 100644 --- a/pkg/detectors/webscraping/webscraping.go +++ b/pkg/detectors/webscraping/webscraping.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Webscraping secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/webscraping/webscraping_test.go b/pkg/detectors/webscraping/webscraping_test.go index ab0399c6467c..dc420a59e2ea 100644 --- a/pkg/detectors/webscraping/webscraping_test.go +++ b/pkg/detectors/webscraping/webscraping_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/websitepulse/websitepulse.go b/pkg/detectors/websitepulse/websitepulse.go index e8eef8764512..19ede57bc8f4 100644 --- a/pkg/detectors/websitepulse/websitepulse.go +++ b/pkg/detectors/websitepulse/websitepulse.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Websitepulse secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idmatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/websitepulse/websitepulse_test.go b/pkg/detectors/websitepulse/websitepulse_test.go index 24e85fc1201a..d0a22240fd39 100644 --- a/pkg/detectors/websitepulse/websitepulse_test.go +++ b/pkg/detectors/websitepulse/websitepulse_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/wepay/wepay.go b/pkg/detectors/wepay/wepay.go index 856e94d48920..3126729c736b 100644 --- a/pkg/detectors/wepay/wepay.go +++ b/pkg/detectors/wepay/wepay.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify WePay secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) appIDmatches := appIDPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/wepay/wepay_test.go b/pkg/detectors/wepay/wepay_test.go index dc42b6f8f3e9..b79c48a32ad5 100644 --- a/pkg/detectors/wepay/wepay_test.go +++ b/pkg/detectors/wepay/wepay_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/whoxy/whoxy.go b/pkg/detectors/whoxy/whoxy.go index 90478b875da0..afd21be19b40 100644 --- a/pkg/detectors/whoxy/whoxy.go +++ b/pkg/detectors/whoxy/whoxy.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Whoxy secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/whoxy/whoxy_test.go b/pkg/detectors/whoxy/whoxy_test.go index 503f037a2f20..9b3c0ac1534b 100644 --- a/pkg/detectors/whoxy/whoxy_test.go +++ b/pkg/detectors/whoxy/whoxy_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/wistia/wistia.go b/pkg/detectors/wistia/wistia.go index 5a611ae5b16d..3c449be526a1 100644 --- a/pkg/detectors/wistia/wistia.go +++ b/pkg/detectors/wistia/wistia.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Wistia secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/wistia/wistia_test.go b/pkg/detectors/wistia/wistia_test.go index 9bfb0ee85ee9..0527fb9b0c83 100644 --- a/pkg/detectors/wistia/wistia_test.go +++ b/pkg/detectors/wistia/wistia_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/wit/wit.go b/pkg/detectors/wit/wit.go index 239250b21b3c..c523084df512 100644 --- a/pkg/detectors/wit/wit.go +++ b/pkg/detectors/wit/wit.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Wit secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/wit/wit_test.go b/pkg/detectors/wit/wit_test.go index d774a6537ac4..33cb445815bd 100644 --- a/pkg/detectors/wit/wit_test.go +++ b/pkg/detectors/wit/wit_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/worksnaps/worksnaps.go b/pkg/detectors/worksnaps/worksnaps.go index e2e8b8e3036e..4ba2876ae26c 100644 --- a/pkg/detectors/worksnaps/worksnaps.go +++ b/pkg/detectors/worksnaps/worksnaps.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Worksnaps secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/worksnaps/worksnaps_test.go b/pkg/detectors/worksnaps/worksnaps_test.go index 03d4172ef182..0522431649d9 100644 --- a/pkg/detectors/worksnaps/worksnaps_test.go +++ b/pkg/detectors/worksnaps/worksnaps_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/workstack/workstack.go b/pkg/detectors/workstack/workstack.go index 5cc825923a2d..1766bf403551 100644 --- a/pkg/detectors/workstack/workstack.go +++ b/pkg/detectors/workstack/workstack.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Workstack secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/workstack/workstack_test.go b/pkg/detectors/workstack/workstack_test.go index 4ae883faf57a..c1f43a6e2489 100644 --- a/pkg/detectors/workstack/workstack_test.go +++ b/pkg/detectors/workstack/workstack_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/worldcoinindex/worldcoinindex.go b/pkg/detectors/worldcoinindex/worldcoinindex.go index 76cac67f4bc6..babb7c5c6f47 100644 --- a/pkg/detectors/worldcoinindex/worldcoinindex.go +++ b/pkg/detectors/worldcoinindex/worldcoinindex.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify WorldCoinIndex secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/worldcoinindex/worldcoinindex_test.go b/pkg/detectors/worldcoinindex/worldcoinindex_test.go index c64433f5e513..d5150cfb1eaa 100644 --- a/pkg/detectors/worldcoinindex/worldcoinindex_test.go +++ b/pkg/detectors/worldcoinindex/worldcoinindex_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/worldweather/worldweather.go b/pkg/detectors/worldweather/worldweather.go index f6d74b752043..145923a97978 100644 --- a/pkg/detectors/worldweather/worldweather.go +++ b/pkg/detectors/worldweather/worldweather.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Worldweather secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/worldweather/worldweather_test.go b/pkg/detectors/worldweather/worldweather_test.go index 9bcdb3907d7a..24db81de4862 100644 --- a/pkg/detectors/worldweather/worldweather_test.go +++ b/pkg/detectors/worldweather/worldweather_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/wrike/wrike.go b/pkg/detectors/wrike/wrike.go index 1587641677d5..b454e453f1a9 100644 --- a/pkg/detectors/wrike/wrike.go +++ b/pkg/detectors/wrike/wrike.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Wrike secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/wrike/wrike_test.go b/pkg/detectors/wrike/wrike_test.go index 6bfffcc9e8ef..abe610814863 100644 --- a/pkg/detectors/wrike/wrike_test.go +++ b/pkg/detectors/wrike/wrike_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/yandex/yandex.go b/pkg/detectors/yandex/yandex.go index 142e2ce7c1ed..cb8a40d819a8 100644 --- a/pkg/detectors/yandex/yandex.go +++ b/pkg/detectors/yandex/yandex.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Yandex secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/yandex/yandex_test.go b/pkg/detectors/yandex/yandex_test.go index 8e20383628f1..3ac45c45cc3e 100644 --- a/pkg/detectors/yandex/yandex_test.go +++ b/pkg/detectors/yandex/yandex_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/yelp/yelp.go b/pkg/detectors/yelp/yelp.go index 5278b6d3e164..bf49287fb0ad 100644 --- a/pkg/detectors/yelp/yelp.go +++ b/pkg/detectors/yelp/yelp.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Yelp secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/yelp/yelp_test.go b/pkg/detectors/yelp/yelp_test.go index 91c16f19bfde..9dad1b8292f6 100644 --- a/pkg/detectors/yelp/yelp_test.go +++ b/pkg/detectors/yelp/yelp_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/youneedabudget/youneedabudget.go b/pkg/detectors/youneedabudget/youneedabudget.go index a95e1003f02c..73efb00b550b 100644 --- a/pkg/detectors/youneedabudget/youneedabudget.go +++ b/pkg/detectors/youneedabudget/youneedabudget.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify YouNeedABudget secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/youneedabudget/youneedabudget_test.go b/pkg/detectors/youneedabudget/youneedabudget_test.go index 3c852108e8ba..43d22321e3c6 100644 --- a/pkg/detectors/youneedabudget/youneedabudget_test.go +++ b/pkg/detectors/youneedabudget/youneedabudget_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/yousign/yousign.go b/pkg/detectors/yousign/yousign.go index 36cfe6e9f278..94d5a1fd98d7 100644 --- a/pkg/detectors/yousign/yousign.go +++ b/pkg/detectors/yousign/yousign.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Yousign secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/yousign/yousign_test.go b/pkg/detectors/yousign/yousign_test.go index acecdef047e5..0c11cf01ded1 100644 --- a/pkg/detectors/yousign/yousign_test.go +++ b/pkg/detectors/yousign/yousign_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/youtubeapikey/youtubeapikey.go b/pkg/detectors/youtubeapikey/youtubeapikey.go index c4d98ef1ba16..17d82f7c83ae 100644 --- a/pkg/detectors/youtubeapikey/youtubeapikey.go +++ b/pkg/detectors/youtubeapikey/youtubeapikey.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify YoutubeApiKey secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idmatches := idPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/youtubeapikey/youtubeapikey_test.go b/pkg/detectors/youtubeapikey/youtubeapikey_test.go index ed24f95be51c..4ac9275609e8 100644 --- a/pkg/detectors/youtubeapikey/youtubeapikey_test.go +++ b/pkg/detectors/youtubeapikey/youtubeapikey_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/zapierwebhook/zapierwebhook.go b/pkg/detectors/zapierwebhook/zapierwebhook.go index 620c027f8851..9b7bf91c6836 100644 --- a/pkg/detectors/zapierwebhook/zapierwebhook.go +++ b/pkg/detectors/zapierwebhook/zapierwebhook.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ZapierWebhook secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/zapierwebhook/zapierwebhook_test.go b/pkg/detectors/zapierwebhook/zapierwebhook_test.go index 77512d872417..e4153e195afc 100644 --- a/pkg/detectors/zapierwebhook/zapierwebhook_test.go +++ b/pkg/detectors/zapierwebhook/zapierwebhook_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/zendeskapi/zendeskapi.go b/pkg/detectors/zendeskapi/zendeskapi.go index 9438ea38d242..550cc629c523 100644 --- a/pkg/detectors/zendeskapi/zendeskapi.go +++ b/pkg/detectors/zendeskapi/zendeskapi.go @@ -34,7 +34,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ZendeskApi secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) tokens := token.FindAllStringSubmatch(dataStr, -1) domains := domain.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/zendeskapi/zendeskapi_test.go b/pkg/detectors/zendeskapi/zendeskapi_test.go index 3311161e1150..b43bc3391b48 100644 --- a/pkg/detectors/zendeskapi/zendeskapi_test.go +++ b/pkg/detectors/zendeskapi/zendeskapi_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/zenkitapi/zenkitapi.go b/pkg/detectors/zenkitapi/zenkitapi.go index 17bb385abf0d..511b509e0931 100644 --- a/pkg/detectors/zenkitapi/zenkitapi.go +++ b/pkg/detectors/zenkitapi/zenkitapi.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ZenkitAPI secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/zenrows/zenrows.go b/pkg/detectors/zenrows/zenrows.go index 561919b4508c..df89611b3f50 100644 --- a/pkg/detectors/zenrows/zenrows.go +++ b/pkg/detectors/zenrows/zenrows.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ZenRows secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/zenrows/zenrows_test.go b/pkg/detectors/zenrows/zenrows_test.go index ffe91c405ed6..6f810a8205c5 100644 --- a/pkg/detectors/zenrows/zenrows_test.go +++ b/pkg/detectors/zenrows/zenrows_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/zenscrape/zenscrape.go b/pkg/detectors/zenscrape/zenscrape.go index 1ec246c1fddc..8f392d92477d 100644 --- a/pkg/detectors/zenscrape/zenscrape.go +++ b/pkg/detectors/zenscrape/zenscrape.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Zenscrape secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/zenscrape/zenscrape_test.go b/pkg/detectors/zenscrape/zenscrape_test.go index 332e7bae8e53..12d8de29660d 100644 --- a/pkg/detectors/zenscrape/zenscrape_test.go +++ b/pkg/detectors/zenscrape/zenscrape_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/zenserp/zenserp.go b/pkg/detectors/zenserp/zenserp.go index 5ae78e9458b1..62cddae03122 100644 --- a/pkg/detectors/zenserp/zenserp.go +++ b/pkg/detectors/zenserp/zenserp.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Zenserp secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) for _, match := range matches { diff --git a/pkg/detectors/zeplin/zeplin.go b/pkg/detectors/zeplin/zeplin.go index fe41d8d98d0c..ee3213aeaacd 100644 --- a/pkg/detectors/zeplin/zeplin.go +++ b/pkg/detectors/zeplin/zeplin.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Zeplin secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/zeplin/zeplin_test.go b/pkg/detectors/zeplin/zeplin_test.go index d4c496521936..2c5ec92823cc 100644 --- a/pkg/detectors/zeplin/zeplin_test.go +++ b/pkg/detectors/zeplin/zeplin_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/zerobounce/zerobounce.go b/pkg/detectors/zerobounce/zerobounce.go index 936b1431aed4..04bdbdbceff8 100644 --- a/pkg/detectors/zerobounce/zerobounce.go +++ b/pkg/detectors/zerobounce/zerobounce.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Zerobounce secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/zerobounce/zerobounce_test.go b/pkg/detectors/zerobounce/zerobounce_test.go index e011c8974468..2c6efed5489d 100644 --- a/pkg/detectors/zerobounce/zerobounce_test.go +++ b/pkg/detectors/zerobounce/zerobounce_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/zerotier/zerotier.go b/pkg/detectors/zerotier/zerotier.go index 332d51ca70ea..7f6a583c8424 100644 --- a/pkg/detectors/zerotier/zerotier.go +++ b/pkg/detectors/zerotier/zerotier.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Zerotier secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/zipapi/zipapi.go b/pkg/detectors/zipapi/zipapi.go index 2f25c2e8aee5..5890ef1d2d5e 100644 --- a/pkg/detectors/zipapi/zipapi.go +++ b/pkg/detectors/zipapi/zipapi.go @@ -35,7 +35,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Zipapi secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) emailMatches := emailPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/zipapi/zipapi_test.go b/pkg/detectors/zipapi/zipapi_test.go index 8c5c73a1e847..7c6af4ec36d9 100644 --- a/pkg/detectors/zipapi/zipapi_test.go +++ b/pkg/detectors/zipapi/zipapi_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/zipbooks/zipbooks.go b/pkg/detectors/zipbooks/zipbooks.go index ba7d5801f564..dafc58e9113f 100644 --- a/pkg/detectors/zipbooks/zipbooks.go +++ b/pkg/detectors/zipbooks/zipbooks.go @@ -33,7 +33,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Zipbooks secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := emailPat.FindAllStringSubmatch(dataStr, -1) pwordMatches := pwordPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/zipcodeapi/zipcodeapi.go b/pkg/detectors/zipcodeapi/zipcodeapi.go index a4949f1c1b5d..00cff5cf3cb0 100644 --- a/pkg/detectors/zipcodeapi/zipcodeapi.go +++ b/pkg/detectors/zipcodeapi/zipcodeapi.go @@ -32,7 +32,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ZipCodeAPI secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/zipcodeapi/zipcodeapi_test.go b/pkg/detectors/zipcodeapi/zipcodeapi_test.go index 718f9152eabd..f26a8b2a9edb 100644 --- a/pkg/detectors/zipcodeapi/zipcodeapi_test.go +++ b/pkg/detectors/zipcodeapi/zipcodeapi_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/zipcodebase/zipcodebase.go b/pkg/detectors/zipcodebase/zipcodebase.go index f153a8a2f6c6..e6f474959caf 100644 --- a/pkg/detectors/zipcodebase/zipcodebase.go +++ b/pkg/detectors/zipcodebase/zipcodebase.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify Zipcodebase secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/zipcodebase/zipcodebase_test.go b/pkg/detectors/zipcodebase/zipcodebase_test.go index 2a5fd2a0d529..3d7d4bd0746f 100644 --- a/pkg/detectors/zipcodebase/zipcodebase_test.go +++ b/pkg/detectors/zipcodebase/zipcodebase_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/zonkafeedback/zonkafeedback.go b/pkg/detectors/zonkafeedback/zonkafeedback.go index 90160fc78e11..36850276fd52 100644 --- a/pkg/detectors/zonkafeedback/zonkafeedback.go +++ b/pkg/detectors/zonkafeedback/zonkafeedback.go @@ -31,7 +31,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ZonkaFeedback secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) diff --git a/pkg/detectors/zonkafeedback/zonkafeedback_test.go b/pkg/detectors/zonkafeedback/zonkafeedback_test.go index 0dc18b8719cc..508f7077657a 100644 --- a/pkg/detectors/zonkafeedback/zonkafeedback_test.go +++ b/pkg/detectors/zonkafeedback/zonkafeedback_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/kylelemons/godebug/pretty" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common" diff --git a/pkg/detectors/zulipchat/zulipchat.go b/pkg/detectors/zulipchat/zulipchat.go index 1164836c869a..b4df182c096b 100644 --- a/pkg/detectors/zulipchat/zulipchat.go +++ b/pkg/detectors/zulipchat/zulipchat.go @@ -12,7 +12,7 @@ import ( "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" ) -type Scanner struct{ +type Scanner struct { client *http.Client } @@ -36,7 +36,7 @@ func (s Scanner) Keywords() []string { // FromData will find and optionally verify ZulipChat secrets in a given set of bytes. func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) { - dataStr := string(data) + dataStr := common.BytesToString(data) matches := keyPat.FindAllStringSubmatch(dataStr, -1) idMatches := idPat.FindAllStringSubmatch(dataStr, -1) @@ -62,14 +62,14 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result s1 := detectors.Result{ DetectorType: detectorspb.DetectorType_ZulipChat, Raw: []byte(resMatch), - RawV2: []byte(fmt.Sprintf("%s:%s:%s",resMatch, resIdMatch, resDomainMatch)), + RawV2: []byte(fmt.Sprintf("%s:%s:%s", resMatch, resIdMatch, resDomainMatch)), } if verify { client := s.client - if client == nil { - client = defaultClient - } + if client == nil { + client = defaultClient + } req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("https://%s/api/v1/users", resDomainMatch), nil) if err != nil { continue @@ -91,9 +91,9 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result s1.VerificationError = err } } - if !s1.Verified && detectors.IsKnownFalsePositive(resMatch, detectors.DefaultFalsePositives, true) { - continue - } + if !s1.Verified && detectors.IsKnownFalsePositive(resMatch, detectors.DefaultFalsePositives, true) { + continue + } results = append(results, s1) } diff --git a/pkg/detectors/zulipchat/zulipchat_test.go b/pkg/detectors/zulipchat/zulipchat_test.go index c16eb28499d3..4e2be96f9e5b 100644 --- a/pkg/detectors/zulipchat/zulipchat_test.go +++ b/pkg/detectors/zulipchat/zulipchat_test.go @@ -6,11 +6,12 @@ package zulipchat import ( "context" "fmt" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "testing" "time" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/common"