Skip to content

Commit 17f4785

Browse files
authored
Update dependencies, Go version and address CVEs (#1474)
* Update dependencies, Go version and address CVEs Signed-off-by: Anton Troshin <[email protected]> * update golangci-lint version and list of disabled linters form dapr/dapr Signed-off-by: Anton Troshin <[email protected]> * adjust golangci-lint settings and fix lint issues Signed-off-by: Anton Troshin <[email protected]> * fix test Signed-off-by: Anton Troshin <[email protected]> --------- Signed-off-by: Anton Troshin <[email protected]>
1 parent efe1d6c commit 17f4785

37 files changed

+609
-1458
lines changed

.github/workflows/dapr_cli.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
name: Build ${{ matrix.target_os }}_${{ matrix.target_arch }} binaries
3030
runs-on: ${{ matrix.os }}
3131
env:
32-
GOLANG_CI_LINT_VER: v1.55.2
32+
GOLANG_CI_LINT_VER: v1.61.0
3333
GOOS: ${{ matrix.target_os }}
3434
GOARCH: ${{ matrix.target_arch }}
3535
GOPROXY: https://proxy.golang.org

.golangci.yml

+49-42
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ run:
44
concurrency: 4
55

66
# timeout for analysis, e.g. 30s, 5m, default is 1m
7-
deadline: 10m
7+
timeout: 10m
88

99
# exit code when at least one issue was found, default is 1
1010
issues-exit-code: 1
@@ -16,28 +16,22 @@ run:
1616
#build-tags:
1717
# - mytag
1818

19+
issues:
1920
# which dirs to skip: they won't be analyzed;
2021
# can use regexp here: generated.*, regexp is applied on full path;
2122
# default value is empty list, but next dirs are always skipped independently
2223
# from this option's value:
2324
# third_party$, testdata$, examples$, Godeps$, builtin$
24-
skip-dirs:
25+
exclude-dirs:
2526
- ^pkg.*client.*clientset.*versioned.*
2627
- ^pkg.*client.*informers.*externalversions.*
2728
- pkg.*mod.*k8s.io.*
2829

29-
# which files to skip: they will be analyzed, but issues from them
30-
# won't be reported. Default value is empty list, but there is
31-
# no need to include all autogenerated files, we confidently recognize
32-
# autogenerated files. If it's not please let us know.
33-
skip-files: []
34-
# - ".*\\.my\\.go$"
35-
# - lib/bad.go
36-
3730
# output configuration options
3831
output:
3932
# colored-line-number|line-number|json|tab|checkstyle, default is "colored-line-number"
40-
format: tab
33+
formats:
34+
- format: tab
4135

4236
# print lines of code with issue, default is true
4337
print-issued-lines: true
@@ -71,9 +65,6 @@ linters-settings:
7165
statements: 40
7266

7367
govet:
74-
# report about shadowed variables
75-
check-shadowing: true
76-
7768
# settings per analyzer
7869
settings:
7970
printf: # analyzer name, run `go tool vet help` to see all analyzers
@@ -82,13 +73,18 @@ linters-settings:
8273
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
8374
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
8475
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
76+
- github.com/dapr/cli/pkg/print.FailureStatusEvent
77+
- github.com/dapr/cli/pkg/print.SuccessStatusEvent
78+
- github.com/dapr/cli/pkg/print.WarningStatusEvent
79+
- github.com/dapr/cli/pkg/print.InfoStatusEvent
80+
- github.com/dapr/cli/pkg/print.StatusEvent
81+
- github.com/dapr/cli/pkg/print.Spinner
8582

8683
# enable or disable analyzers by name
8784
enable:
8885
- atomicalign
89-
enable-all: false
90-
disable:
9186
- shadow
87+
enable-all: false
9288
disable-all: false
9389
revive:
9490
# linting errors below this confidence will be ignored, default is 0.8
@@ -106,9 +102,6 @@ linters-settings:
106102
gocognit:
107103
# minimal code complexity to report, 30 by default (but we recommend 10-20)
108104
min-complexity: 10
109-
maligned:
110-
# print struct with more effective memory layout or not, false by default
111-
suggest-new: true
112105
dupl:
113106
# tokens count to trigger issue, 150 by default
114107
threshold: 100
@@ -141,7 +134,7 @@ linters-settings:
141134
# XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
142135
# if it's called for subdir of a project it can't find funcs usages. All text editor integrations
143136
# with golangci-lint call it on a directory with the changed file.
144-
check-exported: false
137+
exported-fields-are-used: false
145138
unparam:
146139
# Inspect exported functions, default is false. Set to true if no external program/library imports your code.
147140
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
@@ -216,12 +209,17 @@ linters-settings:
216209
# Allow case blocks to end with a whitespace.
217210
# Allow declarations (var) to be cuddled.
218211
allow-cuddle-declarations: false
212+
testifylint:
213+
disable:
214+
- require-error
215+
219216

220217
linters:
221218
fast: false
222219
enable-all: true
223220
disable:
224221
# TODO Enforce the below linters later
222+
- musttag
225223
- dupl
226224
- errcheck
227225
- funlen
@@ -230,39 +228,48 @@ linters:
230228
- gocyclo
231229
- gocognit
232230
- godox
233-
- interfacer
234231
- lll
235-
- maligned
236-
- scopelint
237232
- unparam
238233
- wsl
239234
- gomnd
240235
- testpackage
241236
- nestif
242-
- goerr113
243237
- nlreturn
244238
- exhaustive
245-
- gci
246-
- noctx
247-
- exhaustivestruct
248239
- exhaustruct
249-
- gomoddirectives
250-
- paralleltest
240+
- noctx
241+
- gci
251242
- tparallel
252-
- wastedassign
253-
- cyclop
254-
- forbidigo
255-
- tagliatelle
256-
- thelper
243+
- paralleltest
257244
- wrapcheck
245+
- tagliatelle
246+
- ireturn
247+
- errchkjson
248+
- contextcheck
249+
- gomoddirectives
250+
- godot
251+
- cyclop
258252
- varnamelen
253+
- errorlint
259254
- forcetypeassert
260-
- ireturn
261-
- golint
262-
- nosnakecase
255+
- maintidx
256+
- nilnil
257+
- predeclared
258+
- tenv
259+
- thelper
260+
- wastedassign
261+
- containedctx
262+
- gosimple
263+
- nonamedreturns
264+
- asasalint
265+
- rowserrcheck
266+
- sqlclosecheck
267+
- inamedparam
263268
- tagalign
264-
- varcheck
265-
- deadcode
266-
- structcheck
267-
- ifshort
268-
- testifylint
269+
- mnd
270+
- canonicalheader
271+
- exportloopref
272+
- execinquery
273+
- err113
274+
- fatcontext
275+
- forbidigo

cmd/dashboard.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ dapr dashboard -k -p 0
182182
// url for dashboard after port forwarding.
183183
webURL := fmt.Sprintf("http://%s", net.JoinHostPort(dashboardHost, fmt.Sprint(portForward.LocalPort))) //nolint: perfsprint
184184

185-
print.InfoStatusEvent(os.Stdout, fmt.Sprintf("Dapr dashboard found in namespace:\t%s", foundNamespace))
185+
print.InfoStatusEvent(os.Stdout, "Dapr dashboard found in namespace:\t"+foundNamespace)
186186
print.InfoStatusEvent(os.Stdout, fmt.Sprintf("Dapr dashboard available at:\t%s\n", webURL))
187187

188188
err = browser.OpenURL(webURL)

cmd/mtls.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ dapr mtls export -o ./certs
6767
}
6868

6969
dir, _ := filepath.Abs(exportPath)
70-
print.SuccessStatusEvent(os.Stdout, fmt.Sprintf("Trust certs successfully exported to %s", dir))
70+
print.SuccessStatusEvent(os.Stdout, "Trust certs successfully exported to "+dir)
7171
},
7272
PostRun: func(cmd *cobra.Command, args []string) {
7373
kubernetes.CheckForCertExpiry()

cmd/renew_certificate.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ dapr mtls renew-cert -k --valid-until <no of days> --restart
103103
print.InfoStatusEvent(os.Stdout, "Using password file to generate root certificate")
104104
err = kubernetes.RenewCertificate(kubernetes.RenewCertificateParams{
105105
RootPrivateKeyFilePath: privateKey,
106-
ValidUntil: time.Hour * time.Duration(validUntil*24),
106+
ValidUntil: time.Hour * time.Duration(validUntil*24), //nolint:gosec
107107
Timeout: timeout,
108108
ImageVariant: imageVariant,
109109
})
@@ -113,7 +113,7 @@ dapr mtls renew-cert -k --valid-until <no of days> --restart
113113
} else {
114114
print.InfoStatusEvent(os.Stdout, "generating fresh certificates")
115115
err = kubernetes.RenewCertificate(kubernetes.RenewCertificateParams{
116-
ValidUntil: time.Hour * time.Duration(validUntil*24),
116+
ValidUntil: time.Hour * time.Duration(validUntil*24), //nolint:gosec
117117
Timeout: timeout,
118118
ImageVariant: imageVariant,
119119
})
@@ -129,7 +129,7 @@ dapr mtls renew-cert -k --valid-until <no of days> --restart
129129
logErrorAndExit(err)
130130
}
131131
print.SuccessStatusEvent(os.Stdout,
132-
fmt.Sprintf("Certificate rotation is successful! Your new certicate is valid through %s", expiry.Format(time.RFC1123)))
132+
"Certificate rotation is successful! Your new certicate is valid through "+expiry.Format(time.RFC1123))
133133

