mirror of
https://github.com/trufflesecurity/trufflehog.git
synced 2024-11-10 15:14:38 +00:00
Fix SquareApp detector type return value (#1322)
* Change SquareApp detector type to report as SquareApp instead of Square.
This commit is contained in:
parent
deb0f63d25
commit
87f3f27dab
1 changed files with 4 additions and 5 deletions
|
@ -20,7 +20,7 @@ type Scanner struct{}
|
|||
var _ detectors.Detector = (*Scanner)(nil)
|
||||
|
||||
var (
|
||||
//possibly always `sq0csp` for secret
|
||||
// possibly always `sq0csp` for secret
|
||||
// and `sq0idb` for app
|
||||
keyPat = regexp.MustCompile(`[\w\-]*sq0i[a-z]{2}-[0-9A-Za-z\-_]{22,43}`)
|
||||
secPat = regexp.MustCompile(`[\w\-]*sq0c[a-z]{2}-[0-9A-Za-z\-_]{40,50}`)
|
||||
|
@ -39,7 +39,6 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
|||
matches := keyPat.FindAllString(dataStr, -1)
|
||||
secMatches := secPat.FindAllString(dataStr, -1)
|
||||
for _, match := range matches {
|
||||
|
||||
for _, secMatch := range secMatches {
|
||||
|
||||
if detectors.IsKnownFalsePositive(strings.ToLower(secMatch), detectors.DefaultFalsePositives, true) {
|
||||
|
@ -47,7 +46,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
|||
}
|
||||
|
||||
s := detectors.Result{
|
||||
DetectorType: detectorspb.DetectorType_Square,
|
||||
DetectorType: detectorspb.DetectorType_SquareApp,
|
||||
Raw: []byte(match),
|
||||
Redacted: match,
|
||||
}
|
||||
|
@ -72,7 +71,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
|||
req.Header.Add("Content-Type", "application/json")
|
||||
|
||||
// unclear if this version needs to be set or matters, seems to work without, but docs want it
|
||||
//req.Header.Add("Square-Version", "2020-08-12")
|
||||
// req.Header.Add("Square-Version", "2020-08-12")
|
||||
res, err := client.Do(req)
|
||||
if err == nil {
|
||||
res.Body.Close() // The request body is unused.
|
||||
|
@ -95,5 +94,5 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
|||
}
|
||||
|
||||
func (s Scanner) Type() detectorspb.DetectorType {
|
||||
return detectorspb.DetectorType_Square
|
||||
return detectorspb.DetectorType_SquareApp
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue