fix(wordpress): enable to detect vulns of WordPress Core (#1193)

This commit is contained in:
Kota Kanbe
2021-03-09 10:40:52 +09:00
committed by GitHub
parent 2d075079f1
commit 54e73c2f54
7 changed files with 464 additions and 532 deletions

View File

@@ -134,9 +134,8 @@ func Detect(dbclient DBClient, rs []models.ScanResult, dir string) ([]models.Sca
}
for i, r := range rs {
r = r.FilterByCvssOver(c.Conf.CvssScoreOver)
r = r.FilterUnfixed(c.Conf.IgnoreUnfixed)
r = r.FilterInactiveWordPressLibs(c.Conf.WpScan.DetectInactive)
r.ScannedCves = r.ScannedCves.FilterByCvssOver(c.Conf.CvssScoreOver)
r.ScannedCves = r.ScannedCves.FilterUnfixed(c.Conf.IgnoreUnfixed)
// IgnoreCves
ignoreCves := []string{}
@@ -145,7 +144,7 @@ func Detect(dbclient DBClient, rs []models.ScanResult, dir string) ([]models.Sca
} else if con, ok := c.Conf.Servers[r.ServerName].Containers[r.Container.Name]; ok {
ignoreCves = con.IgnoreCves
}
r = r.FilterIgnoreCves(ignoreCves)
r.ScannedCves = r.ScannedCves.FilterIgnoreCves(ignoreCves)
// ignorePkgs
ignorePkgsRegexps := []string{}
@@ -154,13 +153,14 @@ func Detect(dbclient DBClient, rs []models.ScanResult, dir string) ([]models.Sca
} else if s, ok := c.Conf.Servers[r.ServerName].Containers[r.Container.Name]; ok {
ignorePkgsRegexps = s.IgnorePkgsRegexp
}
r = r.FilterIgnorePkgs(ignorePkgsRegexps)
r.ScannedCves = r.ScannedCves.FilterIgnorePkgs(ignorePkgsRegexps)
// IgnoreUnscored
if c.Conf.IgnoreUnscoredCves {
r.ScannedCves = r.ScannedCves.FindScoredVulns()
}
r.FilterInactiveWordPressLibs(c.Conf.WpScan.DetectInactive)
rs[i] = r
}
return rs, nil

View File

@@ -61,7 +61,7 @@ func detectWordPressCves(r *models.ScanResult, cnf *c.WpScanConf) (int, error) {
fmt.Sprintf("Failed to get WordPress core version."))
}
url := fmt.Sprintf("https://wpscan.com/api/v3/wordpresses/%s", ver)
wpVinfos, err := wpscan(url, ver, cnf.Token)
wpVinfos, err := wpscan(url, ver, cnf.Token, true)
if err != nil {
return 0, err
}
@@ -73,7 +73,7 @@ func detectWordPressCves(r *models.ScanResult, cnf *c.WpScanConf) (int, error) {
}
for _, p := range themes {
url := fmt.Sprintf("https://wpscan.com/api/v3/themes/%s", p.Name)
candidates, err := wpscan(url, p.Name, cnf.Token)
candidates, err := wpscan(url, p.Name, cnf.Token, false)
if err != nil {
return 0, err
}
@@ -88,7 +88,7 @@ func detectWordPressCves(r *models.ScanResult, cnf *c.WpScanConf) (int, error) {
}
for _, p := range plugins {
url := fmt.Sprintf("https://wpscan.com/api/v3/plugins/%s", p.Name)
candidates, err := wpscan(url, p.Name, cnf.Token)
candidates, err := wpscan(url, p.Name, cnf.Token, false)
if err != nil {
return 0, err
}
@@ -110,7 +110,7 @@ func detectWordPressCves(r *models.ScanResult, cnf *c.WpScanConf) (int, error) {
return len(wpVinfos), nil
}
func wpscan(url, name, token string) (vinfos []models.VulnInfo, err error) {
func wpscan(url, name, token string, isCore bool) (vinfos []models.VulnInfo, err error) {
body, err := httpRequest(url, token)
if err != nil {
return nil, err
@@ -118,6 +118,9 @@ func wpscan(url, name, token string) (vinfos []models.VulnInfo, err error) {
if body == "" {
logging.Log.Debugf("wpscan.com response body is empty. URL: %s", url)
}
if isCore {
name = "core"
}
return convertToVinfos(name, body)
}