Skip to content

Find, verify, and analyze leaked credentials

Update yousign detector endpoints to check againt prod and staging urls (#3426)

Damanpreet Singh88b8c862a6ee
diff --git a/pkg/detectors/yousign/yousign.go b/pkg/detectors/yousign/yousign.go
index e9680772d..96bd55ef5 100644
--- a/pkg/detectors/yousign/yousign.go
+++ b/pkg/detectors/yousign/yousign.go
@@ -3,10 +3,11 @@ package yousign
import (
"context"
"fmt"
- regexp "github.com/wasilibs/go-re2"
"net/http"
"strings"
+ regexp "github.com/wasilibs/go-re2"
+
"github.com/trufflesecurity/trufflehog/v3/pkg/common"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors"
"github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb"
@@ -14,6 +15,10 @@ import (
type Scanner struct{}
+// docs: https://dev.yousign.com/#api-v3-documentation-new
+const PROD_URL = "https://api.yousign.com"
+const STAGING_URL = "https://staging-api.yousign.com"
+
// Ensure the Scanner satisfies the interface at compile time.
var _ detectors.Detector = (*Scanner)(nil)
@@ -48,7 +53,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
}
if verify {
- req, err := http.NewRequestWithContext(ctx, "GET", "https://staging-api.yousign.com/users", nil)
+ req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("%s/users", PROD_URL), nil)
if err != nil {
continue
}
@@ -59,6 +64,20 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
defer res.Body.Close()
if res.StatusCode >= 200 && res.StatusCode < 300 {
s1.Verified = true
+ } else {
+ req, err = http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("%s/users", STAGING_URL), nil)
+ if err != nil {
+ continue
+ }
+ req.Header.Add("Content-Type", "application/json")
+ req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", resMatch))
+ res, err = client.Do(req)
+ if err == nil {
+ defer res.Body.Close()
+ if res.StatusCode >= 200 && res.StatusCode < 300 {
+ s1.Verified = true
+ }
+ }
}
}
}