Skip to content

Commit

Permalink
generator: use crypto/rand instead of math/rand
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Butusov <andrey@nspcc.io>
  • Loading branch information
End-rey committed Aug 29, 2024
1 parent dad76ef commit 91060a3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions internal/datagen/generator.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package datagen

import (
"crypto/rand"
"crypto/sha256"
"encoding/hex"
"math/rand"

"github.com/dop251/goja"
"go.k6.io/k6/js/modules"
Expand Down Expand Up @@ -58,8 +58,10 @@ func (g *Generator) nextSlice() []byte {
if g.buf == nil {
// Allocate buffer with extra tail for sliding and populate it with random bytes
g.buf = make([]byte, g.size+TailSize)
//nolint:staticcheck
rand.Read(g.buf) // Per docs, err is always nil here
_, err := rand.Read(g.buf)
if err != nil {
panic(err)

Check warning on line 63 in internal/datagen/generator.go

View check run for this annotation

Codecov / codecov/patch

internal/datagen/generator.go#L63

Added line #L63 was not covered by tests
}
}

result := g.buf[g.offset : g.offset+g.size]
Expand Down

0 comments on commit 91060a3

Please sign in to comment.