-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.golangci.yml
More file actions
488 lines (488 loc) · 20.4 KB
/
Copy path.golangci.yml
File metadata and controls
488 lines (488 loc) · 20.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
version: '2'
run:
go: '1.25'
timeout: 15m
linters:
default: none
enable:
- bodyclose
- depguard
- errorlint
- forbidigo
- govet
- ineffassign
- misspell
- nolintlint
- revive
- sloglint
- staticcheck
- testifylint
- unconvert
- unused
settings:
depguard:
rules:
cgo:
files:
- '!$test'
- '**/tool/tbot/**'
- '**/lib/client/**'
- '!**/lib/integrations/**'
- '**/integrations/**'
deny:
- pkg: github.com/gravitational/teleport/lib/bpf
desc: '"lib/bpf" requires CGO'
- pkg: github.com/gravitational/teleport/lib/backend/lite
desc: '"lib/backend/lite" requires CGO'
- pkg: github.com/gravitational/teleport/lib/cgroup
desc: '"lib/cgroup" requires CGO'
- pkg: github.com/gravitational/teleport/lib/config
desc: '"lib/config" requires CGO via "lib/pam" and "lib/backend/lite"'
- pkg: github.com/gravitational/teleport/lib/desktop/rdp/rdpclient
desc: '"lib/desktop/rdp/rdpclient" requires CGO'
- pkg: github.com/gravitational/teleport/lib/devicetrust/authn$
desc: '"lib/devicetrust/authn" requires CGO on darwin'
- pkg: github.com/gravitational/teleport/lib/devicetrust/enroll
desc: '"lib/devicetrust/enroll" requires CGO on darwin'
- pkg: github.com/gravitational/teleport/lib/devicetrust/native
desc: '"lib/devicetrust/native" requires CGO on darwin'
- pkg: github.com/gravitational/teleport/lib/inventory/metadata
desc: '"lib/inventory/metadata" requires CGO'
- pkg: github.com/gravitational/teleport/lib/pam
desc: '"lib/pam" requires CGO'
- pkg: github.com/gravitational/teleport/lib/srv/uacc
desc: '"lib/srv/uacc" requires CGO'
- pkg: github.com/gravitational/teleport/lib/system/signal
desc: '"lib/system/signal" requires CGO'
- pkg: github.com/gravitational/teleport/lib/vnet/daemon
desc: '"vnet/daemon" requires CGO'
client-tools:
list-mode: lax
files:
- '!$test'
- '**/tool/tbot/**'
- '**/lib/tbot/**'
- '**/tool/tctl/**'
- '**/tool/tsh/**'
- '**/lib/client/**'
- '**/lib/services/**'
- '**/lib/service/servicecfg/**'
- '**/lib/reversetunnelclient/**'
- '**/lib/auth/authclient/**'
- '**/lib/cloud/imds/**'
allow:
- github.com/gravitational/teleport/lib/cloud/imds
deny:
- pkg: github.com/gravitational/teleport/lib/auth$
desc: lib/auth should not be imported to prevent increasing binary size, prefer lib/auth/authclient instead
- pkg: github.com/gravitational/teleport/lib/cloud
desc: lib/cloud should not be imported to prevent increasing binary size
- pkg: github.com/gravitational/teleport/lib/srv$
desc: lib/srv prevents client tools from build on non-linux platforms
- pkg: github.com/gravitational/teleport/lib/web$
desc: lib/web should not be imported to prevent increasing binary size
go-cmp:
files:
- '!$test'
- '!**/integration/helpers/**'
- '!**/integrations/operator/controllers/resources/testlib/**'
- '!**/lib/auth/test/**'
- '!**/lib/services/suite/**'
- '!**/e/lib/accesslist/equal.go'
- '!**/e/lib/auth/saml.go'
- '!**lib/services/authority.go'
- '!**lib/services/compare.go'
- '!**/lib/services/local/access_list.go'
- '!**/lib/services/local/users.go'
- '!**/lib/services/server.go'
- '!**/lib/services/user.go'
deny:
- pkg: github.com/google/go-cmp/cmp
desc: '"github.com/google/go-cmp/cmp" should only be used in tests'
- pkg: github.com/google/go-cmp/cmp/cmpopts
desc: '"github.com/google/go-cmp/cmp/cmpopts" should only be used in tests'
integration:
list-mode: lax
files:
- '!$test'
- '!**/integration/**'
- '!**/e/tests/**'
- '!**/integrations/operator/controllers/resources/testlib/**'
allow:
- github.com/gravitational/teleport/integrations
deny:
- pkg: github.com/gravitational/teleport/integration
desc: integration test should not be imported outside of intergation tests
- pkg: github.com/gravitational/teleport/lib/srv/db/cassandra/protocoltest
desc: testing packages should not be imported outside of _test.go files
- pkg: github.com/gravitational/teleport/lib/utils/mcptest
desc: testing packages should not be imported outside of _test.go files
- pkg: github.com/testcontainers/testcontainers-go
desc: testing packages should not be imported outside of _test.go files
- pkg: github.com/testcontainers/testcontainers-go/modules/postgres
desc: testing packages should not be imported outside of _test.go files
- pkg: github.com/testcontainers/testcontainers-go/modules/mysql
desc: testing packages should not be imported outside of _test.go files
logging:
deny:
- pkg: github.com/sirupsen/logrus
desc: use "log/slog" instead
- pkg: github.com/siddontang/go-log/log
desc: use "log/slog" instead
- pkg: github.com/siddontang/go/log
desc: use "log/slog" instead
- pkg: github.com/mailgun/log
desc: use "log/slog" instead
- pkg: github.com/saferwall/pe/log
desc: use "log/slog" instead
- pkg: golang.org/x/exp/slog
desc: use "log/slog" instead
- pkg: github.com/aws/aws-sdk-go/
desc: 'use "aws-sdk-go-v2" instead'
- pkg: github.com/aws/aws-sdk-go$
desc: 'use "aws-sdk-go-v2" instead'
main:
deny:
- pkg: io/ioutil
desc: use "io" or "os" packages instead
- pkg: math/rand$
desc: use "math/rand/v2" or "crypto/rand" instead
- pkg: github.com/golang/protobuf
desc: use "google.golang.org/protobuf"
- pkg: github.com/hashicorp/go-uuid
desc: use "github.com/google/uuid" instead
- pkg: github.com/pborman/uuid
desc: use "github.com/google/uuid" instead
- pkg: github.com/tj/assert
desc: use "github.com/stretchr/testify/assert" instead
- pkg: go.uber.org/atomic
desc: use "sync/atomic" instead
- pkg: golang.design
desc: experimental project, not to be confused with official Go packages
- pkg: golang.org/x/exp/slices
desc: use "slices" instead
- pkg: github.com/hashicorp/go-version
desc: use "coreos/go-semver/semver" instead
- pkg: golang.org/x/mod/semver
desc: use "coreos/go-semver/semver" instead
- pkg: github.com/microsoftgraph/msgraph-sdk-go
desc: use "github.com/gravitational/teleport/lib/msgraph" instead
- pkg: github.com/cloudflare/cfssl
desc: use "crypto" or "x/crypto" instead
- pkg: golang.org/x/net/context
desc: use "context" instead
- pkg: github.com/gogo/protobuf/jsonpb
desc: gogoproto jsonpb has inconsistent interactions with any
message that directly or indirectly makes use of
gogoproto.casttype, and will happily violate the protobuf json
encoding spec in those situations. It should only be used for
existing marshaling and unmarshaling that can't easily be
migrated away from jsonpb, but it should not be used by new
code. If you need to encode and decode a gogoproto-generated
message in protobuf json, use
google.golang.org/protobuf/encoding/protojson together with
google.golang.org/protobuf/protoadapt instead, or, better yet,
see if you can move the code generation for that message to the
modern protoc-gen-go.
oidc:
deny:
- pkg: github.com/coreos/go-oidc
desc: 'github.com/zitadel/oidc/v3 should be used instead'
- pkg: github.com/zitadel/oidc$
desc: 'github.com/zitadel/oidc/v3 should be used instead'
test_packages:
files:
- '!$test'
- '!**/integrations/operator/controllers/resources/testlib/**.go'
- '!**/e/lib/aws/identitycenter/test/**'
- '!**/e/lib/devicetrust/testenv/**'
- '!**/e/lib/jamf/testenv/**'
- '!**/e/lib/intune/testenv/**'
- '!**/e/lib/idp/saml/testenv/**'
- '!**/e/lib/operatortest/**'
- '!**/e/tests/**'
- '!**/integration/db/fixture.go'
- '!**/integration/helpers/**'
- '!**/integrations/lib/testing/**'
deny:
- pkg: github.com/gravitational/teleport/e/lib/aws/identitycenter/test
desc: testing packages should not be imported outside of _test.go files
- pkg: github.com/gravitational/teleport/e/lib/idp/operatortest
desc: testing packages should not be imported outside of _test.go files
- pkg: github.com/gravitational/teleport/lib/events/tests
desc: testing packages should not be imported outside of _test.go files
- pkg: github.com/gravitational/teleport/lib/teleterm/gatewaytest
desc: testing packages should not be imported outside of _test.go files
- pkg: github.com/gravitational/teleport/lib/utils/testutils
desc: testing packages should not be imported outside of _test.go files
- pkg: github.com/gravitational/teleport/lib/test
desc: testing packages should not be imported outside of _test.go files
- pkg: github.com/gravitational/teleport/integrations/operator/controllers/resources/testlib
desc: testing packages should not be imported outside of _test.go files
- pkg: github.com/gravitational/teleport/tool/teleport/testenv
desc: testing packages should not be imported outside of _test.go files
- pkg: github.com/gravitational/teleport/lib/srv/db/redis/protocoltest
desc: testing packages should not be imported outside of _test.go files
- pkg: github.com/gravitational/teleport/lib/srv/db/spanner/protocoltest
desc: testing packages should not be imported outside of _test.go files
- pkg: github.com/gravitational/teleport/lib/srv/db/clickhouse/protocoltest
desc: testing packages should not be imported outside of _test.go files
- pkg: github.com/gravitational/teleport/lib/modules/modulestest
desc: testing packages should not be imported outside of _test.go files
- pkg: github.com/gravitational/teleport/lib/utils/logtesttest
desc: testing packages should not be imported outside of _test.go files
- pkg: github.com/gravitational/teleport/lib/auth/authtest
desc: testing packages should not be imported outside of _test.go files
- pkg: github.com/gravitational/teleport/lib/cryptosuites/cryptosuitestest
desc: testing packages should not be imported outside of _test.go files
testify:
files:
- '!$test'
- '!**/api/testhelpers/**'
- '!**/e/lib/auth/ssotestlib.go'
- '!**/e/lib/aws/identitycenter/test/**'
- '!**/e/lib/idp/saml/testenv/**'
- '!**/e/lib/operatortest/**'
- '!**/e/tests/**'
- '!**/lib/auth/helpers.go'
- '!**/lib/auth/keystore/testhelpers.go'
- '!**/lib/backend/test/**'
- '!**/lib/events/test/**'
- '!**/lib/services/suite/**'
- '!**/lib/tbot/workloadidentity/workloadattest/sigstore/sigstoretest/sigstoretest.go'
- '!**/lib/teleterm/gatewaytest/**'
- '!**/lib/utils/mcptest/**'
- '!**/lib/utils/testutils/**'
- '!**/integration/appaccess/fixtures.go'
- '!**/integration/appaccess/jwt.go'
- '!**/integration/appaccess/pack.go'
- '!**/integration/db/fixture.go'
- '!**/integration/hsm/helpers.go'
- '!**/integration/helpers/**'
- '!**/integration/proxy/proxy_helpers.go'
- '!**/integrations/access/email/testlib/**'
- '!**/integrations/access/datadog/testlib/**'
- '!**/integrations/access/discord/testlib/**'
- '!**/integrations/access/jira/testlib/**'
- '!**/integrations/access/mattermost/testlib/**'
- '!**/integrations/access/msteams/testlib/**'
- '!**/integrations/access/opsgenie/testlib/**'
- '!**/integrations/access/pagerduty/testlib/**'
- '!**/integrations/access/servicenow/testlib/**'
- '!**/integrations/access/slack/testlib/**'
- '!**/integrations/lib/testing/integration/accessrequestsuite.go'
- '!**/integrations/lib/testing/integration/app.go'
- '!**/integrations/lib/testing/integration/authhelper.go'
- '!**/integrations/lib/testing/integration/suite.go'
- '!**/integrations/operator/controllers/resources/testlib/**'
- '!**/e/lib/intune/testenv/**'
deny:
- pkg: github.com/stretchr/testify
desc: testify should not be imported outside of test code
testing:
files:
- '!$test'
- '!**/api/testhelpers/**'
- '!**/e/lib/auth/ssotestlib.go'
- '!**/e/lib/aws/identitycenter/test/**'
- '!**/e/lib/devicetrust/testenv/**'
- '!**/e/lib/devicetrust/storage/storage.go'
- '!**/e/lib/idp/saml/testenv/**'
- '!**/e/lib/jamf/testenv/**'
- '!**/e/lib/intune/testenv/**'
- '!**/e/lib/okta/api/oktaapitest/**'
- '!**/e/lib/operatortest/**'
- '!**/e/tests/**'
- '!**/integration/**'
- '!**/integrations/access/email/testlib/**'
- '!**/integrations/access/msteams/testlib/**'
- '!**/integrations/access/slack/testlib/**'
- '!**/integrations/operator/controllers/resources/testlib/**'
- '!**/lib/auth/authtest/**'
- '!**/lib/auth/helpers.go'
- '!**/lib/auth/keystore/testhelpers.go'
- '!**/lib/backend/test/**'
- '!**/lib/cryptosuites/precompute.go'
- '!**/lib/cryptosuites/internal/rsa/rsa.go'
- '!**/lib/events/test/**'
- '!**/lib/modules/modulestest/**'
- '!**/lib/modules/test.go'
- '!**/lib/service/service.go'
- '!**/lib/services/local/users.go'
- '!**/lib/services/suite/**'
- '!**/lib/tbot/workloadidentity/workloadattest/sigstore/sigstoretest/sigstoretest.go'
- '!**/lib/teleterm/gatewaytest/**'
- '!**/lib/utils/cli.go'
- '!**/lib/utils/mcptest/**'
- '!**/lib/utils/testutils/**'
deny:
- pkg: testing
desc: testing should not be imported outside of tests
errorlint:
errorf: true
asserts: true
comparison: true
forbidigo:
forbid:
- pattern: ^rsa\.GenerateKey$
msg: generating RSA keys is slow, use lib/cryptosuites to generate an appropriate key type
- pattern: ^iam\.NewFromConfig$
msg: Use iamutils.NewFromConfig
- pattern: ^sts\.NewFromConfig$
msg: Use stsutils.NewFromConfig
- pattern: ^sts\.New$
msg: Use stsutils.NewV1
- pattern: ^stscreds\.NewCredentials$
msg: Use stsutils.NewCredentials
- pattern: ^protojson\.Unmarshal$
msg: use protojson.UnmarshalOptions and consider enabling DiscardUnknown
- pattern: ^jsonpb\.(?:Unmarshal|UnmarshalString|UnmarshalNext)$
msg: use protojson if possible, or use jsonpb.Unmarshaler and consider enabling AllowUnknownFields
misspell:
locale: US
nolintlint:
require-explanation: true
require-specific: true
allow-unused: true
revive:
rules:
- name: unused-parameter
disabled: true
sloglint:
context: all
static-msg: true
key-naming-case: snake
forbidden-keys:
- level
- msg
- source
- time
testifylint:
disable-all: true
enable:
- bool-compare
- compares
- empty
- error-is-as
- error-nil
- expected-actual
- float-compare
- len
- suite-extra-assert-call
- suite-thelper
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- staticcheck
text: 'QF1008: could remove embedded field'
- linters:
- staticcheck
text: 'QF1008: could simplify selectors'
- linters:
- staticcheck
text: 'S1002: should omit comparison to bool constant'
- linters:
- revive
text: 'exported: exported const'
- linters:
- unused
path: integrations/operator/controllers/resources/(.+)_controller_test\.go
- linters:
- staticcheck
text: grpc.Dial is deprecated
- linters:
- staticcheck
text: grpc.DialContext is deprecated
- linters:
- staticcheck
path: (client/client.go|client/proxy/client_test.go)
text: this DialOption is not supported by NewClient
- linters:
- staticcheck
path: lib/kube/grpc/grpc_test.go
text: grpc.WithBlock is deprecated
- linters:
- staticcheck
path: lib/observability/tracing/client.go
text: grpc.WithBlock is deprecated
- linters:
- staticcheck
path: integrations/lib/config.go
text: grpc.WithReturnConnectionError is deprecated
- linters:
- staticcheck
path: lib/service/service_test.go
text: this DialOption is not supported by NewClient
- linters:
- staticcheck
path: integration/client_test.go
text: grpc.WithReturnConnectionError is deprecated
- linters:
- staticcheck
path: integration/integration_test.go
text: grpc.WithBlock is deprecated
- linters:
- staticcheck
path: lib/multiplexer/multiplexer_test.go
text: grpc.WithBlock is deprecated
- linters:
- staticcheck
path: provider/provider.go
text: grpc.WithReturnConnectionError is deprecated
- linters:
- staticcheck
text: 'BlockUntil is deprecated: New code should prefer BlockUntilContext'
- linters:
- forbidigo
path: lib/utils/aws/iamutils/iam.go
text: iam.NewFromConfig
- linters:
- forbidigo
path: lib/utils/aws/stsutils/sts.go
text: sts.NewFromConfig
- linters:
- forbidigo
path: lib/utils/aws/stsutils/sts_v1.go
text: sts.New
- linters:
- forbidigo
path: lib/utils/aws/stsutils/stscreds_v1.go
text: stscreds.NewCredentials
paths:
- (^|/)node_modules/
- ^api/gen/
- ^docs/
- ^gen/
- ^rfd/
- ^web/
issues:
max-issues-per-linter: 0
max-same-issues: 0
uniq-by-line: false
formatters:
enable:
- gci
- goimports
settings:
gci:
sections:
- standard
- default
- prefix(github.com/gravitational/teleport)
- prefix(github.com/gravitational/teleport/integrations/terraform,github.com/gravitational/teleport/integrations/event-handler)
custom-order: true
exclusions:
generated: lax
paths:
- (^|/)node_modules/
- ^api/gen/
- ^docs/
- ^gen/
- ^rfd/
- ^web/