mirror of
https://github.com/trufflesecurity/trufflehog.git
synced 2024-11-10 15:14:38 +00:00
fix: NewRelic Detector: fallback to EU Api for verification (#1932)
This commit is contained in:
parent
7bc0b77374
commit
8184a62e24
1 changed files with 16 additions and 1 deletions
|
@ -48,11 +48,16 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
|||
|
||||
if verify {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", "https://api.newrelic.com/v2/users.json", nil)
|
||||
if err != nil {
|
||||
reqEU, errEU := http.NewRequestWithContext(ctx, "GET", "https://api.eu.newrelic.com/v2/users.json", nil)
|
||||
if err != nil || errEU != nil {
|
||||
continue
|
||||
}
|
||||
req.Header.Add("X-Api-Key", resMatch)
|
||||
reqEU.Header.Add("X-Api-Key", resMatch)
|
||||
|
||||
res, err := client.Do(req)
|
||||
resEU, errEU := client.Do(reqEU)
|
||||
|
||||
if err == nil {
|
||||
defer res.Body.Close()
|
||||
if res.StatusCode >= 200 && res.StatusCode < 300 {
|
||||
|
@ -63,6 +68,16 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
|||
continue
|
||||
}
|
||||
}
|
||||
} else if errEU == nil {
|
||||
defer resEU.Body.Close()
|
||||
if resEU.StatusCode >= 200 && resEU.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, false) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue