Ticket #9687: more_randomness_in_secret_key.patch
File more_randomness_in_secret_key.patch, 851 bytes (added by , 16 years ago) |
---|
-
core/management/commands/startproject.py
32 32 main_settings_file = os.path.join(directory, project_name, 'settings.py') 33 33 settings_contents = open(main_settings_file, 'r').read() 34 34 fp = open(main_settings_file, 'w') 35 secret_key = ''.join([choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(50)]) 35 charset = [chr(i) for i in range(32,38) + range(40,127)] 36 secret_key = ''.join([choice(charset) for i in range(50)]) 36 37 settings_contents = re.sub(r"(?<=SECRET_KEY = ')'", secret_key + "'", settings_contents) 37 38 fp.write(settings_contents) 38 39 fp.close()