Set MinVersion: tls.VersionTLS12 in prometheus client's TLSClientConfig

Having no explicit MinVersion is reported by [gosec] as G402 (CWE-295):
`TLS MinVersion too low`

Using MinVersion: tls.VersionTLS12 because it's what client-go uses:
cf 1ac8d45935/transport/transport.go (L92)

That way, the Kubernetes API client and the Prometheus client in
prometheus-adapter use the same TLS config MinVersion.

[gosec]: https://github.com/securego/gosec
This commit is contained in:
Olivier Lemasle 2022-11-28 23:18:51 +01:00
parent 8958457968
commit dc0c0058d0

View file

@ -408,10 +408,10 @@ func makePrometheusCAClient(caFilePath string, tlsCertFilePath string, tlsKeyFil
}
return &http.Client{
Transport: &http.Transport{
//nolint:gosec
TLSClientConfig: &tls.Config{
RootCAs: pool,
Certificates: []tls.Certificate{tlsClientCerts},
MinVersion: tls.VersionTLS12,
},
},
}, nil
@ -419,9 +419,9 @@ func makePrometheusCAClient(caFilePath string, tlsCertFilePath string, tlsKeyFil
return &http.Client{
Transport: &http.Transport{
//nolint:gosec
TLSClientConfig: &tls.Config{
RootCAs: pool,
RootCAs: pool,
MinVersion: tls.VersionTLS12,
},
},
}, nil