Skip to content

Commit

Permalink
Use crypto/rand instead of math/rand
Browse files Browse the repository at this point in the history
  • Loading branch information
Gogen120 committed Sep 23, 2024
1 parent 9fff5cf commit 4a6ecb9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions selectel/dbaas.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 4a6ecb9

Please sign in to comment.