Skip to content

Commit 37c4eea

Browse files
authored
[chore] - ioutil.ReadFile is deprecated (#753)
* Use os.ReadFile. * Update imports. * remove unused import.
1 parent fa2d6b9 commit 37c4eea

92 files changed

Lines changed: 208 additions & 213 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

hack/generate/generate.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package main
22

33
import (
44
"fmt"
5-
"io/ioutil"
65
"log"
76
"os"
87
"path/filepath"
@@ -77,7 +76,7 @@ func mustWriteTemplates(jobs []templateJob) {
7776

7877
// Write the files from templates.
7978
for _, job := range jobs {
80-
tmplBytes, err := ioutil.ReadFile(job.TemplatePath)
79+
tmplBytes, err := os.ReadFile(job.TemplatePath)
8180
if err != nil {
8281
log.Fatal(err)
8382
}

pkg/detectors/abuseipdb/abuseipdb.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@ package abuseipdb
22

33
import (
44
"context"
5-
"io/ioutil"
6-
5+
"io"
6+
"net/http"
77
// "log"
88
"regexp"
99
"strings"
1010

11-
"net/http"
12-
1311
"github.com/trufflesecurity/trufflehog/v3/pkg/common"
1412
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors"
1513
"github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb"
@@ -58,11 +56,11 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
5856
req.Header.Add("Key", resMatch)
5957
res, err := client.Do(req)
6058
if err == nil {
61-
bodyBytes, err := ioutil.ReadAll(res.Body)
59+
bodyBytes, err := io.ReadAll(res.Body)
6260
if err == nil {
6361
bodyString := string(bodyBytes)
6462
validResponse := strings.Contains(bodyString, `ipAddress`)
65-
//errCode := strings.Contains(bodyString, `AbuseIPDB APIv2 Server.`)
63+
// errCode := strings.Contains(bodyString, `AbuseIPDB APIv2 Server.`)
6664

6765
defer res.Body.Close()
6866
if res.StatusCode >= 200 && res.StatusCode < 300 {

pkg/detectors/allsports/allsports.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@ package allsports
22

33
import (
44
"context"
5-
"io/ioutil"
6-
5+
"io"
6+
"net/http"
77
// "log"
88
"regexp"
99
"strings"
1010

11-
"net/http"
12-
1311
"github.com/trufflesecurity/trufflehog/v3/pkg/common"
1412
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors"
1513
"github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb"
@@ -58,7 +56,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
5856
res, err := client.Do(req)
5957
if err == nil {
6058
defer res.Body.Close()
61-
bodyBytes, err := ioutil.ReadAll(res.Body)
59+
bodyBytes, err := io.ReadAll(res.Body)
6260
if err != nil {
6361
continue
6462
}

pkg/detectors/amadeus/amadeus.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package amadeus
22

33
import (
44
"context"
5-
"io/ioutil"
5+
"io"
66
"net/http"
77
"regexp"
88
"strings"
@@ -66,7 +66,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
6666
res, err := client.Do(req)
6767
if err == nil {
6868
defer res.Body.Close()
69-
bodyBytes, err := ioutil.ReadAll(res.Body)
69+
bodyBytes, err := io.ReadAll(res.Body)
7070
if err != nil {
7171
continue
7272
}

pkg/detectors/api2cart/api2cart.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"encoding/json"
66
"fmt"
7-
"io/ioutil"
7+
"io"
88
"net/http"
99
"regexp"
1010
"strings"
@@ -57,7 +57,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
5757
res, err := client.Do(req)
5858
if err == nil {
5959
defer res.Body.Close()
60-
body, errBody := ioutil.ReadAll(res.Body)
60+
body, errBody := io.ReadAll(res.Body)
6161

6262
var result Response
6363
if errBody == nil {

pkg/detectors/appointedd/appointedd.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ package appointedd
22

33
import (
44
"context"
5+
"io"
56
"net/http"
67
"regexp"
78
"strings"
8-
"io/ioutil"
9-
9+
1010
"github.com/trufflesecurity/trufflehog/v3/pkg/common"
1111
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors"
1212
"github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb"
@@ -20,7 +20,7 @@ var _ detectors.Detector = (*Scanner)(nil)
2020
var (
2121
client = common.SaneHttpClient()
2222

23-
//Make sure that your group is surrounded in boundry characters such as below to reduce false positives
23+
// Make sure that your group is surrounded in boundry characters such as below to reduce false positives
2424
keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"appointedd"}) + `\b([a-zA-Z0-9=+]{88})`)
2525
)
2626

@@ -55,7 +55,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
5555
res, err := client.Do(req)
5656
if err == nil {
5757
defer res.Body.Close()
58-
bodyBytes, err := ioutil.ReadAll(res.Body)
58+
bodyBytes, err := io.ReadAll(res.Body)
5959
if err != nil {
6060
continue
6161
}

pkg/detectors/apptivo/apptivo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package apptivo
33
import (
44
"context"
55
"fmt"
6-
"io/ioutil"
6+
"io"
77
"net/http"
88
"regexp"
99
"strings"
@@ -63,7 +63,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
6363
}
6464
res, err := client.Do(req)
6565
if err == nil {
66-
bodyBytes, err := ioutil.ReadAll(res.Body)
66+
bodyBytes, err := io.ReadAll(res.Body)
6767
if err != nil {
6868
continue
6969
}

pkg/detectors/audd/audd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package audd
33
import (
44
"context"
55
"fmt"
6-
"io/ioutil"
6+
"io"
77
"net/http"
88
"regexp"
99
"strings"
@@ -55,7 +55,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
5555
}
5656
res, err := client.Do(req)
5757
if err == nil {
58-
bodyBytes, err := ioutil.ReadAll(res.Body)
58+
bodyBytes, err := io.ReadAll(res.Body)
5959
if err == nil {
6060
bodyString := string(bodyBytes)
6161
validResponse := strings.Contains(bodyString, `"status":"success"`)

pkg/detectors/auth0oauth/auth0oauth.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package auth0oauth
22

33
import (
44
"context"
5-
"io/ioutil"
5+
"io"
66
"net/http"
77
"net/url"
88
"regexp"
@@ -88,7 +88,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
8888
res, err := client.Do(req)
8989
if err == nil {
9090
defer res.Body.Close()
91-
bodyBytes, err := ioutil.ReadAll(res.Body)
91+
bodyBytes, err := io.ReadAll(res.Body)
9292
if err != nil {
9393
continue
9494
}

pkg/detectors/autoklose/autoklose.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"encoding/json"
66
"fmt"
7-
"io/ioutil"
7+
"io"
88
"net/http"
99
"regexp"
1010
"strings"
@@ -56,7 +56,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
5656
}
5757
res, err := client.Do(req)
5858
if err == nil {
59-
bodyBytes, err := ioutil.ReadAll(res.Body)
59+
bodyBytes, err := io.ReadAll(res.Body)
6060
if err != nil {
6161
continue
6262
}

0 commit comments

Comments
 (0)