Skip to content

Commit

Permalink
fix(report): remove retry logic for wpscan.com (future-architect#1151)
Browse files Browse the repository at this point in the history
* fix(saas) change saas upload s3 key (future-architect#1116)

* fix(report): remove retry logic for wpscan.com

Co-authored-by: sadayuki-matsuno <[email protected]>
  • Loading branch information
kotakanbe and sadayuki-matsuno authored Jan 28, 2021
1 parent 3dbdd01 commit 644d5a5
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions wordpress/wordpress.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"io/ioutil"
"net/http"
"strings"
"time"

c "github.com/future-architect/vuls/config"
"github.com/future-architect/vuls/errof"
Expand Down Expand Up @@ -217,14 +216,11 @@ func extractToVulnInfos(pkgName string, cves []WpCveInfo) (vinfos []models.VulnI
}

func httpRequest(url, token string) (string, error) {
retry := 1
util.Log.Debugf("%s", url)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return "", err
}
req.Header.Set("Authorization", fmt.Sprintf("Token token=%s", token))
loop:
resp, err := new(http.Client).Do(req)
if err != nil {
return "", err
Expand All @@ -239,14 +235,12 @@ loop:
} else if resp.StatusCode == 404 {
// This package is not in wpscan
return "", nil
} else if resp.StatusCode == 429 && retry <= 3 {
// 429 Too Many Requests
util.Log.Debugf("sleep %d min(s): %s", retry, resp.Status)
time.Sleep(time.Duration(retry) * time.Minute)
retry++
goto loop
} else if resp.StatusCode == 429 {
return "", xerrors.Errorf("wpscan.com API limit exceeded: %+v", resp.Status)
} else {
util.Log.Warnf("wpscan.com unknown status code: %+v", resp.Status)
return "", nil
}
return "", err
}

func removeInactives(pkgs models.WordPressPackages) (removed models.WordPressPackages) {
Expand Down

0 comments on commit 644d5a5

Please sign in to comment.