Skip to content
This repository has been archived by the owner on Dec 1, 2024. It is now read-only.

Commit

Permalink
[nvdtools] Fix golint findings and enable the golint pass (#149)
Browse files Browse the repository at this point in the history
* [nvdtools] Fix golint using golangci-lint and enable the golint pass

* [nvdtools] Adding golint pass to CI
  • Loading branch information
sadhvi25 authored Jun 17, 2020
1 parent 2b32a4e commit 2dc8079
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ env:

script:
- go get -v -t -u -d ./...
- 'golangci-lint run ./... --disable-all -E gosimple -E govet -E ineffassign -E staticcheck -E structcheck -E varcheck -e SA5011:'
- 'golangci-lint run ./... --disable-all -E golint -E gosimple -E govet -E ineffassign -E staticcheck -E structcheck -E varcheck -e SA5011:'
- go test -v ./...

before_deploy:
Expand Down
8 changes: 4 additions & 4 deletions providers/idefense/api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
// Client struct
type Client struct {
client.Client
baseUrl string
baseURL string
apiKey string
}

Expand All @@ -43,10 +43,10 @@ const (
)

// NewClient creates an object which is used to query the iDefense API
func NewClient(c client.Client, baseUrl, apiKey string) *Client {
func NewClient(c client.Client, baseURL, apiKey string) *Client {
return &Client{
Client: c,
baseUrl: baseUrl,
baseURL: baseURL,
apiKey: apiKey,
}
}
Expand Down Expand Up @@ -107,7 +107,7 @@ func (c *Client) FetchAllVulnerabilities(ctx context.Context, since int64) (<-ch
}

func (c *Client) queryVulnerabilities(ctx context.Context, params map[string]interface{}) (*schema.VulnerabilitySearchResults, error) {
u, err := url.Parse(c.baseUrl + vulnerabilityEndpoint)
u, err := url.Parse(c.baseURL + vulnerabilityEndpoint)
if err != nil {
return nil, errors.Wrap(err, "failed to parse url")
}
Expand Down
17 changes: 9 additions & 8 deletions providers/redhat/check/check_cve.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,26 @@ import (
"github.com/facebookincubator/nvdtools/wfn"
)

var NoCheckers = errors.New("no applicable checkers")
var ErrCheckers = errors.New("no applicable checkers")

func CVEChecker(cve *schema.CVE) (rpm.Checker, error) {
var chks []rpm.Checker

if archks, err := affectedReleaseCheckers(cve); err != nil {
archks, err := affectedReleaseCheckers(cve)
if err != nil {
return nil, fmt.Errorf("can't construct checkers for affected release: %v", err)
} else {
chks = archks
}
chks = archks

if pschks, err := packageStateCheckers(cve); err != nil {
pschks, err := packageStateCheckers(cve)
if err != nil {
return nil, fmt.Errorf("can't construct checkers for package state: %v", err)
} else {
chks = append(chks, pschks...)
}
chks = append(chks, pschks...)


if len(chks) == 0 {
return nil, NoCheckers
return nil, ErrCheckers
}

return &cveChecker{cve.Name, chks}, nil
Expand Down
2 changes: 1 addition & 1 deletion providers/redhat/feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (feed *Feed) Checker() (rpm.Checker, error) {
var err error
for cveid, cve := range feed.data {
if mc[cveid], err = check.CVEChecker(cve); err != nil {
if err == check.NoCheckers {
if err == check.ErrCheckers {
// no checkers could be created, just skip it
delete(mc, cveid)
continue
Expand Down
3 changes: 1 addition & 2 deletions rpm/compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,8 @@ func versionCompare(v1, v2 string) int {
if len(v2Seg) == 0 {
if isNumeric {
return 1
} else {
return -1
}
return -1
}

// here we know that they both start with either numbers or letters
Expand Down

0 comments on commit 2dc8079

Please sign in to comment.