Skip to content

Commit

Permalink
Update readme.go (#795)
Browse files Browse the repository at this point in the history
* Update readme.go

Readme has change the way they issue their keys

now its like rdme_{70} ascii chars

* Update readme.go

* Update readme.go

* Update readme.go

The tester seems to be working fine with the new defaultclient code
  • Loading branch information
ankushgoel27 committed Sep 18, 2022
1 parent 59d6d29 commit 44bc023
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pkg/detectors/readme/readme.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"regexp"
"strings"

"github.com/trufflesecurity/trufflehog/v3/pkg/common"

"github.com/trufflesecurity/trufflehog/v3/pkg/detectors"
"github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb"
)
Expand All @@ -17,16 +17,15 @@ type Scanner struct{}
var _ detectors.Detector = (*Scanner)(nil)

var (
client = common.SaneHttpClient()

// Make sure that your group is surrounded in boundary characters such as below to reduce false positives.
keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"readme"}) + `\b([a-zA-Z0-9_]{32})\b`)
keyPat = regexp.MustCompile(`(rdme_[a-z0-9]{70})`)
)

// Keywords are used for efficiently pre-filtering chunks.
// Use identifiers in the secret preferably, or the provider name.
func (s Scanner) Keywords() []string {
return []string{"readme"}
return []string{"rdme_"}
}

// FromData will find and optionally verify ReadMe secrets in a given set of bytes.
Expand All @@ -47,12 +46,13 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
}

if verify {
req, err := http.NewRequestWithContext(ctx, "GET", "https://dash.readme.com/api/v1", nil)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, "https://dash.readme.com/api/v1", nil)
if err != nil {
continue
}
req.SetBasicAuth(resMatch, "")
res, err := client.Do(req)
req.Header.Add("accept", "application/json")
res, err := http.DefaultClient.Do(req)
if err == nil {
defer res.Body.Close()
if res.StatusCode >= 200 && res.StatusCode < 300 {
Expand Down

0 comments on commit 44bc023

Please sign in to comment.