Skip to content

Commit 977da09

Browse files
committed
fix(gosec): annotate non-crypto math/rand uses with //nosec G404
1 parent 05d8c16 commit 977da09

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

comm/peer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func (ps *PeerSet) Slice() Peers {
180180
defer ps.lock.Unlock()
181181

182182
ret := make(Peers, len(ps.m))
183-
perm := rand.Perm(len(ps.m))
183+
perm := rand.Perm(len(ps.m)) //nosec G404 -- non-crypto shuffle for peer ordering
184184
i := 0
185185
for _, s := range ps.m {
186186
// randomly

p2p/discv5/ticket.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ func (s *ticketStore) addTicket(localTime mclock.AbsTime, pingHash []byte, ticke
549549

550550
if _, ok := s.tickets[topic]; ok {
551551
wait := ticket.regTime[topicIdx] - localTime
552-
rnd := rand.ExpFloat64()
552+
rnd := rand.ExpFloat64() //nosec G404 -- non-crypto jitter for ticket registration wait
553553
rnd = min(rnd, 10)
554554
if float64(wait) < float64(keepTicketConst)+float64(keepTicketExp)*rnd {
555555
// use the ticket to register this topic

p2p/discv5/topic.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ func (w *waitControlLoop) hasMinimumWaitPeriod() bool {
354354
}
355355

356356
func noRegTimeout() time.Duration {
357-
e := rand.ExpFloat64()
357+
e := rand.ExpFloat64() //nosec G404 -- non-crypto jitter for registration timeout
358358
e = min(e, 100)
359359
return time.Duration(float64(avgnoRegTimeout) * e)
360360
}

0 commit comments

Comments
 (0)