Use secure random number generation

Proprietary

Replaces Next, Next(max), Next(min, max) and NextBytes calls on unseeded System.Random instances with the cryptographically secure RandomNumberGenerator.GetInt32 and RandomNumberGenerator.Fill. System.Random is predictable and must not produce tokens, passwords, keys, salts or nonces. Seeded instances, instances that are passed in from elsewhere, and members without a RandomNumberGenerator equivalent (NextDouble, NextInt64, Shuffle, ...) are left unchanged. RandomNumberGenerator.GetInt32 rejects an empty range where Random.Next returns the lower bound.

OpenRewrite.Recipes.CSharp.Security.UseSecureRandom
mod run . --recipe=OpenRewrite.Recipes.CSharp.Security.UseSecureRandom

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