gosec: G404: Use of weak random number generator
These should be ok to ignore for the purpose they're used pkg/namesgenerator/names-generator.go:843:36: G404: Use of weak random number generator (math/rand instead of crypto/rand) (gosec) name := fmt.Sprintf("%s_%s", left[rand.Intn(len(left))], right[rand.Intn(len(right))]) ^ pkg/namesgenerator/names-generator.go:849:36: G404: Use of weak random number generator (math/rand instead of crypto/rand) (gosec) name = fmt.Sprintf("%s%d", name, rand.Intn(10)) ^ testutil/stringutils.go:11:18: G404: Use of weak random number generator (math/rand instead of crypto/rand) (gosec) b[i] = letters[rand.Intn(len(letters))] ^ pkg/namesgenerator/names-generator.go:849:36: G404: Use of weak random number generator (math/rand instead of crypto/rand) (gosec) name = fmt.Sprintf("%s%d", name, rand.Intn(10)) ^ Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
f45ca809a6
commit
6b0ecacd92
2 changed files with 3 additions and 3 deletions
|
@ -840,13 +840,13 @@ var (
|
||||||
// integer between 0 and 10 will be added to the end of the name, e.g `focused_turing3`
|
// integer between 0 and 10 will be added to the end of the name, e.g `focused_turing3`
|
||||||
func GetRandomName(retry int) string {
|
func GetRandomName(retry int) string {
|
||||||
begin:
|
begin:
|
||||||
name := fmt.Sprintf("%s_%s", left[rand.Intn(len(left))], right[rand.Intn(len(right))])
|
name := fmt.Sprintf("%s_%s", left[rand.Intn(len(left))], right[rand.Intn(len(right))]) //nolint:gosec // G404: Use of weak random number generator (math/rand instead of crypto/rand)
|
||||||
if name == "boring_wozniak" /* Steve Wozniak is not boring */ {
|
if name == "boring_wozniak" /* Steve Wozniak is not boring */ {
|
||||||
goto begin
|
goto begin
|
||||||
}
|
}
|
||||||
|
|
||||||
if retry > 0 {
|
if retry > 0 {
|
||||||
name = fmt.Sprintf("%s%d", name, rand.Intn(10))
|
name = fmt.Sprintf("%s%d", name, rand.Intn(10)) //nolint:gosec // G404: Use of weak random number generator (math/rand instead of crypto/rand)
|
||||||
}
|
}
|
||||||
return name
|
return name
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ func GenerateRandomAlphaOnlyString(n int) string {
|
||||||
letters := []byte("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
letters := []byte("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
||||||
b := make([]byte, n)
|
b := make([]byte, n)
|
||||||
for i := range b {
|
for i := range b {
|
||||||
b[i] = letters[rand.Intn(len(letters))]
|
b[i] = letters[rand.Intn(len(letters))] //nolint: gosec // G404: Use of weak random number generator (math/rand instead of crypto/rand)
|
||||||
}
|
}
|
||||||
return string(b)
|
return string(b)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue