Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
Fixing Gosec complaints
Browse files Browse the repository at this point in the history
  • Loading branch information
sumerman committed Dec 21, 2022
1 parent a7a8f7c commit 03c01c4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/pgmodel/metrics/database/metrics.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package database

import (
"crypto/rand"
"fmt"
"math/rand"
"math/big"
"strings"
"time"

Expand Down Expand Up @@ -53,11 +54,14 @@ func updateAtMostEvery(interval time.Duration) metricQueryPollConfig {
// funciton will hammer the database simultaneously at the start.
// At the same time delaying them for the full duration of interval
// might be too much. Hence the jitter.
jitterDelta := time.Duration(rand.Int63n(int64(interval) / 3))
jitterDelta, err := rand.Int(rand.Reader, big.NewInt(int64(interval)/3))
if err != nil {
panic(err)
}
return metricQueryPollConfig{
enabled: true,
interval: interval,
lastUpdate: time.Now().Add(-interval + jitterDelta),
lastUpdate: time.Now().Add(-interval + time.Duration(jitterDelta.Int64())),
}
}

Expand Down

0 comments on commit 03c01c4

Please # to comment.