-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
fix: fixed verification endpoint and verification logic for brand fetch #3470
base: main
Are you sure you want to change the base?
fix: fixed verification endpoint and verification logic for brand fetch #3470
Conversation
"domain": "www.example.com" | ||
}`) | ||
req, err := http.NewRequestWithContext(ctx, "POST", "https://api.brandfetch.io/v1/color", payload) | ||
// API upgraded to v2 from v1, new API doc: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API documentation link is missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added, thanks @kashifkhan0771
}`) | ||
req, err := http.NewRequestWithContext(ctx, "POST", "https://api.brandfetch.io/v1/color", payload) | ||
// API upgraded to v2 from v1, new API doc: https://docs.brandfetch.com/reference/brand-api | ||
req, err := http.NewRequestWithContext(ctx, "GET", "https://api.brandfetch.io/v2/brands/google.com", nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current v1
APIs with the old tokens are still functioning properly. Therefore, rather than updating the existing version, I would recommend adding a new version of the detector.
@@ -20,7 +21,7 @@ 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{"brandfetch"}) + `\b([0-9A-Za-z]{40})\b`) | |||
keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"brandfetch"}) + `\b([a-zA-Z0-9=]{44})`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The token I received included a /
character as well. Its length was 44, which seems correct. I recommend generating multiple tokens to confirm the pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enhanced regex and created new version for the API v2
@@ -1642,6 +1642,8 @@ func DefaultDetectors() []detectors.Detector { | |||
meraki.Scanner{}, | |||
saladcloudapikey.Scanner{}, | |||
boxoauth.Scanner{}, | |||
brandfetchV1.Scanner{}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing Versioner interface implementation. For reference see any detector which has two versions (e.g Github, Gitlab etc)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ll create an issue to document this better since it can be confusing for most contributors. Even I find the interface smuggling confusing at times, so it’s likely unclear to others as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing Versioner interface implementation
Can you give me an example of PR where this is implemented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the implementation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have made the relevant changes.
Signed-off-by: Sahil Silare <[email protected]>
"github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb" | ||
) | ||
|
||
func TestBrandfetch_FromChunk(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These test cases for v2 might fail as the regex is different and these v2 secrets does not exist in the vault.
I am not sure what to do here so tagging experts 👨🏻💻 @zricethezav @mcastorina @abmussani
And please add the the pattern test cases for both versions separately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description:
Fixes #3469 .
Checklist:
make test-community
)?make lint
this requires golangci-lint)?