diff --git a/errof/errof.go b/errof/errof.go index afe066b6..7d5bf2dc 100644 --- a/errof/errof.go +++ b/errof/errof.go @@ -16,6 +16,9 @@ func (e Error) Error() string { var ( // ErrFailedToAccessGithubAPI is error of github alert's api access ErrFailedToAccessGithubAPI ErrorCode = "ErrFailedToAccessGithubAPI" + + // ErrFailedToAccessWpScan is error of wpscan.com api access + ErrFailedToAccessWpScan ErrorCode = "ErrFailedToAccessWpScan" ) // New : diff --git a/github/github.go b/github/github.go index 3a03f60b..1eb24e64 100644 --- a/github/github.go +++ b/github/github.go @@ -65,10 +65,8 @@ func FillGitHubSecurityAlerts(r *models.ScanResult, owner, repo, token string) ( // util.Log.Debugf("%s", pp.Sprint(alerts)) // util.Log.Debugf("%s", string(body)) if alerts.Data.Repository.URL == "" { - return 0, errof.New( - errof.ErrFailedToAccessGithubAPI, - fmt.Sprintf("Failed to access to GitHub API. Response: %s", string(body)), - ) + return 0, errof.New(errof.ErrFailedToAccessGithubAPI, + fmt.Sprintf("Failed to access to GitHub API. Response: %s", string(body))) } for _, v := range alerts.Data.Repository.VulnerabilityAlerts.Edges { diff --git a/models/scanresults.go b/models/scanresults.go index ea0b8ef5..45beaed6 100644 --- a/models/scanresults.go +++ b/models/scanresults.go @@ -49,7 +49,7 @@ type ScanResult struct { Packages Packages `json:"packages"` SrcPackages SrcPackages `json:",omitempty"` EnabledDnfModules []string `json:"enabledDnfModules,omitempty"` // for dnf modules - WordPressPackages *WordPressPackages `json:",omitempty"` + WordPressPackages WordPressPackages `json:",omitempty"` LibraryScanners LibraryScanners `json:"libraries,omitempty"` CweDict CweDict `json:"cweDict,omitempty"` Optional map[string]interface{} `json:",omitempty"` diff --git a/scan/base.go b/scan/base.go index 42b080d1..e938f3f6 100644 --- a/scan/base.go +++ b/scan/base.go @@ -35,7 +35,7 @@ type base struct { Platform models.Platform osPackages LibraryScanners []models.LibraryScanner - WordPress *models.WordPressPackages + WordPress models.WordPressPackages log *logrus.Entry errs []error @@ -656,7 +656,7 @@ func (l *base) scanWordPress() (err error) { if err != nil { return xerrors.Errorf("Failed to scan wordpress: %w", err) } - l.WordPress = wp + l.WordPress = *wp return nil } diff --git a/wordpress/wordpress.go b/wordpress/wordpress.go index e139fb1d..c95b6073 100644 --- a/wordpress/wordpress.go +++ b/wordpress/wordpress.go @@ -9,6 +9,7 @@ import ( "time" c "github.com/future-architect/vuls/config" + "github.com/future-architect/vuls/errof" "github.com/future-architect/vuls/models" "github.com/future-architect/vuls/util" version "github.com/hashicorp/go-version" @@ -107,7 +108,8 @@ func FillWordPress(r *models.ScanResult, token string) (int, error) { func wpscan(url, name, token string) (vinfos []models.VulnInfo, err error) { body, err := httpRequest(url, token) if err != nil { - return nil, err + return nil, errof.New(errof.ErrFailedToAccessWpScan, + fmt.Sprintf("Failed to access to wpscan.comm. body: %s, err: %s", string(body), err)) } if body == "" { util.Log.Debugf("wpscan.com response body is empty. URL: %s", url)