Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update readme.go #795

Merged
merged 4 commits into from
Sep 18, 2022
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions pkg/detectors/readme/readme.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"net/http"
"regexp"
"strings"

"github.com/trufflesecurity/trufflehog/v3/pkg/common"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors"
Expand All @@ -20,13 +19,13 @@ var (
client = common.SaneHttpClient()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Try to use the default client here. http.DefaultClient. I think this will resolve the 403. I'm not entirely sure why their API does not allow for our custom client, given it only includes some timeouts and keep lives, but that seems to be the issue.


// 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 @@ -39,7 +38,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
if len(match) != 2 {
continue
}
resMatch := strings.TrimSpace(match[1])
resMatch := match[1]

s1 := detectors.Result{
DetectorType: detectorspb.DetectorType_ReadMe,
Expand Down