Skip to content

Commit

Permalink
Merge branch 'master' of github.com:future-architect/vuls
Browse files Browse the repository at this point in the history
  • Loading branch information
kotakanbe committed Jan 28, 2021
2 parents 8e18451 + 644d5a5 commit 39b1944
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 39b1944

Please sign in to comment.