From fb57765abc69a9490a846cb4ca3058a3f29d1aba Mon Sep 17 00:00:00 2001 From: Nikolai Vladimirov Date: Wed, 6 Mar 2024 06:35:14 +0200 Subject: [PATCH] chore: enable gosec --- .golangci.yml | 1 - internal/run/prom_push_gw_test.go | 6 +++++- internal/trigger/api/iteration_jitter.go | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 4b594d25..4155c88d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -50,7 +50,6 @@ linters: - gocritic - forbidigo - dupl - - gosec linters-settings: tagliatelle: diff --git a/internal/run/prom_push_gw_test.go b/internal/run/prom_push_gw_test.go index c9874f43..e7152e39 100644 --- a/internal/run/prom_push_gw_test.go +++ b/internal/run/prom_push_gw_test.go @@ -7,6 +7,7 @@ import ( "strings" "sync" "sync/atomic" + "time" io_prometheus_client "github.com/prometheus/client_model/go" "github.com/prometheus/common/expfmt" @@ -84,7 +85,10 @@ func (f *FakePrometheus) ServeHTTP(response http.ResponseWriter, request *http.R func (f *FakePrometheus) StartServer() { f.metricFamilies = sync.Map{} - f.server = &http.Server{Addr: fmt.Sprintf("localhost:%d", f.Port)} + f.server = &http.Server{ + Addr: fmt.Sprintf("localhost:%d", f.Port), + ReadHeaderTimeout: 1 * time.Second, + } f.server.Handler = f go func() { if err := f.server.ListenAndServe(); err != nil { diff --git a/internal/trigger/api/iteration_jitter.go b/internal/trigger/api/iteration_jitter.go index f17321de..1aaa3de9 100644 --- a/internal/trigger/api/iteration_jitter.go +++ b/internal/trigger/api/iteration_jitter.go @@ -12,6 +12,7 @@ func WithJitter(rate RateFunction, multiple float64) RateFunction { return rate } return func(now time.Time) int { + //nolint:gosec // G404: Use of weak random number generator - doesn't need to be secure variationFactor := 1 + (math.Cos(rand.Float64()*2*math.Pi))*multiple/100 requestedRate := float64(rate(now)) + balance proposed := requestedRate * variationFactor