diff --git a/.github/workflows/golangci.yml b/.github/workflows/golangci.yml index cc0eca90..9b3bd56b 100644 --- a/.github/workflows/golangci.yml +++ b/.github/workflows/golangci.yml @@ -16,7 +16,7 @@ jobs: uses: golangci/golangci-lint-action@v2 with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. - version: v1.32 + version: v1.42 args: --timeout=10m # Optional: working directory, useful for monorepos diff --git a/.golangci.yml b/.golangci.yml index a93842cb..9244a424 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,14 +1,44 @@ name: golang-ci linters-settings: - errcheck: + revive: + # see https://github.com/mgechev/revive#available-rules for details. + ignore-generated-header: true + severity: warning + confidence: 0.8 + rules: + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: dot-imports + - name: error-return + - name: error-strings + - name: error-naming + - name: exported + - name: if-return + - name: increment-decrement + - name: var-naming + - name: var-declaration + - name: package-comments + - name: range + - name: receiver-naming + - name: time-naming + - name: unexported-return + - name: indent-error-flow + - name: errorf + - name: empty-block + - name: superfluous-else + - name: unused-parameter + - name: unreachable-code + - name: redefines-builtin-id + # errcheck: #exclude: /path/to/file.txt linters: disable-all: true enable: - goimports - - golint + - revive - govet - misspell - errcheck diff --git a/.revive.toml b/.revive.toml new file mode 100644 index 00000000..208d23c8 --- /dev/null +++ b/.revive.toml @@ -0,0 +1,30 @@ +ignoreGeneratedHeader = false +severity = "warning" +confidence = 0.8 +errorCode = 0 +warningCode = 0 + +[rule.blank-imports] +[rule.context-as-argument] +[rule.context-keys-type] +[rule.dot-imports] +[rule.error-return] +[rule.error-strings] +[rule.error-naming] +[rule.exported] +[rule.if-return] +[rule.increment-decrement] +[rule.var-naming] +[rule.var-declaration] +[rule.package-comments] +[rule.range] +[rule.receiver-naming] +[rule.time-naming] +[rule.unexported-return] +[rule.indent-error-flow] +[rule.errorf] +[rule.empty-block] +[rule.superfluous-else] +[rule.unused-parameter] +[rule.unreachable-code] +[rule.redefines-builtin-id] \ No newline at end of file diff --git a/GNUmakefile b/GNUmakefile index 01ea9b2f..f23d1c15 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -42,8 +42,8 @@ install-scanner: ./cmd/scanner/main.go $(CGO_UNABLED) install -tags=scanner -ldflags "$(LDFLAGS)" ./cmd/scanner lint: - $(GO_OFF) get -u golang.org/x/lint/golint - golint $(PKGS) + $(GO_OFF) get -u github.com/mgechev/revive + revive -config ./.revive.toml -formatter plain $(PKGS) vet: echo $(PKGS) | xargs env $(GO) vet || exit; diff --git a/config/jsonloader.go b/config/jsonloader.go index 6285a3ce..e53f6b70 100644 --- a/config/jsonloader.go +++ b/config/jsonloader.go @@ -7,6 +7,6 @@ type JSONLoader struct { } // Load load the configuration JSON file specified by path arg. -func (c JSONLoader) Load(path, sudoPass, keyPass string) (err error) { +func (c JSONLoader) Load(_, _, _ string) (err error) { return xerrors.New("Not implement yet") } diff --git a/config/scanmode.go b/config/scanmode.go index 2e5a5a35..86d2efbe 100644 --- a/config/scanmode.go +++ b/config/scanmode.go @@ -84,7 +84,7 @@ func (s ScanMode) String() string { return ss + " mode" } -func setScanMode(server *ServerInfo, d ServerInfo) error { +func setScanMode(server *ServerInfo) error { if len(server.ScanMode) == 0 { server.ScanMode = Conf.Default.ScanMode } diff --git a/config/tomlloader.go b/config/tomlloader.go index ff8b3a43..d3ac85cc 100644 --- a/config/tomlloader.go +++ b/config/tomlloader.go @@ -15,7 +15,7 @@ type TOMLLoader struct { } // Load load the configuration TOML file specified by path arg. -func (c TOMLLoader) Load(pathToToml, keyPass string) error { +func (c TOMLLoader) Load(pathToToml, _ string) error { // util.Log.Infof("Loading config: %s", pathToToml) if _, err := toml.DecodeFile(pathToToml, &Conf); err != nil { return err @@ -34,11 +34,11 @@ func (c TOMLLoader) Load(pathToToml, keyPass string) error { index := 0 for name, server := range Conf.Servers { server.ServerName = name - if err := setDefaultIfEmpty(&server, Conf.Default); err != nil { + if err := setDefaultIfEmpty(&server); err != nil { return xerrors.Errorf("Failed to set default value to config. server: %s, err: %w", name, err) } - if err := setScanMode(&server, Conf.Default); err != nil { + if err := setScanMode(&server); err != nil { return xerrors.Errorf("Failed to set ScanMode: %w", err) } @@ -137,7 +137,7 @@ func (c TOMLLoader) Load(pathToToml, keyPass string) error { return nil } -func setDefaultIfEmpty(server *ServerInfo, d ServerInfo) error { +func setDefaultIfEmpty(server *ServerInfo) error { if server.Type != constant.ServerTypePseudo { if len(server.Host) == 0 { return xerrors.Errorf("server.host is empty") diff --git a/detector/cve_client.go b/detector/cve_client.go index 6d617e39..5be55469 100644 --- a/detector/cve_client.go +++ b/detector/cve_client.go @@ -156,7 +156,7 @@ func (api goCveDictClient) detectCveByCpeURI(cpeURI string, useJVN bool) (cves [ query := map[string]string{"name": cpeURI} logging.Log.Debugf("HTTP Request to %s, query: %#v", url, query) - if cves, err = api.httpPost(cpeURI, url, query); err != nil { + if cves, err = api.httpPost(url, query); err != nil { return nil, err } } else { @@ -180,7 +180,7 @@ func (api goCveDictClient) detectCveByCpeURI(cpeURI string, useJVN bool) (cves [ return nvdCves, nil } -func (api goCveDictClient) httpPost(key, url string, query map[string]string) ([]cvemodels.CveDetail, error) { +func (api goCveDictClient) httpPost(url string, query map[string]string) ([]cvemodels.CveDetail, error) { var body string var errs []error var resp *http.Response diff --git a/detector/util.go b/detector/util.go index 5a8a54eb..845a808a 100644 --- a/detector/util.go +++ b/detector/util.go @@ -68,10 +68,9 @@ func loadPrevious(currs models.ScanResults, resultsDir string) (prevs models.Sca prevs = append(prevs, *r) logging.Log.Infof("Previous json found: %s", path) break - } else { - logging.Log.Infof("Previous json is different family.Release: %s, pre: %s.%s cur: %s.%s", - path, r.Family, r.Release, result.Family, result.Release) } + logging.Log.Infof("Previous json is different family.Release: %s, pre: %s.%s cur: %s.%s", + path, r.Family, r.Release, result.Family, result.Release) } } return prevs, nil diff --git a/go.mod b/go.mod index cd2a1cae..ced15d96 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.17 require ( github.com/Azure/azure-sdk-for-go v50.2.0+incompatible - github.com/BurntSushi/toml v0.3.1 + github.com/BurntSushi/toml v0.4.1 github.com/Ullaakut/nmap/v2 v2.1.2-0.20210406060955-59a52fe80a4f github.com/VividCortex/ewma v1.2.0 // indirect github.com/aquasecurity/fanal v0.0.0-20210815095355-42429a80d0e3 @@ -51,18 +51,18 @@ require ( github.com/spf13/afero v1.6.0 github.com/spf13/cast v1.4.1 // indirect github.com/spf13/cobra v1.2.1 - github.com/vulsio/go-cve-dictionary v0.8.1-0.20210916000615-947df305878a - github.com/vulsio/go-exploitdb v0.2.0 + github.com/vulsio/go-cve-dictionary v0.8.1 + github.com/vulsio/go-exploitdb v0.4.0 github.com/vulsio/go-msfdb v0.2.0 - github.com/vulsio/gost v0.3.0 - github.com/vulsio/goval-dictionary v0.6.0 + github.com/vulsio/gost v0.4.1-0.20210919121048-2a7957bf1885 + github.com/vulsio/goval-dictionary v0.6.1 golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect golang.org/x/net v0.0.0-20210902165921-8d991716f632 // indirect golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c golang.org/x/sync v0.0.0-20210220032951-036812b2e83c golang.org/x/text v0.3.7 // indirect golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 - gopkg.in/ini.v1 v1.63.0 // indirect + gopkg.in/ini.v1 v1.63.2 // indirect gorm.io/driver/mysql v1.1.2 // indirect gorm.io/driver/postgres v1.1.1 // indirect gorm.io/driver/sqlite v1.1.5 // indirect @@ -79,7 +79,7 @@ require ( github.com/Masterminds/goutils v1.1.1 // indirect github.com/Masterminds/semver v1.5.0 // indirect github.com/Masterminds/sprig v2.22.0+incompatible // indirect - github.com/PuerkitoBio/goquery v1.6.1 // indirect + github.com/PuerkitoBio/goquery v1.7.1 // indirect github.com/andybalholm/cascadia v1.2.0 // indirect github.com/aquasecurity/go-dep-parser v0.0.0-20210815080135-5be65146849a // indirect github.com/aquasecurity/go-gem-version v0.0.0-20201115065557-8eed6fe000ce // indirect @@ -119,7 +119,6 @@ require ( github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.2 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect - github.com/labstack/gommon v0.3.0 // indirect github.com/magiconair/properties v1.8.5 // indirect github.com/masahiro331/go-mvn-version v0.0.0-20210429150710-d3157d602a08 // indirect github.com/mattn/go-colorable v0.1.8 // indirect @@ -137,8 +136,6 @@ require ( github.com/stretchr/objx v0.3.0 // indirect github.com/stretchr/testify v1.7.0 // indirect github.com/subosito/gotenv v1.2.0 // indirect - github.com/valyala/bytebufferpool v1.0.0 // indirect - github.com/valyala/fasttemplate v1.2.1 // indirect github.com/ymomoi/goval-parser v0.0.0-20170813122243-0a0be1dd9d08 // indirect go.etcd.io/bbolt v1.3.6 // indirect go.uber.org/atomic v1.7.0 // indirect diff --git a/go.sum b/go.sum index 7f04bef1..6b5b2e3e 100644 --- a/go.sum +++ b/go.sum @@ -113,8 +113,9 @@ github.com/Azure/go-autorest/logger v0.2.0/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZ github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= github.com/Azure/go-autorest/tracing v0.6.0 h1:TYi4+3m5t6K48TGI9AUdb+IzbnSxvnvUMfuitfgcfuo= github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU= -github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/toml v0.4.1 h1:GaI7EiDXDRfa8VshkTj7Fym7ha+y8/XxIgD2okUIjLw= +github.com/BurntSushi/toml v0.4.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/Djarvur/go-err113 v0.0.0-20200410182137-af658d038157/go.mod h1:4UJr5HIiMZrwgkSPdsjy2uOQExX/WEILpIrO9UPGuXs= github.com/Djarvur/go-err113 v0.1.0/go.mod h1:4UJr5HIiMZrwgkSPdsjy2uOQExX/WEILpIrO9UPGuXs= @@ -159,8 +160,9 @@ github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAE github.com/OneOfOne/xxhash v1.2.8/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q= github.com/OpenPeeDeeP/depguard v1.0.1/go.mod h1:xsIw86fROiiwelg+jB2uM9PiKihMMmUx/1V+TNhjQvM= github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo= -github.com/PuerkitoBio/goquery v1.6.1 h1:FgjbQZKl5HTmcn4sKBgvx8vv63nhyhIpv7lJpFGCWpk= github.com/PuerkitoBio/goquery v1.6.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= +github.com/PuerkitoBio/goquery v1.7.1 h1:oE+T06D+1T7LNrn91B4aERsRIeCLJ/oPSa6xB9FPnz4= +github.com/PuerkitoBio/goquery v1.7.1/go.mod h1:XY0pP4kfraEmmV1O7Uf6XyjoslwsneBbgeDjLYuN8xY= github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= @@ -1068,7 +1070,6 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0 github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/labstack/echo v3.3.10+incompatible/go.mod h1:0INS7j/VjnFxD4E2wkz67b8cVwCLbBmJyDaka6Cmk1s= github.com/labstack/echo/v4 v4.1.17/go.mod h1:Tn2yRQL/UclUalpb5rPdXDevbkJ+lp/2svdyFBg6CHQ= -github.com/labstack/gommon v0.3.0 h1:JEeO0bvc78PKdyHxloTKiF8BD5iGrH8T6MSeGvSgob0= github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/liamg/clinch v1.5.6/go.mod h1:IXM+nLBuZ5sOQAYYf9+G51nkaA0WY9cszxE5nPXexhE= @@ -1544,12 +1545,10 @@ github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtX github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= github.com/uudashr/gocognit v1.0.1/go.mod h1:j44Ayx2KW4+oB6SWMv8KsmHzZrOInQav7D3cQMJ5JUM= -github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasthttp v1.2.0/go.mod h1:4vX61m6KN+xDduDNwXrhIAVZaZaZiQ1luJk8LWSxF3s= github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/valyala/fasttemplate v1.1.0/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= -github.com/valyala/fasttemplate v1.2.1 h1:TVEnxayobAdVkhQfrfes2IzOB6o+z4roRkPF52WA1u4= github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= github.com/valyala/quicktemplate v1.2.0/go.mod h1:EH+4AkTd43SvgIbQHYu59/cJyxDoOVRUAfrukLPuGJ4= github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio= @@ -1564,16 +1563,16 @@ github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6Ac github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= github.com/vmware/govmomi v0.20.3/go.mod h1:URlwyTFZX72RmxtxuaFL2Uj3fD1JTvZdx59bHWk6aFU= -github.com/vulsio/go-cve-dictionary v0.8.1-0.20210916000615-947df305878a h1:IGhdylaTYl0Xhn11gfLpX86TqZ91JofFbvEV1+sbKNA= -github.com/vulsio/go-cve-dictionary v0.8.1-0.20210916000615-947df305878a/go.mod h1:PdkEViYpf0sx4H0YF7Sk/Xo+j8Agof4aOVoQxzL+TQA= -github.com/vulsio/go-exploitdb v0.2.0 h1:+PdCXcMiJo8ewMCkqikuJsgkPQeYUdvyBYrAnlNDXec= -github.com/vulsio/go-exploitdb v0.2.0/go.mod h1:Vx0zR1HMR3wyhiYctNuADxBVPxMcfCNZpmP72d26hZU= +github.com/vulsio/go-cve-dictionary v0.8.1 h1:vpxOq7OAFVqEGfxcRZ5tRKfCd8Wuioj6yNosJ0Nx8d4= +github.com/vulsio/go-cve-dictionary v0.8.1/go.mod h1:PdkEViYpf0sx4H0YF7Sk/Xo+j8Agof4aOVoQxzL+TQA= +github.com/vulsio/go-exploitdb v0.4.0 h1:itUM3pI3FUUs20+gmwtcZsrVy0zG81yN42aHJmwAlrw= +github.com/vulsio/go-exploitdb v0.4.0/go.mod h1:C1X/lRIvDDBWDeW19Msw7asZ4q0pFjmFx/kXGns2raA= github.com/vulsio/go-msfdb v0.2.0 h1:VY0vnQEgYB4eRwvK8yio1Tz5Yn5l7GJSh3mnUJEPceM= github.com/vulsio/go-msfdb v0.2.0/go.mod h1:QsHhtjF4hAheLgeGJQRv/ccmE3txtOSgwzTgziyStKY= -github.com/vulsio/gost v0.3.0 h1:oRgIAi3SR9AFZS12vuaqx0TXFhTxSyp6MQX8XV41a6w= -github.com/vulsio/gost v0.3.0/go.mod h1:bCyU8JTDE+C2pRRM1PArrFdbd2dELH9S+NKKio9jvac= -github.com/vulsio/goval-dictionary v0.6.0 h1:P+4Bni+quaeHc19ESD3MJQOHFVYvraNris8AYOA2oC8= -github.com/vulsio/goval-dictionary v0.6.0/go.mod h1:RU1jWunEAwnErgIbM5Hc2j4OnTHQEvMagBq6/6wfWPU= +github.com/vulsio/gost v0.4.1-0.20210919121048-2a7957bf1885 h1:J9ISMRl26ayPzoYWHMiX4ORHWzLwanl5aWUDNcXu264= +github.com/vulsio/gost v0.4.1-0.20210919121048-2a7957bf1885/go.mod h1:49trASwbe0ZhntJhEc1rv3MDGUpIhIkZktELgZ8a5YA= +github.com/vulsio/goval-dictionary v0.6.1 h1:w2AXwgPWD5/IrJ+44ywD0u5I9ILNdHvzlR+n6iu0eAQ= +github.com/vulsio/goval-dictionary v0.6.1/go.mod h1:RU1jWunEAwnErgIbM5Hc2j4OnTHQEvMagBq6/6wfWPU= github.com/willf/bitset v1.1.11-0.20200630133818-d5bec3311243/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4= github.com/willf/bitset v1.1.11/go.mod h1:83CECat5yLh5zVOf4P1ErAgKA5UDvKtgyUABdr3+MjI= github.com/xanzy/go-gitlab v0.31.0/go.mod h1:sPLojNBn68fMUWSxIJtdVVIP8uSBYqesTfDUseX11Ug= @@ -2246,8 +2245,8 @@ gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.56.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.63.0 h1:2t0h8NA59dpVQpa5Yh8cIcR6nHAeBIEk0zlLVqfw4N4= -gopkg.in/ini.v1 v1.63.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/ini.v1 v1.63.2 h1:tGK/CyBg7SMzb60vP1M03vNZ3VDu3wGQJwn7Sxi9r3c= +gopkg.in/ini.v1 v1.63.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= diff --git a/gost/pseudo.go b/gost/pseudo.go index d6b7b241..880705cb 100644 --- a/gost/pseudo.go +++ b/gost/pseudo.go @@ -13,6 +13,6 @@ type Pseudo struct { } // DetectCVEs fills cve information that has in Gost -func (pse Pseudo) DetectCVEs(r *models.ScanResult, _ bool) (int, error) { +func (pse Pseudo) DetectCVEs(_ *models.ScanResult, _ bool) (int, error) { return 0, nil } diff --git a/models/vulninfos.go b/models/vulninfos.go index a7be1e6a..a54bda70 100644 --- a/models/vulninfos.go +++ b/models/vulninfos.go @@ -87,9 +87,8 @@ func (v VulnInfos) FilterIgnorePkgs(ignorePkgsRegexps []string) VulnInfos { if err != nil { logging.Log.Warnf("Failed to parse %s. err: %+v", pkgRegexp, err) continue - } else { - regexps = append(regexps, re) } + regexps = append(regexps, re) } if len(regexps) == 0 { return v diff --git a/saas/uuid.go b/saas/uuid.go index 231136a4..672fdd2e 100644 --- a/saas/uuid.go +++ b/saas/uuid.go @@ -19,7 +19,7 @@ import ( // EnsureUUIDs generate a new UUID of the scan target server if UUID is not assigned yet. // And then set the generated UUID to config.toml and scan results. func EnsureUUIDs(servers map[string]config.ServerInfo, path string, scanResults models.ScanResults) (err error) { - needsOverwrite, err := ensure(servers, path, scanResults, uuid.GenerateUUID) + needsOverwrite, err := ensure(servers, scanResults, uuid.GenerateUUID) if err != nil { return xerrors.Errorf("Failed to ensure UUIDs. err: %w", err) } @@ -30,7 +30,7 @@ func EnsureUUIDs(servers map[string]config.ServerInfo, path string, scanResults return writeToFile(config.Conf, path) } -func ensure(servers map[string]config.ServerInfo, path string, scanResults models.ScanResults, generateFunc func() (string, error)) (needsOverwrite bool, err error) { +func ensure(servers map[string]config.ServerInfo, scanResults models.ScanResults, generateFunc func() (string, error)) (needsOverwrite bool, err error) { for i, r := range scanResults { serverInfo := servers[r.ServerName] if serverInfo.UUIDs == nil { diff --git a/saas/uuid_test.go b/saas/uuid_test.go index 04eb9420..4ac046b9 100644 --- a/saas/uuid_test.go +++ b/saas/uuid_test.go @@ -377,7 +377,7 @@ func Test_ensure(t *testing.T) { } for i, tt := range tests { t.Run(tt.name, func(t *testing.T) { - gotNeedsOverwrite, err := ensure(tt.args.servers, tt.args.path, tt.args.scanResults, tt.args.generateFunc) + gotNeedsOverwrite, err := ensure(tt.args.servers, tt.args.scanResults, tt.args.generateFunc) if (err != nil) != tt.wantErr { t.Errorf("ensure() error = %v, wantErr %v", err, tt.wantErr) return diff --git a/subcmds/discover.go b/subcmds/discover.go index 73503598..7138024b 100644 --- a/subcmds/discover.go +++ b/subcmds/discover.go @@ -34,7 +34,7 @@ func (*DiscoverCmd) Usage() string { } // SetFlags set flag -func (p *DiscoverCmd) SetFlags(f *flag.FlagSet) { +func (p *DiscoverCmd) SetFlags(_ *flag.FlagSet) { } // Execute execute diff --git a/subcmds/history.go b/subcmds/history.go index 7f7a0cd7..4e367e71 100644 --- a/subcmds/history.go +++ b/subcmds/history.go @@ -43,7 +43,7 @@ func (p *HistoryCmd) SetFlags(f *flag.FlagSet) { } // Execute execute -func (p *HistoryCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus { +func (p *HistoryCmd) Execute(_ context.Context, _ *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus { dirs, err := reporter.ListValidJSONDirs(config.Conf.ResultsDir) if err != nil { return subcommands.ExitFailure diff --git a/subcmds/server.go b/subcmds/server.go index 1e0be649..f5048a32 100644 --- a/subcmds/server.go +++ b/subcmds/server.go @@ -90,7 +90,7 @@ func (p *ServerCmd) SetFlags(f *flag.FlagSet) { } // Execute execute -func (p *ServerCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus { +func (p *ServerCmd) Execute(_ context.Context, _ *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus { logging.Log = logging.NewCustomLogger(config.Conf.Debug, config.Conf.Quiet, config.Conf.LogToFile, config.Conf.LogDir, "", "") logging.Log.Infof("vuls-%s-%s", config.Version, config.Revision) if err := config.Load(p.configPath, ""); err != nil { diff --git a/tui/tui.go b/tui/tui.go index 24a70104..a59be136 100644 --- a/tui/tui.go +++ b/tui/tui.go @@ -301,10 +301,7 @@ func cursorMoveMiddle(g *gocui.Gui, v *gocui.View) error { return err } } - if err := onMovingCursorRedrawView(g, v); err != nil { - return err - } - return nil + return onMovingCursorRedrawView(g, v) } func cursorPageDown(g *gocui.Gui, v *gocui.View) error { @@ -505,7 +502,7 @@ func showMsg(g *gocui.Gui, v *gocui.View) error { return nil } -func delMsg(g *gocui.Gui, v *gocui.View) error { +func delMsg(g *gocui.Gui, _ *gocui.View) error { if err := g.DeleteView("msg"); err != nil { return err } @@ -513,7 +510,7 @@ func delMsg(g *gocui.Gui, v *gocui.View) error { return err } -func quit(g *gocui.Gui, v *gocui.View) error { +func quit(_ *gocui.Gui, _ *gocui.View) error { return gocui.ErrQuit }