From 37c4eea66a8f6f72431b1818610823cd612b09c9 Mon Sep 17 00:00:00 2001 From: ahrav Date: Tue, 30 Aug 2022 09:41:12 -0700 Subject: [PATCH] [chore] - ioutil.ReadFile is deprecated (#753) * Use os.ReadFile. * Update imports. * remove unused import. --- hack/generate/generate.go | 3 +-- pkg/detectors/abuseipdb/abuseipdb.go | 10 ++++------ pkg/detectors/allsports/allsports.go | 8 +++----- pkg/detectors/amadeus/amadeus.go | 4 ++-- pkg/detectors/api2cart/api2cart.go | 4 ++-- pkg/detectors/appointedd/appointedd.go | 8 ++++---- pkg/detectors/apptivo/apptivo.go | 4 ++-- pkg/detectors/audd/audd.go | 4 ++-- pkg/detectors/auth0oauth/auth0oauth.go | 4 ++-- pkg/detectors/autoklose/autoklose.go | 4 ++-- pkg/detectors/baseapiio/baseapiio.go | 4 ++-- pkg/detectors/besttime/besttime.go | 4 ++-- pkg/detectors/borgbase/borgbase.go | 4 ++-- .../braintreepayments/braintreepayments.go | 8 ++++---- pkg/detectors/bulbul/bulbul.go | 4 ++-- pkg/detectors/cexio/cexio.go | 4 ++-- pkg/detectors/coinlayer/coinlayer.go | 4 ++-- pkg/detectors/commodities/commodities.go | 4 ++-- pkg/detectors/convier/convier.go | 4 ++-- pkg/detectors/cryptocompare/cryptocompare.go | 4 ++-- pkg/detectors/currencycloud/currencycloud.go | 4 ++-- pkg/detectors/currencylayer/currencylayer.go | 4 ++-- pkg/detectors/dareboost/dareboost.go | 4 ++-- pkg/detectors/diffbot/diffbot.go | 4 ++-- pkg/detectors/dynalist/dynalist.go | 4 ++-- pkg/detectors/dyspatch/dyspatch.go | 4 ++-- pkg/detectors/fakejson/fakejson.go | 4 ++-- pkg/detectors/fetchrss/fetchrss.go | 4 ++-- pkg/detectors/fileio/fileio.go | 4 ++-- .../financialmodelingprep.go | 4 ++-- pkg/detectors/fixerio/fixerio.go | 4 ++-- pkg/detectors/flickr/flickr.go | 4 ++-- pkg/detectors/flightlabs/flightlabs.go | 8 ++++---- pkg/detectors/flightstats/flightstats.go | 4 ++-- pkg/detectors/flowflu/flowflu.go | 4 ++-- pkg/detectors/formbucket/formbucket.go | 4 ++-- pkg/detectors/freshbooks/freshbooks.go | 4 ++-- pkg/detectors/gengo/gengo.go | 4 ++-- pkg/detectors/geocode/geocode.go | 4 ++-- pkg/detectors/getemail/getemail.go | 4 ++-- pkg/detectors/gocanvas/gocanvas.go | 4 ++-- pkg/detectors/heatmapapi/heatmapapi.go | 11 ++++++----- pkg/detectors/holistic/holistic.go | 8 ++++---- pkg/detectors/humanity/humanity.go | 4 ++-- pkg/detectors/ipapi/ipapi.go | 4 ++-- pkg/detectors/ipinfodb/ipinfodb.go | 4 ++-- pkg/detectors/ipquality/ipquality.go | 4 ++-- pkg/detectors/ipstack/ipstack.go | 4 ++-- pkg/detectors/languagelayer/languagelayer.go | 4 ++-- pkg/detectors/linearapi/linearapi.go | 4 ++-- pkg/detectors/mailboxlayer/mailboxlayer.go | 4 ++-- pkg/detectors/mesibo/mesibo.go | 4 ++-- pkg/detectors/metaapi/metaapi.go | 4 ++-- pkg/detectors/mindmeister/mindmeister.go | 4 ++-- pkg/detectors/moosend/moosend.go | 4 ++-- pkg/detectors/mrticktock/mrticktock.go | 4 ++-- pkg/detectors/numverify/numverify.go | 4 ++-- pkg/detectors/onedesk/onedesk.go | 4 ++-- pkg/detectors/paralleldots/paralleldots.go | 3 +-- pkg/detectors/pdflayer/pdflayer.go | 4 ++-- pkg/detectors/planyo/planyo.go | 4 ++-- pkg/detectors/raven/raven.go | 4 ++-- .../reallysimplesystems/reallysimplesystems.go | 4 ++-- pkg/detectors/scrapersite/scrapersite.go | 4 ++-- pkg/detectors/scrapestack/scrapestack.go | 4 ++-- .../screenshotlayer/screenshotlayer.go | 4 ++-- pkg/detectors/semaphore/semaphore.go | 4 ++-- pkg/detectors/serpstack/serpstack.go | 4 ++-- pkg/detectors/shortcut/shortcut.go | 4 ++-- pkg/detectors/simfin/simfin.go | 8 ++++---- pkg/detectors/slackwebhook/slackwebhook.go | 4 ++-- pkg/detectors/sonarcloud/sonarcloud.go | 4 ++-- pkg/detectors/tefter/tefter.go | 8 ++++---- pkg/detectors/teletype/teletype.go | 4 ++-- pkg/detectors/text2data/text2data.go | 4 ++-- pkg/detectors/thinkific/thinkific.go | 4 ++-- pkg/detectors/twelvedata/twelvedata.go | 4 ++-- pkg/detectors/unifyid/unifyid.go | 4 ++-- pkg/detectors/upcdatabase/upcdatabase.go | 4 ++-- pkg/detectors/uptimerobot/uptimerobot.go | 4 ++-- pkg/detectors/userstack/userstack.go | 4 ++-- pkg/detectors/vatlayer/vatlayer.go | 4 ++-- pkg/detectors/walkscore/walkscore.go | 4 ++-- pkg/detectors/weatherstack/weatherstack.go | 4 ++-- pkg/detectors/webscraping/webscraping.go | 4 ++-- pkg/detectors/websitepulse/websitepulse.go | 17 +++++++++-------- pkg/detectors/whoxy/whoxy.go | 4 ++-- pkg/detectors/worldcoinindex/worldcoinindex.go | 4 ++-- pkg/detectors/zenscrape/zenscrape.go | 4 ++-- pkg/detectors/zenserp/zenserp.go | 4 ++-- pkg/detectors/zerobounce/zerobounce.go | 4 ++-- pkg/updater/updater.go | 5 ++--- 92 files changed, 208 insertions(+), 213 deletions(-) diff --git a/hack/generate/generate.go b/hack/generate/generate.go index 7fd8a8994a2c..47ccc50b0843 100644 --- a/hack/generate/generate.go +++ b/hack/generate/generate.go @@ -2,7 +2,6 @@ package main import ( "fmt" - "io/ioutil" "log" "os" "path/filepath" @@ -77,7 +76,7 @@ func mustWriteTemplates(jobs []templateJob) { // Write the files from templates. for _, job := range jobs { - tmplBytes, err := ioutil.ReadFile(job.TemplatePath) + tmplBytes, err := os.ReadFile(job.TemplatePath) if err != nil { log.Fatal(err) } diff --git a/pkg/detectors/abuseipdb/abuseipdb.go b/pkg/detectors/abuseipdb/abuseipdb.go index fc538f7ec0da..f081bff72f1f 100644 --- a/pkg/detectors/abuseipdb/abuseipdb.go +++ b/pkg/detectors/abuseipdb/abuseipdb.go @@ -2,14 +2,12 @@ package abuseipdb import ( "context" - "io/ioutil" - + "io" + "net/http" // "log" "regexp" "strings" - "net/http" - "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" @@ -58,11 +56,11 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result req.Header.Add("Key", resMatch) res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err == nil { bodyString := string(bodyBytes) validResponse := strings.Contains(bodyString, `ipAddress`) - //errCode := strings.Contains(bodyString, `AbuseIPDB APIv2 Server.`) + // errCode := strings.Contains(bodyString, `AbuseIPDB APIv2 Server.`) defer res.Body.Close() if res.StatusCode >= 200 && res.StatusCode < 300 { diff --git a/pkg/detectors/allsports/allsports.go b/pkg/detectors/allsports/allsports.go index 3b3ef2ce4ec6..4dc997f16442 100644 --- a/pkg/detectors/allsports/allsports.go +++ b/pkg/detectors/allsports/allsports.go @@ -2,14 +2,12 @@ package allsports import ( "context" - "io/ioutil" - + "io" + "net/http" // "log" "regexp" "strings" - "net/http" - "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" @@ -58,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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/amadeus/amadeus.go b/pkg/detectors/amadeus/amadeus.go index cef1d86c4c6d..ae788af977af 100644 --- a/pkg/detectors/amadeus/amadeus.go +++ b/pkg/detectors/amadeus/amadeus.go @@ -2,7 +2,7 @@ package amadeus import ( "context" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -66,7 +66,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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/api2cart/api2cart.go b/pkg/detectors/api2cart/api2cart.go index 9568dafb89f0..01204a7c1279 100644 --- a/pkg/detectors/api2cart/api2cart.go +++ b/pkg/detectors/api2cart/api2cart.go @@ -4,7 +4,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -57,7 +57,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() - body, errBody := ioutil.ReadAll(res.Body) + body, errBody := io.ReadAll(res.Body) var result Response if errBody == nil { diff --git a/pkg/detectors/appointedd/appointedd.go b/pkg/detectors/appointedd/appointedd.go index c13c8cd45fc5..0b6782341950 100644 --- a/pkg/detectors/appointedd/appointedd.go +++ b/pkg/detectors/appointedd/appointedd.go @@ -2,11 +2,11 @@ package appointedd import ( "context" + "io" "net/http" "regexp" "strings" - "io/ioutil" - + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" @@ -20,7 +20,7 @@ var _ detectors.Detector = (*Scanner)(nil) var ( client = common.SaneHttpClient() - //Make sure that your group is surrounded in boundry characters such as below to reduce false positives + // Make sure that your group is surrounded in boundry characters such as below to reduce false positives keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"appointedd"}) + `\b([a-zA-Z0-9=+]{88})`) ) @@ -55,7 +55,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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/apptivo/apptivo.go b/pkg/detectors/apptivo/apptivo.go index 6a7d654038c1..084329433416 100644 --- a/pkg/detectors/apptivo/apptivo.go +++ b/pkg/detectors/apptivo/apptivo.go @@ -3,7 +3,7 @@ package apptivo import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -63,7 +63,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/audd/audd.go b/pkg/detectors/audd/audd.go index 6fdde0714e91..9cb549e476e3 100644 --- a/pkg/detectors/audd/audd.go +++ b/pkg/detectors/audd/audd.go @@ -3,7 +3,7 @@ package audd import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -55,7 +55,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err == nil { bodyString := string(bodyBytes) validResponse := strings.Contains(bodyString, `"status":"success"`) diff --git a/pkg/detectors/auth0oauth/auth0oauth.go b/pkg/detectors/auth0oauth/auth0oauth.go index 47a89661ad55..56af8b69035e 100644 --- a/pkg/detectors/auth0oauth/auth0oauth.go +++ b/pkg/detectors/auth0oauth/auth0oauth.go @@ -2,7 +2,7 @@ package auth0oauth import ( "context" - "io/ioutil" + "io" "net/http" "net/url" "regexp" @@ -88,7 +88,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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/autoklose/autoklose.go b/pkg/detectors/autoklose/autoklose.go index b96983eb4442..311f3159f7be 100644 --- a/pkg/detectors/autoklose/autoklose.go +++ b/pkg/detectors/autoklose/autoklose.go @@ -4,7 +4,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -56,7 +56,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/baseapiio/baseapiio.go b/pkg/detectors/baseapiio/baseapiio.go index ec571fad9c20..ed8a460700d8 100644 --- a/pkg/detectors/baseapiio/baseapiio.go +++ b/pkg/detectors/baseapiio/baseapiio.go @@ -3,7 +3,7 @@ package baseapiio import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -57,7 +57,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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/besttime/besttime.go b/pkg/detectors/besttime/besttime.go index 0869e1464226..28b7f7e6313d 100644 --- a/pkg/detectors/besttime/besttime.go +++ b/pkg/detectors/besttime/besttime.go @@ -2,7 +2,7 @@ package besttime import ( "context" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -55,7 +55,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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/borgbase/borgbase.go b/pkg/detectors/borgbase/borgbase.go index afca05950db8..7e5374e9830c 100644 --- a/pkg/detectors/borgbase/borgbase.go +++ b/pkg/detectors/borgbase/borgbase.go @@ -3,7 +3,7 @@ package borgbase import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -61,7 +61,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", resMatch)) res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err == nil { bodyString := string(bodyBytes) validResponse := strings.Contains(bodyString, `"sshList":[]`) diff --git a/pkg/detectors/braintreepayments/braintreepayments.go b/pkg/detectors/braintreepayments/braintreepayments.go index d68bab96b1ca..fd11698f9df2 100644 --- a/pkg/detectors/braintreepayments/braintreepayments.go +++ b/pkg/detectors/braintreepayments/braintreepayments.go @@ -2,7 +2,7 @@ package braintreepayments import ( "context" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -20,7 +20,7 @@ var _ detectors.Detector = (*Scanner)(nil) var ( client = common.SaneHttpClient() - //Make sure that your group is surrounded in boundry characters such as below to reduce false positives + // Make sure that your group is surrounded in boundry characters such as below to reduce false positives keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"braintree"}) + `\b([0-9a-f]{32})\b`) idPat = regexp.MustCompile(detectors.PrefixRegex([]string{"braintree"}) + `\b([0-9a-z]{16})\b`) ) @@ -67,7 +67,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result req.SetBasicAuth(resIdMatch, resMatch) res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } @@ -79,7 +79,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result if res.StatusCode >= 200 && res.StatusCode < 300 && validResponse { s1.Verified = true } else { - //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 + // 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 detectors.IsKnownFalsePositive(resMatch, detectors.DefaultFalsePositives, true) { continue } diff --git a/pkg/detectors/bulbul/bulbul.go b/pkg/detectors/bulbul/bulbul.go index c5d4e0d15587..1207f323950d 100644 --- a/pkg/detectors/bulbul/bulbul.go +++ b/pkg/detectors/bulbul/bulbul.go @@ -3,7 +3,7 @@ package bulbul import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -55,7 +55,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue diff --git a/pkg/detectors/cexio/cexio.go b/pkg/detectors/cexio/cexio.go index 8d1119bd25fd..7f72fbd4e404 100644 --- a/pkg/detectors/cexio/cexio.go +++ b/pkg/detectors/cexio/cexio.go @@ -7,7 +7,7 @@ import ( "encoding/hex" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "regexp" @@ -92,7 +92,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result if err == nil { defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + body, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/coinlayer/coinlayer.go b/pkg/detectors/coinlayer/coinlayer.go index 1d34da144213..47623dd25243 100644 --- a/pkg/detectors/coinlayer/coinlayer.go +++ b/pkg/detectors/coinlayer/coinlayer.go @@ -3,7 +3,7 @@ package coinlayer import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -55,7 +55,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err == nil { bodyString := string(bodyBytes) validResponse := strings.Contains(bodyString, `"success": true`) || strings.Contains(bodyString, `"info":"Access Restricted - Your current Subscription Plan does not support HTTPS Encryption."`) diff --git a/pkg/detectors/commodities/commodities.go b/pkg/detectors/commodities/commodities.go index e63fbd32c3f0..6f4a8285f27e 100644 --- a/pkg/detectors/commodities/commodities.go +++ b/pkg/detectors/commodities/commodities.go @@ -2,7 +2,7 @@ package commodities import ( "context" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -56,7 +56,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/convier/convier.go b/pkg/detectors/convier/convier.go index e65f0190232f..c4ce78f8fbd2 100644 --- a/pkg/detectors/convier/convier.go +++ b/pkg/detectors/convier/convier.go @@ -3,7 +3,7 @@ package convier import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -59,7 +59,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", resMatch)) res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/cryptocompare/cryptocompare.go b/pkg/detectors/cryptocompare/cryptocompare.go index 98367ff8be74..65f952d0cb15 100644 --- a/pkg/detectors/cryptocompare/cryptocompare.go +++ b/pkg/detectors/cryptocompare/cryptocompare.go @@ -2,7 +2,7 @@ package cryptocompare import ( "context" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -54,7 +54,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/currencycloud/currencycloud.go b/pkg/detectors/currencycloud/currencycloud.go index a1a04481b536..d13710559421 100644 --- a/pkg/detectors/currencycloud/currencycloud.go +++ b/pkg/detectors/currencycloud/currencycloud.go @@ -2,7 +2,7 @@ package currencycloud import ( "context" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -66,7 +66,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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/currencylayer/currencylayer.go b/pkg/detectors/currencylayer/currencylayer.go index dd753985f8f4..eb339a913667 100644 --- a/pkg/detectors/currencylayer/currencylayer.go +++ b/pkg/detectors/currencylayer/currencylayer.go @@ -3,7 +3,7 @@ package currencylayer import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -56,7 +56,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } res, err := client.Do(req) if err == nil { - bodyBytes, err2 := ioutil.ReadAll(res.Body) + bodyBytes, err2 := io.ReadAll(res.Body) if err2 == nil { bodyString := string(bodyBytes) validResponse := strings.Contains(bodyString, `"success": true`) || strings.Contains(bodyString, `"info":"Access Restricted - Your current Subscription Plan does not support HTTPS Encryption."`) diff --git a/pkg/detectors/dareboost/dareboost.go b/pkg/detectors/dareboost/dareboost.go index 3707eae2e668..14162ba75f5a 100644 --- a/pkg/detectors/dareboost/dareboost.go +++ b/pkg/detectors/dareboost/dareboost.go @@ -2,7 +2,7 @@ package dareboost import ( "context" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -57,7 +57,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result req.Header.Add("Content-Type", "application/json") res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/diffbot/diffbot.go b/pkg/detectors/diffbot/diffbot.go index 309b7ca38897..1ae1e9d7d569 100644 --- a/pkg/detectors/diffbot/diffbot.go +++ b/pkg/detectors/diffbot/diffbot.go @@ -3,7 +3,7 @@ package diffbot import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -58,7 +58,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err == nil { bodyString := string(bodyBytes) validResponse := strings.Contains(bodyString, `"token":`) && strings.Contains(bodyString, `"planCredits":`) diff --git a/pkg/detectors/dynalist/dynalist.go b/pkg/detectors/dynalist/dynalist.go index 75f17b448eea..b84c19b02066 100644 --- a/pkg/detectors/dynalist/dynalist.go +++ b/pkg/detectors/dynalist/dynalist.go @@ -3,7 +3,7 @@ package dynalist import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -57,7 +57,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result req.Header.Add("Content-Type", "application/json") res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err == nil { bodyString := string(bodyBytes) validResponse := strings.Contains(bodyString, `"_code":"Ok"`) diff --git a/pkg/detectors/dyspatch/dyspatch.go b/pkg/detectors/dyspatch/dyspatch.go index 2392eb273db1..949e67653f8a 100644 --- a/pkg/detectors/dyspatch/dyspatch.go +++ b/pkg/detectors/dyspatch/dyspatch.go @@ -3,7 +3,7 @@ package dyspatch import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -58,7 +58,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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/fakejson/fakejson.go b/pkg/detectors/fakejson/fakejson.go index 95c000836690..74121ddb3a5d 100644 --- a/pkg/detectors/fakejson/fakejson.go +++ b/pkg/detectors/fakejson/fakejson.go @@ -3,7 +3,7 @@ package fakejson import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -57,7 +57,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result req.Header.Add("Content-Type", "application/json") res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err == nil { bodyString := string(bodyBytes) validResponse := strings.Contains(bodyString, `"user_email":`) diff --git a/pkg/detectors/fetchrss/fetchrss.go b/pkg/detectors/fetchrss/fetchrss.go index 7e98cb38ea20..d47d2f82bf10 100644 --- a/pkg/detectors/fetchrss/fetchrss.go +++ b/pkg/detectors/fetchrss/fetchrss.go @@ -2,7 +2,7 @@ package fetchrss import ( "context" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -55,7 +55,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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/fileio/fileio.go b/pkg/detectors/fileio/fileio.go index b87b83d17849..4ea1dc6ee329 100644 --- a/pkg/detectors/fileio/fileio.go +++ b/pkg/detectors/fileio/fileio.go @@ -4,7 +4,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -57,7 +57,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", resMatch)) res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err == nil { isJson := json.Valid(bodyBytes) defer res.Body.Close() diff --git a/pkg/detectors/financialmodelingprep/financialmodelingprep.go b/pkg/detectors/financialmodelingprep/financialmodelingprep.go index 3e924a94c06b..bc9cd3abeff6 100644 --- a/pkg/detectors/financialmodelingprep/financialmodelingprep.go +++ b/pkg/detectors/financialmodelingprep/financialmodelingprep.go @@ -3,7 +3,7 @@ package financialmodelingprep import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -55,7 +55,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) bodyString := string(bodyBytes) if err == nil { // valid response should be an array of currencies diff --git a/pkg/detectors/fixerio/fixerio.go b/pkg/detectors/fixerio/fixerio.go index 3f55305a7b86..3666fd9bd4dd 100644 --- a/pkg/detectors/fixerio/fixerio.go +++ b/pkg/detectors/fixerio/fixerio.go @@ -2,7 +2,7 @@ package fixerio import ( "context" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/flickr/flickr.go b/pkg/detectors/flickr/flickr.go index e0593adbfec6..106405c37347 100644 --- a/pkg/detectors/flickr/flickr.go +++ b/pkg/detectors/flickr/flickr.go @@ -3,7 +3,7 @@ package flickr import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -57,7 +57,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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/flightlabs/flightlabs.go b/pkg/detectors/flightlabs/flightlabs.go index a7cf18929582..f17f2daac3ec 100644 --- a/pkg/detectors/flightlabs/flightlabs.go +++ b/pkg/detectors/flightlabs/flightlabs.go @@ -3,7 +3,7 @@ package flightlabs import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -21,7 +21,7 @@ var _ detectors.Detector = (*Scanner)(nil) var ( client = common.SaneHttpClient() - //Make sure that your group is surrounded in boundry characters such as below to reduce false positives + // Make sure that your group is surrounded in boundry characters such as below to reduce false positives keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"flightlabs"}) + `\b(ey[a-zA-Z0-9]{34}.ey[a-zA-Z0-9._-]{300,350})\b`) ) @@ -56,7 +56,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } @@ -66,7 +66,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result if res.StatusCode >= 200 && res.StatusCode < 300 && validResponse { s1.Verified = true } else { - //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 + // 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 detectors.IsKnownFalsePositive(resMatch, detectors.DefaultFalsePositives, true) { continue } diff --git a/pkg/detectors/flightstats/flightstats.go b/pkg/detectors/flightstats/flightstats.go index 5b0eded3b3e3..303c8ad574e1 100644 --- a/pkg/detectors/flightstats/flightstats.go +++ b/pkg/detectors/flightstats/flightstats.go @@ -3,7 +3,7 @@ package flightstats import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -65,7 +65,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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/flowflu/flowflu.go b/pkg/detectors/flowflu/flowflu.go index ff8f0a5fe10d..960c9a414e73 100644 --- a/pkg/detectors/flowflu/flowflu.go +++ b/pkg/detectors/flowflu/flowflu.go @@ -3,7 +3,7 @@ package flowflu import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -64,7 +64,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/formbucket/formbucket.go b/pkg/detectors/formbucket/formbucket.go index cbdcbe2075b9..cc3ef787eb94 100644 --- a/pkg/detectors/formbucket/formbucket.go +++ b/pkg/detectors/formbucket/formbucket.go @@ -3,7 +3,7 @@ package formbucket import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -58,7 +58,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() - body, errBody := ioutil.ReadAll(res.Body) + body, errBody := io.ReadAll(res.Body) if errBody != nil { continue } diff --git a/pkg/detectors/freshbooks/freshbooks.go b/pkg/detectors/freshbooks/freshbooks.go index 39f3a6386b5d..8fafe7407847 100644 --- a/pkg/detectors/freshbooks/freshbooks.go +++ b/pkg/detectors/freshbooks/freshbooks.go @@ -3,7 +3,7 @@ package freshbooks import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -63,7 +63,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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/gengo/gengo.go b/pkg/detectors/gengo/gengo.go index bd920e089615..129dd5cf66cc 100644 --- a/pkg/detectors/gengo/gengo.go +++ b/pkg/detectors/gengo/gengo.go @@ -7,7 +7,7 @@ import ( "encoding/hex" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strconv" @@ -77,7 +77,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() - body, errBody := ioutil.ReadAll(res.Body) + body, errBody := io.ReadAll(res.Body) if errBody == nil { var response Response diff --git a/pkg/detectors/geocode/geocode.go b/pkg/detectors/geocode/geocode.go index e3dd8d182961..b67590abfce4 100644 --- a/pkg/detectors/geocode/geocode.go +++ b/pkg/detectors/geocode/geocode.go @@ -3,7 +3,7 @@ package geocode import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -55,7 +55,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err == nil { bodyString := string(bodyBytes) validResponse := strings.Contains(bodyString, `"remaining_credits" :`) diff --git a/pkg/detectors/getemail/getemail.go b/pkg/detectors/getemail/getemail.go index dbe3626a50f7..3ee4d624da00 100644 --- a/pkg/detectors/getemail/getemail.go +++ b/pkg/detectors/getemail/getemail.go @@ -3,7 +3,7 @@ package getemail import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -55,7 +55,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/gocanvas/gocanvas.go b/pkg/detectors/gocanvas/gocanvas.go index 2a6bba6d9553..a24297457dc9 100644 --- a/pkg/detectors/gocanvas/gocanvas.go +++ b/pkg/detectors/gocanvas/gocanvas.go @@ -4,7 +4,7 @@ import ( "context" "encoding/xml" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "regexp" @@ -72,7 +72,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() - body, errBody := ioutil.ReadAll(res.Body) + body, errBody := io.ReadAll(res.Body) if errBody == nil { response := Response{} diff --git a/pkg/detectors/heatmapapi/heatmapapi.go b/pkg/detectors/heatmapapi/heatmapapi.go index 7143c844c95e..bcd2659579d0 100644 --- a/pkg/detectors/heatmapapi/heatmapapi.go +++ b/pkg/detectors/heatmapapi/heatmapapi.go @@ -2,11 +2,12 @@ package heatmapapi import ( "context" + "fmt" + "io" "net/http" "regexp" "strings" - "io/ioutil" - "fmt" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" @@ -20,7 +21,7 @@ var _ detectors.Detector = (*Scanner)(nil) var ( client = common.SaneHttpClient() - //Make sure that your group is surrounded in boundry characters such as below to reduce false positives + // Make sure that your group is surrounded in boundry characters such as below to reduce false positives keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"heatmapapi"}) + `\b([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\b`) ) @@ -48,14 +49,14 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } if verify { - req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("http://www.heatmapapi.com/javascript/HeatmapAPI2.aspx?k=%s",resMatch), nil) + req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("http://www.heatmapapi.com/javascript/HeatmapAPI2.aspx?k=%s", resMatch), nil) if err != nil { continue } res, err := client.Do(req) if err == nil { defer res.Body.Close() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/holistic/holistic.go b/pkg/detectors/holistic/holistic.go index adce07d8b2b7..7ec06246107b 100644 --- a/pkg/detectors/holistic/holistic.go +++ b/pkg/detectors/holistic/holistic.go @@ -2,7 +2,7 @@ package holistic import ( "context" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -20,7 +20,7 @@ var _ detectors.Detector = (*Scanner)(nil) var ( client = common.SaneHttpClient() - //Make sure that your group is surrounded in boundry characters such as below to reduce false positives + // Make sure that your group is surrounded in boundry characters such as below to reduce false positives keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"holistic"}) + `\b([0-9a-f]{64})\b`) ) @@ -55,7 +55,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 { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } @@ -67,7 +67,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result if res.StatusCode >= 200 && res.StatusCode < 300 && !errorResponse { s1.Verified = true } else { - //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 + // 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 detectors.IsKnownFalsePositive(resMatch, detectors.DefaultFalsePositives, true) { continue } diff --git a/pkg/detectors/humanity/humanity.go b/pkg/detectors/humanity/humanity.go index ceeedb722f82..8465044bdba2 100644 --- a/pkg/detectors/humanity/humanity.go +++ b/pkg/detectors/humanity/humanity.go @@ -2,7 +2,7 @@ package humanity import ( "context" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -55,7 +55,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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/ipapi/ipapi.go b/pkg/detectors/ipapi/ipapi.go index 5749b31e2e40..6d761bdae92b 100644 --- a/pkg/detectors/ipapi/ipapi.go +++ b/pkg/detectors/ipapi/ipapi.go @@ -3,7 +3,7 @@ package ipapi import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -55,7 +55,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err == nil { bodyString := string(bodyBytes) diff --git a/pkg/detectors/ipinfodb/ipinfodb.go b/pkg/detectors/ipinfodb/ipinfodb.go index ab68a2130947..07b6676be271 100644 --- a/pkg/detectors/ipinfodb/ipinfodb.go +++ b/pkg/detectors/ipinfodb/ipinfodb.go @@ -3,7 +3,7 @@ package ipinfodb import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -55,7 +55,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err == nil { bodyString := string(bodyBytes) validResponse := strings.Contains(bodyString, `"statusCode": "OK"`) diff --git a/pkg/detectors/ipquality/ipquality.go b/pkg/detectors/ipquality/ipquality.go index 6535c604ff3a..53273a47416f 100644 --- a/pkg/detectors/ipquality/ipquality.go +++ b/pkg/detectors/ipquality/ipquality.go @@ -3,7 +3,7 @@ package ipquality import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -57,7 +57,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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/ipstack/ipstack.go b/pkg/detectors/ipstack/ipstack.go index 3f62889ecbdd..82a7d0a7e7e0 100644 --- a/pkg/detectors/ipstack/ipstack.go +++ b/pkg/detectors/ipstack/ipstack.go @@ -2,7 +2,7 @@ package ipstack import ( "context" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -54,7 +54,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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/languagelayer/languagelayer.go b/pkg/detectors/languagelayer/languagelayer.go index fa38f9ef1995..17799ec2a0d4 100644 --- a/pkg/detectors/languagelayer/languagelayer.go +++ b/pkg/detectors/languagelayer/languagelayer.go @@ -3,7 +3,7 @@ package languagelayer import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -55,7 +55,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err == nil { bodyString := string(bodyBytes) validResponse := strings.Contains(bodyString, `results`) || strings.Contains(bodyString, `"info":"Access Restricted - Your current Subscription Plan does not support HTTPS Encryption."`) diff --git a/pkg/detectors/linearapi/linearapi.go b/pkg/detectors/linearapi/linearapi.go index 36022b642f53..a1f5920aa975 100644 --- a/pkg/detectors/linearapi/linearapi.go +++ b/pkg/detectors/linearapi/linearapi.go @@ -2,7 +2,7 @@ package linearapi import ( "context" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -59,7 +59,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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/mailboxlayer/mailboxlayer.go b/pkg/detectors/mailboxlayer/mailboxlayer.go index d7b8800f8964..d51484f99e93 100644 --- a/pkg/detectors/mailboxlayer/mailboxlayer.go +++ b/pkg/detectors/mailboxlayer/mailboxlayer.go @@ -2,7 +2,7 @@ package mailboxlayer import ( "context" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -55,7 +55,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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/mesibo/mesibo.go b/pkg/detectors/mesibo/mesibo.go index fdbf071af815..541a444efba9 100644 --- a/pkg/detectors/mesibo/mesibo.go +++ b/pkg/detectors/mesibo/mesibo.go @@ -2,7 +2,7 @@ package mesibo import ( "context" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -55,7 +55,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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/metaapi/metaapi.go b/pkg/detectors/metaapi/metaapi.go index 51d0975eb091..e2ca68644693 100644 --- a/pkg/detectors/metaapi/metaapi.go +++ b/pkg/detectors/metaapi/metaapi.go @@ -3,7 +3,7 @@ package metaapi import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -66,7 +66,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() - body, errBody := ioutil.ReadAll(res.Body) + body, errBody := io.ReadAll(res.Body) if errBody == nil { bodyStr := string(body) diff --git a/pkg/detectors/mindmeister/mindmeister.go b/pkg/detectors/mindmeister/mindmeister.go index 80ad81944340..bbeca142b652 100644 --- a/pkg/detectors/mindmeister/mindmeister.go +++ b/pkg/detectors/mindmeister/mindmeister.go @@ -3,7 +3,7 @@ package mindmeister import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -56,7 +56,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", resMatch)) res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err == nil { bodyString := string(bodyBytes) validResponse := strings.Contains(bodyString, `"stat":"ok"`) diff --git a/pkg/detectors/moosend/moosend.go b/pkg/detectors/moosend/moosend.go index c3325b89f939..e3f8c24c120f 100644 --- a/pkg/detectors/moosend/moosend.go +++ b/pkg/detectors/moosend/moosend.go @@ -2,7 +2,7 @@ package moosend import ( "context" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -55,7 +55,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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/mrticktock/mrticktock.go b/pkg/detectors/mrticktock/mrticktock.go index 72367e38b7c2..fbebf2d72cfe 100644 --- a/pkg/detectors/mrticktock/mrticktock.go +++ b/pkg/detectors/mrticktock/mrticktock.go @@ -3,7 +3,7 @@ package mrticktock import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -66,7 +66,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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/numverify/numverify.go b/pkg/detectors/numverify/numverify.go index 9a2062f8837a..2a6e5a779b1e 100644 --- a/pkg/detectors/numverify/numverify.go +++ b/pkg/detectors/numverify/numverify.go @@ -3,7 +3,7 @@ package numverify import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -50,7 +50,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err == nil { bodyString := string(bodyBytes) validResponse := strings.Contains(bodyString, `country_code`) || strings.Contains(bodyString, `"info":"Access Restricted - Your current Subscription Plan does not support HTTPS Encryption."`) diff --git a/pkg/detectors/onedesk/onedesk.go b/pkg/detectors/onedesk/onedesk.go index e11b87f88784..8d1411ac028e 100644 --- a/pkg/detectors/onedesk/onedesk.go +++ b/pkg/detectors/onedesk/onedesk.go @@ -3,7 +3,7 @@ package onedesk import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -65,7 +65,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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/paralleldots/paralleldots.go b/pkg/detectors/paralleldots/paralleldots.go index af4cadded29d..acf566c3a2ea 100644 --- a/pkg/detectors/paralleldots/paralleldots.go +++ b/pkg/detectors/paralleldots/paralleldots.go @@ -4,7 +4,6 @@ import ( "bytes" "context" "io" - "io/ioutil" "mime/multipart" "net/http" "regexp" @@ -78,7 +77,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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/pdflayer/pdflayer.go b/pkg/detectors/pdflayer/pdflayer.go index 1ce4647298fe..c64325462e76 100644 --- a/pkg/detectors/pdflayer/pdflayer.go +++ b/pkg/detectors/pdflayer/pdflayer.go @@ -3,7 +3,7 @@ package pdflayer import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -55,7 +55,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err == nil { bodyString := string(bodyBytes) validResponse := strings.Contains(bodyString, `Contents`) diff --git a/pkg/detectors/planyo/planyo.go b/pkg/detectors/planyo/planyo.go index d94de4d46516..6291d1d97d17 100644 --- a/pkg/detectors/planyo/planyo.go +++ b/pkg/detectors/planyo/planyo.go @@ -3,7 +3,7 @@ package planyo import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -57,7 +57,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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/raven/raven.go b/pkg/detectors/raven/raven.go index 946211e9486d..e866a6e0c22a 100644 --- a/pkg/detectors/raven/raven.go +++ b/pkg/detectors/raven/raven.go @@ -4,7 +4,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -56,7 +56,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/reallysimplesystems/reallysimplesystems.go b/pkg/detectors/reallysimplesystems/reallysimplesystems.go index dde05f4abaa8..d3bee2f14b93 100644 --- a/pkg/detectors/reallysimplesystems/reallysimplesystems.go +++ b/pkg/detectors/reallysimplesystems/reallysimplesystems.go @@ -4,7 +4,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -57,7 +57,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", resMatch)) res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/scrapersite/scrapersite.go b/pkg/detectors/scrapersite/scrapersite.go index 902e6352b553..2b14a3b9a43b 100644 --- a/pkg/detectors/scrapersite/scrapersite.go +++ b/pkg/detectors/scrapersite/scrapersite.go @@ -3,7 +3,7 @@ package scrapersite import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -55,7 +55,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/scrapestack/scrapestack.go b/pkg/detectors/scrapestack/scrapestack.go index dbc26038897a..41eb3f5d790f 100644 --- a/pkg/detectors/scrapestack/scrapestack.go +++ b/pkg/detectors/scrapestack/scrapestack.go @@ -3,7 +3,7 @@ package scrapestack import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -55,7 +55,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err == nil { bodyString := string(bodyBytes) validResponse := strings.Contains(bodyString, `html`) || strings.Contains(bodyString, `"info":"Access Restricted - Your current Subscription Plan does not support HTTPS Encryption."`) diff --git a/pkg/detectors/screenshotlayer/screenshotlayer.go b/pkg/detectors/screenshotlayer/screenshotlayer.go index 530c0bbfda37..8fa64590c129 100644 --- a/pkg/detectors/screenshotlayer/screenshotlayer.go +++ b/pkg/detectors/screenshotlayer/screenshotlayer.go @@ -3,7 +3,7 @@ package screenshotlayer import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -55,7 +55,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err == nil { bodyString := string(bodyBytes) validResponse := strings.Contains(bodyString, `PNG`) diff --git a/pkg/detectors/semaphore/semaphore.go b/pkg/detectors/semaphore/semaphore.go index 4926c6e42da8..bddecc80b86b 100644 --- a/pkg/detectors/semaphore/semaphore.go +++ b/pkg/detectors/semaphore/semaphore.go @@ -3,7 +3,7 @@ package semaphore import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -61,7 +61,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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/serpstack/serpstack.go b/pkg/detectors/serpstack/serpstack.go index b26f2bc1346e..8fac9dcfae57 100644 --- a/pkg/detectors/serpstack/serpstack.go +++ b/pkg/detectors/serpstack/serpstack.go @@ -3,7 +3,7 @@ package serpstack import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -58,7 +58,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err == nil { bodyString := string(bodyBytes) validResponse := strings.Contains(bodyString, `search_url`) || strings.Contains(bodyString, `"info":"Access Restricted - Your current Subscription Plan does not support HTTPS Encryption."`) diff --git a/pkg/detectors/shortcut/shortcut.go b/pkg/detectors/shortcut/shortcut.go index b420c81de4aa..3e9194855d26 100644 --- a/pkg/detectors/shortcut/shortcut.go +++ b/pkg/detectors/shortcut/shortcut.go @@ -2,7 +2,7 @@ package shortcut import ( "context" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -57,7 +57,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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/simfin/simfin.go b/pkg/detectors/simfin/simfin.go index 6df2081db353..45b8b038e2b1 100644 --- a/pkg/detectors/simfin/simfin.go +++ b/pkg/detectors/simfin/simfin.go @@ -3,7 +3,7 @@ package simfin import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -21,7 +21,7 @@ var _ detectors.Detector = (*Scanner)(nil) var ( client = common.SaneHttpClient() - //Make sure that your group is surrounded in boundry characters such as below to reduce false positives + // Make sure that your group is surrounded in boundry characters such as below to reduce false positives keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"simfin"}) + `\b([a-zA-Z0-9]{32})\b`) ) @@ -56,7 +56,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } @@ -66,7 +66,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result if res.StatusCode >= 200 && res.StatusCode < 300 && validResponse { s1.Verified = true } else { - //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 + // 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 detectors.IsKnownFalsePositive(resMatch, detectors.DefaultFalsePositives, true) { continue } diff --git a/pkg/detectors/slackwebhook/slackwebhook.go b/pkg/detectors/slackwebhook/slackwebhook.go index 1969d68270cb..739ba721c49a 100644 --- a/pkg/detectors/slackwebhook/slackwebhook.go +++ b/pkg/detectors/slackwebhook/slackwebhook.go @@ -2,7 +2,7 @@ package slackwebhook import ( "context" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -57,7 +57,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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/sonarcloud/sonarcloud.go b/pkg/detectors/sonarcloud/sonarcloud.go index 91a5c7560fd0..39e1c1ea22a3 100644 --- a/pkg/detectors/sonarcloud/sonarcloud.go +++ b/pkg/detectors/sonarcloud/sonarcloud.go @@ -2,7 +2,7 @@ package sonarcloud import ( "context" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -54,7 +54,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/tefter/tefter.go b/pkg/detectors/tefter/tefter.go index 296bb02b8e2c..9767c3c993b7 100644 --- a/pkg/detectors/tefter/tefter.go +++ b/pkg/detectors/tefter/tefter.go @@ -3,7 +3,7 @@ package tefter import ( "context" "encoding/json" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -21,7 +21,7 @@ var _ detectors.Detector = (*Scanner)(nil) var ( client = common.SaneHttpClient() - //Make sure that your group is surrounded in boundry characters such as below to reduce false positives + // Make sure that your group is surrounded in boundry characters such as below to reduce false positives keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"tefter"}) + `\b([0-9a-zA-Z]{20})\b`) ) @@ -57,7 +57,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result req.Header.Add("X-User-Token", resMatch) res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } @@ -68,7 +68,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result if res.StatusCode >= 200 && res.StatusCode < 300 && validResponse { s1.Verified = true } else { - //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 + // 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 detectors.IsKnownFalsePositive(resMatch, detectors.DefaultFalsePositives, true) { continue } diff --git a/pkg/detectors/teletype/teletype.go b/pkg/detectors/teletype/teletype.go index d3199dd01048..905bf6a8d3f1 100644 --- a/pkg/detectors/teletype/teletype.go +++ b/pkg/detectors/teletype/teletype.go @@ -2,7 +2,7 @@ package teletype import ( "context" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -56,7 +56,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result req.Header.Add("X-Auth-Token", resMatch) res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/text2data/text2data.go b/pkg/detectors/text2data/text2data.go index 2fed92bfbb14..2e5ed68fdb82 100644 --- a/pkg/detectors/text2data/text2data.go +++ b/pkg/detectors/text2data/text2data.go @@ -2,7 +2,7 @@ package text2data import ( "context" - "io/ioutil" + "io" "net/http" "net/url" "regexp" @@ -63,7 +63,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() - body, errBody := ioutil.ReadAll(res.Body) + body, errBody := io.ReadAll(res.Body) if errBody == nil { bodyString := string(body) diff --git a/pkg/detectors/thinkific/thinkific.go b/pkg/detectors/thinkific/thinkific.go index d46834c432dc..11e96f9c036d 100644 --- a/pkg/detectors/thinkific/thinkific.go +++ b/pkg/detectors/thinkific/thinkific.go @@ -3,7 +3,7 @@ package thinkific import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -67,7 +67,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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/twelvedata/twelvedata.go b/pkg/detectors/twelvedata/twelvedata.go index c163d6f1d9d5..e0c99e6dc951 100644 --- a/pkg/detectors/twelvedata/twelvedata.go +++ b/pkg/detectors/twelvedata/twelvedata.go @@ -2,7 +2,7 @@ package twelvedata import ( "context" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/unifyid/unifyid.go b/pkg/detectors/unifyid/unifyid.go index bbf8d69d4efd..0a128db450c0 100644 --- a/pkg/detectors/unifyid/unifyid.go +++ b/pkg/detectors/unifyid/unifyid.go @@ -2,7 +2,7 @@ package unifyid import ( "context" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -58,7 +58,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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/upcdatabase/upcdatabase.go b/pkg/detectors/upcdatabase/upcdatabase.go index 5bea46f83584..62cb3c71abea 100644 --- a/pkg/detectors/upcdatabase/upcdatabase.go +++ b/pkg/detectors/upcdatabase/upcdatabase.go @@ -3,7 +3,7 @@ package upcdatabase import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -55,7 +55,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err == nil { bodyString := string(bodyBytes) validResponse := strings.Contains(bodyString, `added_time`) diff --git a/pkg/detectors/uptimerobot/uptimerobot.go b/pkg/detectors/uptimerobot/uptimerobot.go index 050500e66cfc..afe4ae6b5907 100644 --- a/pkg/detectors/uptimerobot/uptimerobot.go +++ b/pkg/detectors/uptimerobot/uptimerobot.go @@ -2,7 +2,7 @@ package uptimerobot import ( "context" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -54,7 +54,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/userstack/userstack.go b/pkg/detectors/userstack/userstack.go index 461359645ed4..07ccc731232f 100644 --- a/pkg/detectors/userstack/userstack.go +++ b/pkg/detectors/userstack/userstack.go @@ -3,7 +3,7 @@ package userstack import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -55,7 +55,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err == nil { bodyString := string(bodyBytes) valid := strings.Contains(bodyString, `is_mobile_device`) || strings.Contains(bodyString, `"info":"Access Restricted - Your current Subscription Plan does not support HTTPS Encryption."`) diff --git a/pkg/detectors/vatlayer/vatlayer.go b/pkg/detectors/vatlayer/vatlayer.go index e0772ec43620..e036e0960ac7 100644 --- a/pkg/detectors/vatlayer/vatlayer.go +++ b/pkg/detectors/vatlayer/vatlayer.go @@ -3,7 +3,7 @@ package vatlayer import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -55,7 +55,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err == nil { bodyString := string(bodyBytes) validResponse := strings.Contains(bodyString, `vat_number`) || strings.Contains(bodyString, `"info":"Access Restricted - Your current Subscription Plan does not support HTTPS Encryption."`) diff --git a/pkg/detectors/walkscore/walkscore.go b/pkg/detectors/walkscore/walkscore.go index e84089224fd4..b3316aaffc6b 100644 --- a/pkg/detectors/walkscore/walkscore.go +++ b/pkg/detectors/walkscore/walkscore.go @@ -3,7 +3,7 @@ package walkscore import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -57,7 +57,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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/weatherstack/weatherstack.go b/pkg/detectors/weatherstack/weatherstack.go index 41e4efe88466..df8d9f6a8d84 100644 --- a/pkg/detectors/weatherstack/weatherstack.go +++ b/pkg/detectors/weatherstack/weatherstack.go @@ -3,7 +3,7 @@ package weatherstack import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -57,7 +57,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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/webscraping/webscraping.go b/pkg/detectors/webscraping/webscraping.go index 8bb147262c3c..3582f7f639d2 100644 --- a/pkg/detectors/webscraping/webscraping.go +++ b/pkg/detectors/webscraping/webscraping.go @@ -2,7 +2,7 @@ package webscraping import ( "context" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -55,7 +55,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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/websitepulse/websitepulse.go b/pkg/detectors/websitepulse/websitepulse.go index a10caa9266a0..403f7b711f28 100644 --- a/pkg/detectors/websitepulse/websitepulse.go +++ b/pkg/detectors/websitepulse/websitepulse.go @@ -2,11 +2,12 @@ package websitepulse import ( "context" + "fmt" + "io" "net/http" "regexp" "strings" - "io/ioutil" -"fmt" + "github.com/trufflesecurity/trufflehog/v3/pkg/common" "github.com/trufflesecurity/trufflehog/v3/pkg/detectors" "github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" @@ -20,9 +21,9 @@ var _ detectors.Detector = (*Scanner)(nil) var ( client = common.SaneHttpClient() - //Make sure that your group is surrounded in boundry characters such as below to reduce false positives + // Make sure that your group is surrounded in boundry characters such as below to reduce false positives keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"websitepulse"}) + `\b([0-9a-f]{32})\b`) - idPat = regexp.MustCompile(detectors.PrefixRegex([]string{"websitepulse"}) + `\b([0-9a-zA-Z._]{4,22})\b`) + idPat = regexp.MustCompile(detectors.PrefixRegex([]string{"websitepulse"}) + `\b([0-9a-zA-Z._]{4,22})\b`) ) // Keywords are used for efficiently pre-filtering chunks. @@ -54,13 +55,13 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result Raw: []byte(resMatch), } if verify { - req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("https://api.websitepulse.com/textserver.php?method=GetContacts&username=%s&key=%s",resIdMatch,resMatch), nil) + req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("https://api.websitepulse.com/textserver.php?method=GetContacts&username=%s&key=%s", resIdMatch, resMatch), nil) if err != nil { continue } res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } @@ -75,10 +76,10 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } } } - + results = append(results, s1) } - + } return detectors.CleanResults(results), nil diff --git a/pkg/detectors/whoxy/whoxy.go b/pkg/detectors/whoxy/whoxy.go index 394c7f73d72a..a59ad2a0f1be 100644 --- a/pkg/detectors/whoxy/whoxy.go +++ b/pkg/detectors/whoxy/whoxy.go @@ -3,7 +3,7 @@ package whoxy import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -57,7 +57,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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/worldcoinindex/worldcoinindex.go b/pkg/detectors/worldcoinindex/worldcoinindex.go index cf8fc972911f..2c171660aa32 100644 --- a/pkg/detectors/worldcoinindex/worldcoinindex.go +++ b/pkg/detectors/worldcoinindex/worldcoinindex.go @@ -3,7 +3,7 @@ package worldcoinindex import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -55,7 +55,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } res, err := client.Do(req) if err == nil { - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err == nil { bodyString := string(bodyBytes) validResponse := strings.Contains(bodyString, `"Markets"`) diff --git a/pkg/detectors/zenscrape/zenscrape.go b/pkg/detectors/zenscrape/zenscrape.go index 816054e99e52..e980568120ef 100644 --- a/pkg/detectors/zenscrape/zenscrape.go +++ b/pkg/detectors/zenscrape/zenscrape.go @@ -2,7 +2,7 @@ package zenscrape import ( "context" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/zenserp/zenserp.go b/pkg/detectors/zenserp/zenserp.go index 3d9fe45f38ec..4a38273494eb 100644 --- a/pkg/detectors/zenserp/zenserp.go +++ b/pkg/detectors/zenserp/zenserp.go @@ -2,7 +2,7 @@ package zenserp import ( "context" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -54,7 +54,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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/detectors/zerobounce/zerobounce.go b/pkg/detectors/zerobounce/zerobounce.go index b4b8eec488c1..c42a61a2965c 100644 --- a/pkg/detectors/zerobounce/zerobounce.go +++ b/pkg/detectors/zerobounce/zerobounce.go @@ -2,7 +2,7 @@ package zerobounce import ( "context" - "io/ioutil" + "io" "net/http" "regexp" "strings" @@ -55,7 +55,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() - bodyBytes, err := ioutil.ReadAll(res.Body) + bodyBytes, err := io.ReadAll(res.Body) if err != nil { continue } diff --git a/pkg/updater/updater.go b/pkg/updater/updater.go index 5026cf8113df..e728a56478fd 100644 --- a/pkg/updater/updater.go +++ b/pkg/updater/updater.go @@ -7,7 +7,6 @@ import ( "compress/gzip" "encoding/json" "io" - "io/ioutil" "net/http" "runtime" "strings" @@ -34,7 +33,7 @@ type OSS struct { // Init validates the provided config func (g *OSS) Init() error { - //initiate OSS connection + // initiate OSS connection return nil } @@ -81,7 +80,7 @@ func (g *OSS) Fetch() (io.Reader, error) { log.Debug("fetching trufflehog update") - newBinBytes, err := ioutil.ReadAll(resp.Body) + newBinBytes, err := io.ReadAll(resp.Body) if err != nil { return nil, err }