Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lint: enable gosec G402 (minimum TLS version) #23247

Merged
merged 1 commit into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ linters-settings:
template: |-
SPDX-License-Identifier: Apache-2.0
Copyright Authors of {{ PROJECT }}
gosec:
includes:
- G402

issues:
# Excluding configuration per-path, per-linter, per-text and per-source
Expand Down Expand Up @@ -89,6 +92,7 @@ linters:
- unused
- varcheck
- goheader
- gosec

# To enable later if makes sense
# - deadcode
Expand Down
6 changes: 5 additions & 1 deletion pkg/crypto/certloader/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,12 @@ func (c *WatchedServerConfig) ServerConfig(base *tls.Config) *tls.Config {
}
}
c.log.WithField("keypair-sn", keypairId(keypair)).
Debugf("Server tls handshake")
Debug("Server tls handshake")
return tlsConfig, nil
},
// NOTE: this MinVersion is not used as this tls.Config will be
// overridden by the one returned by GetConfigForClient. The effective
// MinVersion must be set by the provided base TLS configuration.
MinVersion: tls.VersionTLS13,
}
}
4 changes: 3 additions & 1 deletion pkg/hubble/peer/types/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ func (b RemoteClientBuilder) Client(target string) (Client, error) {
if b.TLSConfig == nil {
opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
} else {
tlsConfig := b.TLSConfig.ClientConfig(&tls.Config{
// NOTE: gosec is unable to resolve the constant and warns about "TLS
// MinVersion too low".
tlsConfig := b.TLSConfig.ClientConfig(&tls.Config{ //nolint:gosec
ServerName: b.TLSServerName,
MinVersion: hubbleopts.MinTLSVersion,
})
Expand Down
4 changes: 3 additions & 1 deletion pkg/hubble/relay/pool/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ func (b GRPCClientConnBuilder) ClientConn(target, hostname string) (poolTypes.Cl
if b.TLSConfig == nil {
opts = append(opts, grpc.WithInsecure())
} else {
tlsConfig := b.TLSConfig.ClientConfig(&tls.Config{
// NOTE: gosec is unable to resolve the constant and warns about "TLS
// MinVersion too low".
tlsConfig := b.TLSConfig.ClientConfig(&tls.Config{ //nolint:gosec
ServerName: hostname,
MinVersion: hubbleopts.MinTLSVersion,
})
Expand Down
4 changes: 3 additions & 1 deletion pkg/hubble/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ func (s *Server) newGRPCServer() (*grpc.Server, error) {
opts = append(opts, grpc.StreamInterceptor(interceptor))
}
if s.opts.ServerTLSConfig != nil {
tlsConfig := s.opts.ServerTLSConfig.ServerConfig(&tls.Config{
// NOTE: gosec is unable to resolve the constant and warns about "TLS
// MinVersion too low".
tlsConfig := s.opts.ServerTLSConfig.ServerConfig(&tls.Config{ //nolint:gosec
MinVersion: serveroption.MinTLSVersion,
})
opts = append(opts, grpc.Creds(credentials.NewTLS(tlsConfig)))
Expand Down