Parcourir la source

Fixes #1092: Increase randomness in SECRET_KEY generation tool

Jeremy Stretch il y a 8 ans
Parent
commit
38d826d152
1 fichiers modifiés avec 2 ajouts et 3 suppressions
  1. 2 3
      netbox/generate_secret_key.py

+ 2 - 3
netbox/generate_secret_key.py

@@ -1,8 +1,7 @@
 #!/usr/bin/env python
 # This script will generate a random 50-character string suitable for use as a SECRET_KEY.
-import os
 import random
 
 charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*(-_=+)'
-random.seed = (os.urandom(2048))
-print(''.join(random.choice(charset) for c in range(50)))
+secure_random = random.SystemRandom()
+print(''.join(secure_random.sample(charset, 50)))