diff options
author | Vishal Tak <vtak@gitlab.com> | 2022-06-02 10:20:32 +0300 |
---|---|---|
committer | Vishal Tak <vtak@gitlab.com> | 2022-06-02 10:54:22 +0300 |
commit | 8505271718ca31061a798ab3919dbd8a50055c65 (patch) | |
tree | 8cbc10d460897a9ad6354ff28defb7416607c140 /internal | |
parent | 2624810f74b8ea239a02d09f5a21def3e1076fda (diff) |
Use IsHTTPS field to check if metrics conn type
Diffstat (limited to 'internal')
-rw-r--r-- | internal/config/config.go | 9 | ||||
-rw-r--r-- | internal/config/config_test.go | 2 |
2 files changed, 3 insertions, 8 deletions
diff --git a/internal/config/config.go b/internal/config/config.go index a59dffd4..46f5f26b 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -150,16 +150,10 @@ type Server struct { type Metrics struct { Address string + IsHTTPS bool TLSConfig *tls.Config } -func (m *Metrics) IsHTTPS() bool { - // disable "G402 (CWE-295): TLS MinVersion too low. (Confidence: HIGH, Severity: HIGH)" - // because zero value of tls.Config{} is used for comparison - // #nosec G402 - return m.TLSConfig != &tls.Config{} -} - var ( errMetricsNoCertificate = errors.New("metrics certificate path must not be empty") errMetricsNoKey = errors.New("metrics private key path must not be empty") @@ -222,6 +216,7 @@ func loadMetricsConfig() (metrics Metrics, err error) { return metrics, err } + metrics.IsHTTPS = true metrics.TLSConfig = &tls.Config{ Certificates: []tls.Certificate{cert}, MinVersion: tls.VersionTLS12, diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 0725bcc3..f120d17d 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -10,7 +10,7 @@ import ( "gitlab.com/gitlab-org/gitlab-pages/internal/fixture" ) -func TestLoadMetricsConfig(t *testing.T) { +func Test_loadMetricsConfig(t *testing.T) { defaultMetricsAdress := ":9325" defaultDir, defaultMetricsKey, defaultMetricsCertificate := setupHTTPSFixture(t) |