detectors: review adjustments
Addresses review feedback on the per-detector commits.
- Rename the extracted verification function to verifyMatch in all 45
detectors. The branch had introduced a per-detector name (verifyCexIO,
verifyWhoxy, ...); verifyMatch is the established convention in this
package and each detector is its own package, so there is no collision.
- gengo and gocanvas were still swallowing the body-read error: a failed
io.ReadAll fell through to `return false, nil` and recorded nothing.
That is the bug this branch exists to fix, so both now return the error.
- Move `defer res.Body.Close()` above io.ReadAll and drain the body first
in the 13 detectors where the deferred close sat after the read, which
left the body unclosed on the error return: commodities, convier,
cryptocompare, dareboost, flowflu, getemail, holistic, raven,
reallysimplesystems, simfin, tefter, teletype, uptimerobot.
- fixerio deferred res.Body.Close() twice; drop the second.
- getemail and teletype had an empty if-branch with the work in the else,
left behind when the redundant `Verified = false` assignment was
removed. Inverted to `if !cond { return true, nil }`.
Status-code interpretation is still carried over verbatim and is not
touched here.
This commit is contained in:
@@ -71,7 +71,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyCexIO(ctx, client, resSecretMatch, resKeyMatch, resUserIdMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resSecretMatch, resKeyMatch, resUserIdMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resSecretMatch, resKeyMatch, resUserIdMatch)
|
||||
}
|
||||
@@ -84,7 +84,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyCexIO(ctx context.Context, client *http.Client, resSecretMatch string, resKeyMatch string, resUserIdMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resSecretMatch string, resKeyMatch string, resUserIdMatch string) (bool, error) {
|
||||
|
||||
timestamp := strconv.FormatInt(time.Now().Unix()*1000, 10)
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyCommodities(ctx, client, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
}
|
||||
@@ -59,7 +59,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyCommodities(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
client.Timeout = 5 * time.Second
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", "https://commodities-api.com/api/latest?access_key="+resMatch, nil)
|
||||
if err != nil {
|
||||
@@ -69,13 +69,16 @@ func verifyCommodities(ctx context.Context, client *http.Client, resMatch string
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
defer func() {
|
||||
_, _ = io.Copy(io.Discard, res.Body)
|
||||
_ = res.Body.Close()
|
||||
}()
|
||||
bodyBytes, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
bodyString := string(bodyBytes)
|
||||
validResponse := strings.Contains(bodyString, `"success":true`)
|
||||
defer func() { _ = res.Body.Close() }()
|
||||
if res.StatusCode >= 200 && res.StatusCode < 300 {
|
||||
if validResponse {
|
||||
return true, nil
|
||||
|
||||
@@ -49,7 +49,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyConvier(ctx, client, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
}
|
||||
@@ -60,7 +60,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyConvier(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
timeout := 10 * time.Second
|
||||
client.Timeout = timeout
|
||||
req, err := http.NewRequestWithContext(ctx, "POST", "https://convier.me/api/event", nil)
|
||||
@@ -72,13 +72,16 @@ func verifyConvier(ctx context.Context, client *http.Client, resMatch string) (b
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
defer func() {
|
||||
_, _ = io.Copy(io.Discard, res.Body)
|
||||
_ = res.Body.Close()
|
||||
}()
|
||||
bodyBytes, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
bodyString := string(bodyBytes)
|
||||
validResponse := strings.Contains(bodyString, `"error":false`)
|
||||
defer func() { _ = res.Body.Close() }()
|
||||
if res.StatusCode >= 200 && res.StatusCode < 300 {
|
||||
if validResponse {
|
||||
return true, nil
|
||||
|
||||
@@ -47,7 +47,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyCryptoCompare(ctx, client, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
}
|
||||
@@ -58,7 +58,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyCryptoCompare(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", "https://min-api.cryptocompare.com/data/blockchain/list?api_key="+resMatch, nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@@ -67,13 +67,16 @@ func verifyCryptoCompare(ctx context.Context, client *http.Client, resMatch stri
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
defer func() {
|
||||
_, _ = io.Copy(io.Discard, res.Body)
|
||||
_ = res.Body.Close()
|
||||
}()
|
||||
bodyBytes, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
bodyString := string(bodyBytes)
|
||||
errCode := strings.Contains(bodyString, `"Response":"Success"`)
|
||||
defer func() { _ = res.Body.Close() }()
|
||||
if res.StatusCode >= 200 && res.StatusCode < 300 {
|
||||
if errCode {
|
||||
return true, nil
|
||||
|
||||
@@ -47,7 +47,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyDareboost(ctx, client, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
}
|
||||
@@ -58,7 +58,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyDareboost(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
payload := strings.NewReader(`{ "token": "` + resMatch + `", "location": "Paris"}`)
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, "POST", "https://api.dareboost.com/0.8/config", payload)
|
||||
@@ -70,6 +70,10 @@ func verifyDareboost(ctx context.Context, client *http.Client, resMatch string)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
defer func() {
|
||||
_, _ = io.Copy(io.Discard, res.Body)
|
||||
_ = res.Body.Close()
|
||||
}()
|
||||
bodyBytes, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@@ -78,7 +82,6 @@ func verifyDareboost(ctx context.Context, client *http.Client, resMatch string)
|
||||
bodyString := string(bodyBytes)
|
||||
validResponse := strings.Contains(bodyString, `"status":200`)
|
||||
|
||||
defer func() { _ = res.Body.Close() }()
|
||||
if res.StatusCode >= 200 && res.StatusCode < 300 {
|
||||
if validResponse {
|
||||
return true, nil
|
||||
|
||||
@@ -48,7 +48,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyDyspatch(ctx, client, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
}
|
||||
@@ -59,7 +59,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyDyspatch(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", "https://api.dyspatch.io/templates", nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
||||
@@ -47,7 +47,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyEtherscan(ctx, client, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
}
|
||||
@@ -58,7 +58,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyEtherscan(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", "https://api.etherscan.io/api?module=account&action=balance&address=0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae&tag=latest&apikey="+resMatch, nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
||||
@@ -47,7 +47,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyFixerIO(ctx, client, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
}
|
||||
@@ -58,7 +58,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyFixerIO(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", "https://data.fixer.io/api/latest?access_key="+resMatch, nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@@ -80,7 +80,6 @@ func verifyFixerIO(ctx context.Context, client *http.Client, resMatch string) (b
|
||||
// ingenious!
|
||||
|
||||
validResponse := strings.Contains(body, `"success": true`) || strings.Contains(body, `"info":"Access Restricted - Your current Subscription Plan does not support HTTPS Encryption."`)
|
||||
defer func() { _ = res.Body.Close() }()
|
||||
|
||||
if res.StatusCode >= 200 && res.StatusCode < 300 && validResponse {
|
||||
return true, nil
|
||||
|
||||
@@ -48,7 +48,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyFlickr(ctx, client, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
}
|
||||
@@ -59,7 +59,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyFlickr(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("https://www.flickr.com/services/rest/?method=flickr.tags.getHotList&api_key=%s", resMatch), nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
||||
@@ -55,7 +55,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyFlightstats(ctx, client, resId, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resId, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resId, resMatch)
|
||||
}
|
||||
@@ -67,7 +67,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyFlightstats(ctx context.Context, client *http.Client, resId string, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resId string, resMatch string) (bool, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("https://api.flightstats.com/flex/aircraft/rest/v1/json/availableFields?appId=%s&appKey=%s", resId, resMatch), nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
||||
@@ -56,7 +56,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyFlowFlu(ctx, client, resAccount, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resAccount, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resAccount, resMatch)
|
||||
}
|
||||
@@ -68,7 +68,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyFlowFlu(ctx context.Context, client *http.Client, resAccount string, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resAccount string, resMatch string) (bool, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("https://%s.flowlu.com/api/v1/module/crm/lead/list?api_key=%s", resAccount, resMatch), nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@@ -77,6 +77,10 @@ func verifyFlowFlu(ctx context.Context, client *http.Client, resAccount string,
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
defer func() {
|
||||
_, _ = io.Copy(io.Discard, res.Body)
|
||||
_ = res.Body.Close()
|
||||
}()
|
||||
bodyBytes, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@@ -85,7 +89,6 @@ func verifyFlowFlu(ctx context.Context, client *http.Client, resAccount string,
|
||||
bodyString := string(bodyBytes)
|
||||
validResponse := strings.Contains(bodyString, `total_result`)
|
||||
|
||||
defer func() { _ = res.Body.Close() }()
|
||||
if res.StatusCode >= 200 && res.StatusCode < 300 {
|
||||
if validResponse {
|
||||
return true, nil
|
||||
|
||||
@@ -53,7 +53,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyFreshbooks(ctx, client, resMatch, resURI)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resMatch, resURI)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch, resURI)
|
||||
}
|
||||
@@ -65,7 +65,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyFreshbooks(ctx context.Context, client *http.Client, resMatch string, resURI string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resMatch string, resURI string) (bool, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf(`https://auth.freshbooks.com/oauth/authorize?client_id=%s&redirect_uri=%s&response_type=code`, resMatch, resURI), nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
||||
@@ -66,7 +66,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyGengo(ctx, client, resSecretMatch, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resSecretMatch, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resSecretMatch, resMatch)
|
||||
}
|
||||
@@ -78,7 +78,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyGengo(ctx context.Context, client *http.Client, resSecretMatch string, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resSecretMatch string, resMatch string) (bool, error) {
|
||||
|
||||
timestamp := strconv.FormatInt(time.Now().Unix(), 10)
|
||||
signature := getGengoSignature(timestamp, resSecretMatch)
|
||||
@@ -93,17 +93,18 @@ func verifyGengo(ctx context.Context, client *http.Client, resSecretMatch string
|
||||
return false, err
|
||||
}
|
||||
defer func() { _ = res.Body.Close() }()
|
||||
body, errBody := io.ReadAll(res.Body)
|
||||
body, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
if errBody == nil {
|
||||
var response Response
|
||||
if err := json.Unmarshal(body, &response); err != nil {
|
||||
return false, err
|
||||
}
|
||||
var response Response
|
||||
if err := json.Unmarshal(body, &response); err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
if res.StatusCode >= 200 && res.StatusCode < 300 && response.OpStat == "ok" {
|
||||
return true, nil
|
||||
}
|
||||
if res.StatusCode >= 200 && res.StatusCode < 300 && response.OpStat == "ok" {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
return false, nil
|
||||
|
||||
@@ -49,7 +49,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyGetEmail(ctx, client, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
}
|
||||
@@ -60,7 +60,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyGetEmail(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("https://api.getemail.io/v1/find-mail?firstname=Larry&lastname=Page&domain=google.com&api_key=%s", resMatch), nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@@ -69,16 +69,18 @@ func verifyGetEmail(ctx context.Context, client *http.Client, resMatch string) (
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
defer func() {
|
||||
_, _ = io.Copy(io.Discard, res.Body)
|
||||
_ = res.Body.Close()
|
||||
}()
|
||||
bodyBytes, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
bodyString := string(bodyBytes)
|
||||
errCode := strings.Contains(bodyString, `"code":"USER_NOT_EXIST"`)
|
||||
defer func() { _ = res.Body.Close() }()
|
||||
if res.StatusCode >= 200 && res.StatusCode < 300 {
|
||||
if errCode {
|
||||
} else {
|
||||
if !errCode {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyGoCanvas(ctx, client, emailMatch, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, emailMatch, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, emailMatch, resMatch)
|
||||
}
|
||||
@@ -71,7 +71,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyGoCanvas(ctx context.Context, client *http.Client, emailMatch string, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, emailMatch string, resMatch string) (bool, error) {
|
||||
payload := url.Values{}
|
||||
payload.Add("username", emailMatch)
|
||||
|
||||
@@ -86,17 +86,18 @@ func verifyGoCanvas(ctx context.Context, client *http.Client, emailMatch string,
|
||||
return false, err
|
||||
}
|
||||
defer func() { _ = res.Body.Close() }()
|
||||
body, errBody := io.ReadAll(res.Body)
|
||||
body, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
if errBody == nil {
|
||||
response := Response{}
|
||||
if err := xml.Unmarshal(body, &response); err != nil {
|
||||
return false, err
|
||||
}
|
||||
response := Response{}
|
||||
if err := xml.Unmarshal(body, &response); err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
if res.StatusCode >= 200 && res.StatusCode < 300 && response.Error == nil {
|
||||
return true, nil
|
||||
}
|
||||
if res.StatusCode >= 200 && res.StatusCode < 300 && response.Error == nil {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
return false, nil
|
||||
|
||||
@@ -47,7 +47,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyHolistic(ctx, client, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
}
|
||||
@@ -58,7 +58,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyHolistic(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", "https://api.holistic.dev/api/v1/project", nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@@ -68,6 +68,10 @@ func verifyHolistic(ctx context.Context, client *http.Client, resMatch string) (
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
defer func() {
|
||||
_, _ = io.Copy(io.Discard, res.Body)
|
||||
_ = res.Body.Close()
|
||||
}()
|
||||
bodyBytes, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@@ -76,7 +80,6 @@ func verifyHolistic(ctx context.Context, client *http.Client, resMatch string) (
|
||||
bodyString := string(bodyBytes)
|
||||
errorResponse := strings.Contains(bodyString, `"data":[]`)
|
||||
|
||||
defer func() { _ = res.Body.Close() }()
|
||||
if res.StatusCode >= 200 && res.StatusCode < 300 && !errorResponse {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyHumanity(ctx, client, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
}
|
||||
@@ -58,7 +58,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyHumanity(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", "https://www.humanity.com/api/v2/me?access_token="+resMatch, nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
||||
@@ -47,7 +47,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyInfura(ctx, client, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
}
|
||||
@@ -58,7 +58,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyInfura(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
payload := strings.NewReader(`{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}`)
|
||||
req, err := http.NewRequestWithContext(ctx, "POST", "https://mainnet.infura.io/v3/"+resMatch, payload)
|
||||
if err != nil {
|
||||
|
||||
@@ -61,7 +61,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
if client == nil {
|
||||
client = defaultClient
|
||||
}
|
||||
isVerified, verificationErr := verifyInstamojo(ctx, client, resClientId, resSecret)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resClientId, resSecret)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resClientId, resSecret)
|
||||
}
|
||||
@@ -73,7 +73,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyInstamojo(ctx context.Context, client *http.Client, resClientId, resSecret string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resClientId, resSecret string) (bool, error) {
|
||||
payload := strings.NewReader("grant_type=client_credentials&client_id=" + resClientId + "&client_secret=" + resSecret)
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, "POST", "https://api.instamojo.com/oauth2/token/", payload)
|
||||
|
||||
@@ -46,7 +46,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyIpStack(ctx, client, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
}
|
||||
@@ -57,7 +57,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyIpStack(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", "https://api.ipstack.com/134.201.250.155?access_key="+resMatch, nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
||||
@@ -47,7 +47,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyLinearAPI(ctx, client, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
}
|
||||
@@ -58,7 +58,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyLinearAPI(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
reqDataQuery := strings.NewReader(`{ "query": "{ viewer { id name } }" }`)
|
||||
req, err := http.NewRequestWithContext(ctx, "POST", "https://api.linear.app/graphql", reqDataQuery)
|
||||
if err != nil {
|
||||
|
||||
@@ -47,7 +47,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyMailboxlayer(ctx, client, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
}
|
||||
@@ -58,7 +58,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyMailboxlayer(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", "https://apilayer.net/api/check?access_key="+resMatch+"&[email protected]", nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
||||
@@ -66,7 +66,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyMetabase(ctx, client, u, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, u, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
}
|
||||
@@ -78,7 +78,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyMetabase(ctx context.Context, client *http.Client, u *url.URL, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, u *url.URL, resMatch string) (bool, error) {
|
||||
u.Path = "/api/user/current"
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)
|
||||
if err != nil {
|
||||
|
||||
@@ -47,7 +47,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyMoosend(ctx, client, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
}
|
||||
@@ -58,7 +58,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyMoosend(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", "https://api.moosend.com/v3/lists.json?apikey="+resMatch+"&format=json", nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
||||
@@ -57,7 +57,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyMrticktock(ctx, client, emailMatch, resPassword)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, emailMatch, resPassword)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, emailMatch, resPassword)
|
||||
}
|
||||
@@ -68,7 +68,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyMrticktock(ctx context.Context, client *http.Client, emailMatch string, resPassword string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, emailMatch string, resPassword string) (bool, error) {
|
||||
payload := strings.NewReader(fmt.Sprintf(`email=%s&password=%s`, emailMatch, resPassword))
|
||||
req, err := http.NewRequestWithContext(ctx, "POST", "https://mrticktock.com/app/api/is_timer_active", payload)
|
||||
if err != nil {
|
||||
|
||||
@@ -57,7 +57,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyOnedesk(ctx, client, emailMatch, resPword)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, emailMatch, resPword)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, emailMatch, resPword)
|
||||
}
|
||||
@@ -68,7 +68,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyOnedesk(ctx context.Context, client *http.Client, emailMatch string, resPword string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, emailMatch string, resPword string) (bool, error) {
|
||||
payload := strings.NewReader(fmt.Sprintf(`{"email": "%s", "password": "%s"}`, emailMatch, resPword))
|
||||
req, err := http.NewRequestWithContext(ctx, "POST", "https://app.onedesk.com/rest/2.0/login/loginUser", payload)
|
||||
if err != nil {
|
||||
|
||||
@@ -49,7 +49,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyParallelDots(ctx, client, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
}
|
||||
@@ -60,7 +60,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyParallelDots(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
payload := &bytes.Buffer{}
|
||||
writer := multipart.NewWriter(payload)
|
||||
fw, err := writer.CreateFormField("api_key")
|
||||
|
||||
@@ -48,7 +48,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyPlanyo(ctx, client, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
}
|
||||
@@ -59,7 +59,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyPlanyo(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("https://www.planyo.com/rest/?method=get_site_info&api_key=%s", resMatch), nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
||||
@@ -49,7 +49,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyRaven(ctx, client, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
}
|
||||
@@ -60,7 +60,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyRaven(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("https://api.raventools.com/api?key=%s&method=profile_info&format=json", resMatch), nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@@ -69,11 +69,14 @@ func verifyRaven(ctx context.Context, client *http.Client, resMatch string) (boo
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
defer func() {
|
||||
_, _ = io.Copy(io.Discard, res.Body)
|
||||
_ = res.Body.Close()
|
||||
}()
|
||||
bodyBytes, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
defer func() { _ = res.Body.Close() }()
|
||||
if res.StatusCode >= 200 && res.StatusCode < 300 {
|
||||
if json.Valid(bodyBytes) {
|
||||
return true, nil
|
||||
|
||||
@@ -57,7 +57,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyRazorPay(ctx, client, key, secret)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, key, secret)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, key, secret)
|
||||
}
|
||||
@@ -70,7 +70,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyRazorPay(ctx context.Context, client *http.Client, key, secret string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, key, secret string) (bool, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", "https://api.razorpay.com/v1/items?count=1", nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
||||
@@ -49,7 +49,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyReallySimpleSystems(ctx, client, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
}
|
||||
@@ -60,7 +60,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyReallySimpleSystems(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", "https://apiv4.reallysimplesystems.com/accounts", nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@@ -70,11 +70,14 @@ func verifyReallySimpleSystems(ctx context.Context, client *http.Client, resMatc
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
defer func() {
|
||||
_, _ = io.Copy(io.Discard, res.Body)
|
||||
_ = res.Body.Close()
|
||||
}()
|
||||
bodyBytes, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
defer func() { _ = res.Body.Close() }()
|
||||
if res.StatusCode >= 200 && res.StatusCode < 300 {
|
||||
if json.Valid(bodyBytes) {
|
||||
return true, nil
|
||||
|
||||
@@ -52,7 +52,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifySemaphore(ctx, client, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
}
|
||||
@@ -63,7 +63,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifySemaphore(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("https://api.semaphore.co/api/v4/account?apikey=%s", resMatch), nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
||||
@@ -48,7 +48,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifySimFin(ctx, client, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
}
|
||||
@@ -59,7 +59,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifySimFin(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("https://simfin.com/api/v2/companies/list?api-key=%s", resMatch), nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@@ -69,13 +69,16 @@ func verifySimFin(ctx context.Context, client *http.Client, resMatch string) (bo
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
defer func() {
|
||||
_, _ = io.Copy(io.Discard, res.Body)
|
||||
_ = res.Body.Close()
|
||||
}()
|
||||
bodyBytes, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
bodyString := string(bodyBytes)
|
||||
validResponse := !strings.Contains(bodyString, `"error"`)
|
||||
defer func() { _ = res.Body.Close() }()
|
||||
if res.StatusCode >= 200 && res.StatusCode < 300 && validResponse {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
client = defaultClient
|
||||
}
|
||||
|
||||
isVerified, verificationErr := verifySlackWebhook(ctx, client, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
}
|
||||
@@ -75,7 +75,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifySlackWebhook(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
// We don't want to actually send anything to webhooks we find. To verify them without spamming them, we
|
||||
// send an intentionally malformed message and look for a particular expected error message.
|
||||
payload := strings.NewReader(`intentionally malformed JSON from TruffleHog scan`)
|
||||
|
||||
@@ -48,7 +48,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyTefter(ctx, client, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
}
|
||||
@@ -59,7 +59,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyTefter(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, "POST", "https://www.tefter.io/api/bookmarks?url=google.com", nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@@ -70,13 +70,16 @@ func verifyTefter(ctx context.Context, client *http.Client, resMatch string) (bo
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
defer func() {
|
||||
_, _ = io.Copy(io.Discard, res.Body)
|
||||
_ = res.Body.Close()
|
||||
}()
|
||||
bodyBytes, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
validResponse := json.Valid(bodyBytes)
|
||||
|
||||
defer func() { _ = res.Body.Close() }()
|
||||
if res.StatusCode >= 200 && res.StatusCode < 300 && validResponse {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyTeletype(ctx, client, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
}
|
||||
@@ -58,7 +58,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyTeletype(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", "https://api.teletype.app/public/api/v1/messages", nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@@ -69,6 +69,10 @@ func verifyTeletype(ctx context.Context, client *http.Client, resMatch string) (
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
defer func() {
|
||||
_, _ = io.Copy(io.Discard, res.Body)
|
||||
_ = res.Body.Close()
|
||||
}()
|
||||
bodyBytes, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@@ -77,10 +81,8 @@ func verifyTeletype(ctx context.Context, client *http.Client, resMatch string) (
|
||||
bodyString := string(bodyBytes)
|
||||
validResponse := strings.Contains(bodyString, `"code":401`)
|
||||
|
||||
defer func() { _ = res.Body.Close() }()
|
||||
if res.StatusCode >= 200 && res.StatusCode < 300 {
|
||||
if validResponse {
|
||||
} else {
|
||||
if !validResponse {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyThinkific(ctx, client, resDomainMatch, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resDomainMatch, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resDomainMatch, resMatch)
|
||||
}
|
||||
@@ -64,7 +64,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyThinkific(ctx context.Context, client *http.Client, resDomainMatch string, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resDomainMatch string, resMatch string) (bool, error) {
|
||||
domainRes := fmt.Sprintf("%s-s-school", resDomainMatch)
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", "https://api.thinkific.com/api/public/v1/collections", nil)
|
||||
if err != nil {
|
||||
|
||||
@@ -47,7 +47,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyTwelveData(ctx, client, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
}
|
||||
@@ -58,7 +58,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyTwelveData(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", "https://api.twelvedata.com/earliest_timestamp?symbol=AAPL&interval=1day&apikey="+resMatch, nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
||||
@@ -47,7 +47,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyUnifyID(ctx, client, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
}
|
||||
@@ -58,7 +58,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyUnifyID(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
payload := strings.NewReader(`{"token": "sample"}`)
|
||||
req, err := http.NewRequestWithContext(ctx, "POST", "https://api.unify.id/v1/humandetect/verify", payload)
|
||||
if err != nil {
|
||||
|
||||
@@ -47,7 +47,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyUptimeRobot(ctx, client, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
}
|
||||
@@ -58,7 +58,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyUptimeRobot(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, "POST", "https://api.uptimerobot.com/v2/getMonitors?api_key="+resMatch, nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@@ -67,13 +67,16 @@ func verifyUptimeRobot(ctx context.Context, client *http.Client, resMatch string
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
defer func() {
|
||||
_, _ = io.Copy(io.Discard, res.Body)
|
||||
_ = res.Body.Close()
|
||||
}()
|
||||
bodyBytes, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
bodyString := string(bodyBytes)
|
||||
validResponse := strings.Contains(bodyString, `"ok"`)
|
||||
defer func() { _ = res.Body.Close() }()
|
||||
if res.StatusCode >= 200 && res.StatusCode < 300 {
|
||||
if validResponse {
|
||||
return true, nil
|
||||
|
||||
@@ -48,7 +48,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyWalkScore(ctx, client, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
}
|
||||
@@ -59,7 +59,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyWalkScore(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("https://transit.walkscore.com/transit/search/stops/?lat=47.6101359&lon=-122.3420567&wsapikey=%s", resMatch), nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
||||
@@ -48,7 +48,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyWeatherStack(ctx, client, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
}
|
||||
@@ -59,7 +59,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyWeatherStack(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("https://api.weatherstack.com/current?access_key=%s&query=LA", resMatch), nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
||||
@@ -47,7 +47,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyWebscraping(ctx, client, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
}
|
||||
@@ -58,7 +58,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyWebscraping(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", `https://api.webscrapingapi.com/v1?api_key=`+resMatch, nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
||||
@@ -53,7 +53,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
SecretParts: map[string]string{"key": resMatch},
|
||||
}
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyWebsitepulse(ctx, client, resIdMatch, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resIdMatch, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resIdMatch, resMatch)
|
||||
}
|
||||
@@ -66,7 +66,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyWebsitepulse(ctx context.Context, client *http.Client, resIdMatch string, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resIdMatch string, resMatch string) (bool, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("https://api.websitepulse.com/textserver.php?method=GetContacts&username=%s&key=%s", resIdMatch, resMatch), nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
||||
@@ -48,7 +48,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
}
|
||||
|
||||
if verify {
|
||||
isVerified, verificationErr := verifyWhoxy(ctx, client, resMatch)
|
||||
isVerified, verificationErr := verifyMatch(ctx, client, resMatch)
|
||||
s1.Verified = isVerified
|
||||
s1.SetVerificationError(verificationErr, resMatch)
|
||||
}
|
||||
@@ -59,7 +59,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func verifyWhoxy(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
func verifyMatch(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("https://api.whoxy.com/?key=%s&account=balance", resMatch), nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
||||
Reference in New Issue
Block a user