Skip to content

Commit

Permalink
[chore] Address more linter errors (trufflesecurity#1134)
Browse files Browse the repository at this point in the history
* Address lint errors in detectors

* Update deprecated ioutil call
  • Loading branch information
mcastorina authored Feb 28, 2023
1 parent 4efe531 commit 6209a80
Show file tree
Hide file tree
Showing 34 changed files with 30 additions and 73 deletions.
3 changes: 1 addition & 2 deletions pkg/detectors/abbysale/abbysale.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package abbysale

import (
"context"
"fmt"
"net/http"
"regexp"
"strings"
Expand Down Expand Up @@ -52,7 +51,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
if err != nil {
continue
}
req.Header.Add("x-api-key", fmt.Sprintf("%s", resMatch))
req.Header.Add("x-api-key", resMatch)
res, err := client.Do(req)
if err == nil {
defer res.Body.Close()
Expand Down
2 changes: 1 addition & 1 deletion pkg/detectors/bitfinex/bitfinex.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result

s1.Verified = isValid
// If there is a valid one, we need to stop iterating now and return the valid result
if isValid == true {
if isValid {
break
}
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/detectors/brandfetch/brandfetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package brandfetch

import (
"context"
"fmt"
"net/http"
"regexp"
"strings"
Expand Down Expand Up @@ -56,7 +55,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
continue
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("x-api-key", fmt.Sprintf("%s", resMatch))
req.Header.Add("x-api-key", resMatch)
res, err := client.Do(req)
if err == nil {
defer res.Body.Close()
Expand Down
3 changes: 1 addition & 2 deletions pkg/detectors/clockify/clockify.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package clockify

import (
"context"
"fmt"
"net/http"
"regexp"
"strings"
Expand Down Expand Up @@ -53,7 +52,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
continue
}
req.Header.Add("content-type", "application/json")
req.Header.Add("X-Api-Key", fmt.Sprintf("%s", resMatch))
req.Header.Add("X-Api-Key", resMatch)
res, err := client.Do(req)
if err == nil {
defer res.Body.Close()
Expand Down
1 change: 0 additions & 1 deletion pkg/detectors/cloudflarecakey/cloudflarecakey.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
if res.StatusCode >= 200 && res.StatusCode < 300 {
s1.Verified = true
}
} else {
}
}

Expand Down
3 changes: 1 addition & 2 deletions pkg/detectors/everhour/everhour.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package everhour

import (
"context"
"fmt"
"net/http"
"regexp"
"strings"
Expand Down Expand Up @@ -53,7 +52,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
continue
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-Api-Key", fmt.Sprintf("%s", resMatch))
req.Header.Add("X-Api-Key", resMatch)
res, err := client.Do(req)
if err == nil {
defer res.Body.Close()
Expand Down
2 changes: 1 addition & 1 deletion pkg/detectors/fastlypersonaltoken/fastlypersonaltoken.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
if err != nil {
continue
}
req.Header.Add("Fastly-Key", fmt.Sprintf("%s", resMatch))
req.Header.Add("Fastly-Key", resMatch)
res, err := client.Do(req)
if err == nil {
bodyBytes, err := io.ReadAll(res.Body)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package figmapersonalaccesstoken

import (
"context"
"fmt"
"net/http"
"regexp"
"strings"
Expand Down Expand Up @@ -51,7 +50,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
if err != nil {
continue
}
req.Header.Add("X-Figma-Token", fmt.Sprintf("%s", resMatch))
req.Header.Add("X-Figma-Token", resMatch)
res, err := client.Do(req)
if err == nil {
defer res.Body.Close()
Expand Down
3 changes: 1 addition & 2 deletions pkg/detectors/fulcrum/fulcrum.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package fulcrum

import (
"context"
"fmt"
"net/http"
"regexp"
"strings"
Expand Down Expand Up @@ -53,7 +52,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
continue
}
req.Header.Add("Accept", "application/json")
req.Header.Add("X-ApiToken", fmt.Sprintf("%s", resMatch))
req.Header.Add("X-ApiToken", resMatch)
res, err := client.Do(req)
if err == nil {
defer res.Body.Close()
Expand Down
3 changes: 1 addition & 2 deletions pkg/detectors/generic/generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ func New() Scanner {
}

type Scanner struct {
programmingBookWords []string
excludeMatchers []*regexp.Regexp
excludeMatchers []*regexp.Regexp
}

// Ensure the Scanner satisfies the interface at compile time.
Expand Down
3 changes: 1 addition & 2 deletions pkg/detectors/impala/impala.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package impala

import (
"context"
"fmt"
"net/http"
"regexp"
"strings"
Expand Down Expand Up @@ -52,7 +51,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
if err != nil {
continue
}
req.Header.Add("x-api-key", fmt.Sprintf("%s", resMatch))
req.Header.Add("x-api-key", resMatch)
res, err := client.Do(req)
if err == nil {
defer res.Body.Close()
Expand Down
5 changes: 0 additions & 5 deletions pkg/detectors/interseller/interseller.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
defer res.Body.Close()
if res.StatusCode >= 200 && res.StatusCode < 300 {
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
// if detectors.IsKnownFalsePositive(resMatch, detectors.DefaultFalsePositives, true) {
// continue
// }
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/detectors/keenio/keenio.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package keenio

import (
"context"
"fmt"
"net/http"
"regexp"
"strings"
Expand Down Expand Up @@ -61,7 +60,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
continue
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", fmt.Sprintf("%s", resMatch))
req.Header.Add("Authorization", resMatch)
res, err := client.Do(req)
if err == nil {
defer res.Body.Close()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package newrelicpersonalapikey

import (
"context"
"fmt"
"net/http"
"regexp"
"strings"
Expand Down Expand Up @@ -52,7 +51,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
if err != nil {
continue
}
req.Header.Add("X-Api-Key", fmt.Sprintf("%s", resMatch))
req.Header.Add("X-Api-Key", resMatch)
res, err := client.Do(req)
if err == nil {
defer res.Body.Close()
Expand Down
3 changes: 1 addition & 2 deletions pkg/detectors/newscatcher/newscatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package newscatcher

import (
"context"
"fmt"
"net/http"
"regexp"
"strings"
Expand Down Expand Up @@ -52,7 +51,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
if err != nil {
continue
}
req.Header.Add("x-api-key", fmt.Sprintf("%s", resMatch))
req.Header.Add("x-api-key", resMatch)
res, err := client.Do(req)
if err == nil {
defer res.Body.Close()
Expand Down
3 changes: 1 addition & 2 deletions pkg/detectors/nftport/nftport.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package nftport

import (
"context"
"fmt"
"net/http"
"regexp"
"strings"
Expand Down Expand Up @@ -53,7 +52,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
continue
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", fmt.Sprintf("%s", resMatch))
req.Header.Add("Authorization", resMatch)
res, err := client.Do(req)
if err == nil {
defer res.Body.Close()
Expand Down
3 changes: 1 addition & 2 deletions pkg/detectors/omnisend/omnisend.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package omnisend

import (
"context"
"fmt"
"net/http"
"regexp"
"strings"
Expand Down Expand Up @@ -52,7 +51,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
if err != nil {
continue
}
req.Header.Add("X-API-KEY", fmt.Sprintf("%s", resMatch))
req.Header.Add("X-API-KEY", resMatch)
res, err := client.Do(req)
if err == nil {
defer res.Body.Close()
Expand Down
3 changes: 1 addition & 2 deletions pkg/detectors/openuv/openuv.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package openuv

import (
"context"
"fmt"
"net/http"
"regexp"
"strings"
Expand Down Expand Up @@ -52,7 +51,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
if err != nil {
continue
}
req.Header.Add("x-access-token", fmt.Sprintf("%s", resMatch))
req.Header.Add("x-access-token", resMatch)
res, err := client.Do(req)
if err == nil {
defer res.Body.Close()
Expand Down
3 changes: 1 addition & 2 deletions pkg/detectors/pepipost/pepipost.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package pepipost

import (
"context"
"fmt"
"net/http"
"regexp"
"strings"
Expand Down Expand Up @@ -52,7 +51,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
if err != nil {
continue
}
req.Header.Add("api_key", fmt.Sprintf("%s", resMatch))
req.Header.Add("api_key", resMatch)
res, err := client.Do(req)
if err == nil {
defer res.Body.Close()
Expand Down
3 changes: 1 addition & 2 deletions pkg/detectors/postman/postman.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package postman

import (
"context"
"fmt"
"net/http"
"regexp"
"strings"
Expand Down Expand Up @@ -52,7 +51,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
if err != nil {
continue
}
req.Header.Add("x-api-key", fmt.Sprintf("%s", resMatch))
req.Header.Add("x-api-key", resMatch)
res, err := client.Do(req)
if err == nil {
defer res.Body.Close()
Expand Down
3 changes: 1 addition & 2 deletions pkg/detectors/postmark/postmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package postmark

import (
"context"
"fmt"
"net/http"
"regexp"
"strings"
Expand Down Expand Up @@ -53,7 +52,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
}
req.Header.Add("Accept", "application/json")
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-Postmark-Server-Token", fmt.Sprintf("%s", resMatch))
req.Header.Add("X-Postmark-Server-Token", resMatch)
res, err := client.Do(req)
if err == nil {
defer res.Body.Close()
Expand Down
3 changes: 1 addition & 2 deletions pkg/detectors/prospectio/prospectio.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package prospectio

import (
"context"
"fmt"
"net/http"
"regexp"
"strings"
Expand Down Expand Up @@ -52,7 +51,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
if err != nil {
continue
}
req.Header.Add("Authorization", fmt.Sprintf("%s", resMatch))
req.Header.Add("Authorization", resMatch)
req.Header.Add("Content-Type", "application/vnd.api+json; charset=utf-8")
res, err := client.Do(req)
if err == nil {
Expand Down
3 changes: 1 addition & 2 deletions pkg/detectors/pushbulletapikey/pushbulletapikey.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package pushbulletapikey

import (
"context"
"fmt"
"net/http"
"regexp"
"strings"
Expand Down Expand Up @@ -52,7 +51,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
if err != nil {
continue
}
req.Header.Add("Access-Token", fmt.Sprintf("%s", resMatch))
req.Header.Add("Access-Token", resMatch)
res, err := client.Do(req)
if err == nil {
defer res.Body.Close()
Expand Down
3 changes: 1 addition & 2 deletions pkg/detectors/qubole/qubole.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package qubole

import (
"context"
"fmt"
"net/http"
"regexp"
"strings"
Expand Down Expand Up @@ -54,7 +53,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Accept", "application/json")
req.Header.Add("X-AUTH-TOKEN", fmt.Sprintf("%s", resMatch))
req.Header.Add("X-AUTH-TOKEN", resMatch)
res, err := client.Do(req)
if err == nil {
defer res.Body.Close()
Expand Down
3 changes: 1 addition & 2 deletions pkg/detectors/rapidapi/rapidapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package rapidapi

import (
"context"
"fmt"
"net/http"
"regexp"
"strings"
Expand Down Expand Up @@ -51,7 +50,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
if err != nil {
continue
}
req.Header.Add("x-rapidapi-key", fmt.Sprintf("%s", resMatch))
req.Header.Add("x-rapidapi-key", resMatch)
res, err := client.Do(req)
if err == nil {
defer res.Body.Close()
Expand Down
1 change: 0 additions & 1 deletion pkg/detectors/rechargepayments/rechargepayments.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ type Scanner struct{}
var _ detectors.Detector = (*Scanner)(nil)

var (
client = common.SaneHttpClient()
verifyURL = "https://api.rechargeapps.com/token_information"

// Make sure that your group is surrounded in boundary characters such as below to reduce false positives.
Expand Down
Loading

0 comments on commit 6209a80

Please sign in to comment.