From 4a6ecb9dfefb856a8384e02048e9b1b67bdd9fcd Mon Sep 17 00:00:00 2001 From: Gogen120 Date: Mon, 23 Sep 2024 11:48:53 +0300 Subject: [PATCH] Use crypto/rand instead of math/rand --- selectel/dbaas.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/selectel/dbaas.go b/selectel/dbaas.go index 61a89cb8..01104fab 100644 --- a/selectel/dbaas.go +++ b/selectel/dbaas.go @@ -3,15 +3,15 @@ package selectel import ( "context" "crypto/md5" + "crypto/rand" "errors" "fmt" "log" "math" - "math/rand" // nosemgrep: go.lang.security.audit.crypto.math_random.math-random-used + "math/big" "sort" "strconv" "strings" - "time" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -97,7 +97,8 @@ func convertFieldToStringByType(field interface{}) string { } func RandomWithPrefix(name string) string { - return fmt.Sprintf("%s_%d", name, rand.New(rand.NewSource(time.Now().UnixNano())).Int()) + n, _ := rand.Int(rand.Reader, big.NewInt(1000000)) + return fmt.Sprintf("%s_%d", name, n.Int64()) } func flavorSchema() *schema.Resource {