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

Commit 03c01c4

Browse files
committed
Fixing Gosec complaints
1 parent a7a8f7c commit 03c01c4

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pkg/pgmodel/metrics/database/metrics.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package database
22

33
import (
4+
"crypto/rand"
45
"fmt"
5-
"math/rand"
6+
"math/big"
67
"strings"
78
"time"
89

@@ -53,11 +54,14 @@ func updateAtMostEvery(interval time.Duration) metricQueryPollConfig {
5354
// funciton will hammer the database simultaneously at the start.
5455
// At the same time delaying them for the full duration of interval
5556
// might be too much. Hence the jitter.
56-
jitterDelta := time.Duration(rand.Int63n(int64(interval) / 3))
57+
jitterDelta, err := rand.Int(rand.Reader, big.NewInt(int64(interval)/3))
58+
if err != nil {
59+
panic(err)
60+
}
5761
return metricQueryPollConfig{
5862
enabled: true,
5963
interval: interval,
60-
lastUpdate: time.Now().Add(-interval + jitterDelta),
64+
lastUpdate: time.Now().Add(-interval + time.Duration(jitterDelta.Int64())),
6165
}
6266
}
6367

0 commit comments

Comments
 (0)