134134
if restartDaprServices {
135135
restartControlPlaneService()

cmd/run.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -319,14 +319,14 @@ dapr run --run-file /path/to/directory -k
319319

320320
stdErrPipe, pipeErr := output.AppCMD.StderrPipe()
321321
if pipeErr != nil {
322-
print.FailureStatusEvent(os.Stderr, fmt.Sprintf("Error creating stderr for App: %s", err.Error()))
322+
print.FailureStatusEvent(os.Stderr, "Error creating stderr for App: "+err.Error())
323323
appRunning <- false
324324
return
325325
}
326326

327327
stdOutPipe, pipeErr := output.AppCMD.StdoutPipe()
328328
if pipeErr != nil {
329-
print.FailureStatusEvent(os.Stderr, fmt.Sprintf("Error creating stdout for App: %s", err.Error()))
329+
print.FailureStatusEvent(os.Stderr, "Error creating stdout for App: "+err.Error())
330330
appRunning <- false
331331
return
332332
}
@@ -335,13 +335,13 @@ dapr run --run-file /path/to/directory -k
335335
outScanner := bufio.NewScanner(stdOutPipe)
336336
go func() {
337337
for errScanner.Scan() {
338-
fmt.Println(print.Blue(fmt.Sprintf("== APP == %s", errScanner.Text())))
338+
fmt.Println(print.Blue("== APP == " + errScanner.Text()))
339339
}
340340
}()
341341

342342
go func() {
343343
for outScanner.Scan() {
344-
fmt.Println(print.Blue(fmt.Sprintf("== APP == %s", outScanner.Text())))
344+
fmt.Println(print.Blue("== APP == " + outScanner.Text()))
345345
}
346346
}()
347347

@@ -395,7 +395,7 @@ dapr run --run-file /path/to/directory -k
395395
}
396396

397397
appCommand := strings.Join(args, " ")
398-
print.InfoStatusEvent(os.Stdout, fmt.Sprintf("Updating metadata for app command: %s", appCommand))
398+
print.InfoStatusEvent(os.Stdout, "Updating metadata for app command: "+appCommand)
399399
err = metadata.Put(output.DaprHTTPPort, "appCommand", appCommand, output.AppID, unixDomainSocket)
400400
if err != nil {
401401
print.WarningStatusEvent(os.Stdout, "Could not update sidecar metadata for appCommand: %s", err.Error())

0 commit comments

Comments
 (0)