Find use of insecure random number generation in Go

Proprietary

Finds Go calls into math/rand and math/rand/v2. These generators are not cryptographically secure and must not be used to produce secrets, tokens, nonces, salts, or any other security-sensitive value. Use crypto/rand instead.

org.openrewrite.golang.security.search.FindInsecureRandom
mod run . --recipe=org.openrewrite.golang.security.search.FindInsecureRandom

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.

Recipe list

It runs these recipes, in this order.

  1. Find method usages math/rand Int(..)
  2. Find method usages math/rand Intn(..)
  3. Find method usages math/rand Int31(..)
  4. Find method usages math/rand Int31n(..)
  5. Find method usages math/rand Int63(..)
  6. Find method usages math/rand Int63n(..)
  7. Find method usages math/rand Uint32(..)
  8. Find method usages math/rand Uint64(..)
  9. Find method usages math/rand Float32(..)
  10. Find method usages math/rand Float64(..)
  11. Find method usages math/rand Read(..)
  12. Find method usages math/rand Perm(..)
  13. Find method usages math/rand Shuffle(..)
  14. Find method usages math/rand/v2 Int(..)
  15. Find method usages math/rand/v2 IntN(..)
  16. Find method usages math/rand/v2 Int32(..)
  17. Find method usages math/rand/v2 Int32N(..)
  18. Find method usages math/rand/v2 Int64(..)
  19. Find method usages math/rand/v2 Int64N(..)
  20. Find method usages math/rand/v2 Uint32(..)
  21. Find method usages math/rand/v2 Uint64(..)
  22. Find method usages math/rand/v2 Float32(..)
  23. Find method usages math/rand/v2 Float64(..)