[#161] *: Do not use math/rand.Read()

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
pull/161/head
Evgenii Stratonikov 2023-09-08 17:15:08 +03:00
parent aa12d8c6a6
commit 49ad985cad
15 changed files with 24 additions and 22 deletions

View File

@ -2,9 +2,9 @@ package checksum
import (
"bytes"
"crypto/rand"
"crypto/sha256"
"fmt"
"math/rand"
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs"
)

View File

@ -1,8 +1,8 @@
package checksumtest
import (
"crypto/rand"
"crypto/sha256"
"math/rand"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/checksum"
)
@ -11,7 +11,7 @@ import (
func Checksum() checksum.Checksum {
var cs [sha256.Size]byte
rand.Read(cs[:])
_, _ = rand.Read(cs[:])
var x checksum.Checksum

View File

@ -1,8 +1,8 @@
package cid_test
import (
"crypto/rand"
"crypto/sha256"
"math/rand"
"testing"
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs"

View File

@ -1,8 +1,8 @@
package cidtest
import (
"crypto/rand"
"crypto/sha256"
"math/rand"
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
)
@ -11,7 +11,7 @@ import (
func ID() cid.ID {
checksum := [sha256.Size]byte{}
rand.Read(checksum[:])
_, _ = rand.Read(checksum[:])
return IDWithChecksum(checksum)
}

View File

@ -1,7 +1,7 @@
package frostfscrypto_test
import (
"math/rand"
"crypto/rand"
"testing"
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs"

View File

@ -2,7 +2,7 @@ package eacltest
import (
"bytes"
"math/rand"
"crypto/rand"
"testing"
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"

View File

@ -1,7 +1,7 @@
package eacl
import (
"math/rand"
"crypto/rand"
"testing"
"github.com/stretchr/testify/require"

View File

@ -1,9 +1,10 @@
package netmap
import (
"crypto/rand"
"encoding/binary"
"fmt"
"math/rand"
mrand "math/rand"
"sort"
"strconv"
"testing"
@ -28,10 +29,10 @@ func BenchmarkHRWSort(b *testing.B) {
node.SetPublicKey(key)
vectors[i] = nodes{node}
weights[i] = float64(rand.Uint32()%10) / 10.0
weights[i] = float64(mrand.Uint32()%10) / 10.0
}
pivot := rand.Uint64()
pivot := mrand.Uint64()
b.Run("sort by index, no weight", func(b *testing.B) {
realNodes := make([]nodes, netmapSize)
b.ResetTimer()

View File

@ -1,7 +1,7 @@
package netmaptest
import (
"math/rand"
"crypto/rand"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap"
)
@ -70,7 +70,7 @@ func NetworkInfo() (x netmap.NetworkInfo) {
// NodeInfo returns random netmap.NodeInfo.
func NodeInfo() (x netmap.NodeInfo) {
key := make([]byte, 33)
rand.Read(key)
_, _ = rand.Read(key)
x.SetPublicKey(key)
x.SetNetworkEndpoints("1", "2", "3")

View File

@ -1,10 +1,10 @@
package ns
import (
"crypto/rand"
"errors"
"fmt"
"math/big"
"math/rand"
"strings"
"testing"

View File

@ -1,8 +1,8 @@
package oidtest
import (
"crypto/rand"
"crypto/sha256"
"math/rand"
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
@ -12,7 +12,7 @@ import (
func ID() oid.ID {
checksum := [sha256.Size]byte{}
rand.Read(checksum[:])
_, _ = rand.Read(checksum[:])
return idWithChecksum(checksum)
}

View File

@ -1,8 +1,8 @@
package object_test
import (
"crypto/rand"
"crypto/sha256"
"math/rand"
"testing"
v2object "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/object"

View File

@ -1,8 +1,8 @@
package object
import (
"crypto/rand"
"crypto/sha256"
"math/rand"
"testing"
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/tombstone"

View File

@ -1,9 +1,10 @@
package session_test
import (
"crypto/rand"
"fmt"
"math"
"math/rand"
mrand "math/rand"
"testing"
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs"
@ -396,7 +397,7 @@ func TestContainer_AppliedTo(t *testing.T) {
func TestContainer_InvalidAt(t *testing.T) {
var x session.Container
nbf := rand.Uint64()
nbf := mrand.Uint64()
if nbf == math.MaxUint64 {
nbf--
}

View File

@ -1,7 +1,7 @@
package user_test
import (
"math/rand"
"crypto/rand"
"testing"
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs"