File tree Expand file tree Collapse file tree 5 files changed +36
-24
lines changed
Expand file tree Collapse file tree 5 files changed +36
-24
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,14 @@ Unreleased
55~~~~~~~~~~~~~~~~~~~~
66
77
8+ 1.3.2 - `2023-02-24 `
9+ ~~~~~~~~~~~~~~~~~~~~
10+ This release contains a fix for a security vulnerability.
11+
12+ 1.3.1 - `2023-02-15 `
13+ ~~~~~~~~~~~~~~~~~~~~
14+ This release contains no changes.
15+
8161.3.0 - `2023-02-13 `
917~~~~~~~~~~~~~~~~~~~~
1018This release contains many dependency updates, and numerous added or improved features over the last year.
Original file line number Diff line number Diff line change 11import os .path
2- import random
2+ import secrets
33import string
44from celery .schedules import crontab
55
1818
1919
2020def get_random_secret (length ):
21- secret_key = '' .join (random .choice (string .ascii_uppercase ) for x in range (round (length / 4 )))
22- secret_key = secret_key + '' .join (random .choice ("~!@#$%^&*()_+" ) for x in range (round (length / 4 )))
23- secret_key = secret_key + '' .join (random .choice (string .ascii_lowercase ) for x in range (round (length / 4 )))
24- return secret_key + '' .join (random .choice (string .digits ) for x in range (round (length / 4 )))
21+ secret_key = '' .join (secrets .choice (string .ascii_uppercase ) for x in range (round (length / 4 )))
22+ secret_key = secret_key + '' .join (secrets .choice ("~!@#$%^&*()_+" ) for x in range (round (length / 4 )))
23+ secret_key = secret_key + '' .join (secrets .choice (string .ascii_lowercase ) for x in range (round (length / 4 )))
24+ return secret_key + '' .join (secrets .choice (string .digits ) for x in range (round (length / 4 )))
2525
2626
2727# This is the secret key used by Flask session management
Original file line number Diff line number Diff line change @@ -143,11 +143,11 @@ Basic Configuration
143143
144144 An example of how you might generate a random string:
145145
146- >>> import random
147- >>> secret_key = ' ' .join(random .choice(string.ascii_uppercase) for x in range (6 ))
148- >>> secret_key = secret_key + ' ' .join(random .choice(" ~!@#$%^&*()_+" ) for x in range (6 ))
149- >>> secret_key = secret_key + ' ' .join(random .choice(string.ascii_lowercase) for x in range (6 ))
150- >>> secret_key = secret_key + ' ' .join(random .choice(string.digits) for x in range (6 ))
146+ >>> import secrets
147+ >>> secret_key = ' ' .join(secrets .choice(string.ascii_uppercase) for x in range (6 ))
148+ >>> secret_key = secret_key + ' ' .join(secrets .choice(" ~!@#$%^&*()_+" ) for x in range (6 ))
149+ >>> secret_key = secret_key + ' ' .join(secrets .choice(string.ascii_lowercase) for x in range (6 ))
150+ >>> secret_key = secret_key + ' ' .join(secrets .choice(string.digits) for x in range (6 ))
151151
152152
153153.. data :: LEMUR_ENCRYPTION_KEYS
Original file line number Diff line number Diff line change 88"""
99import base64
1010import json
11- import random
1211import re
12+ import secrets
1313import socket
1414import ssl
1515import string
@@ -58,19 +58,19 @@ def get_psuedo_random_string():
5858 """
5959 Create a random and strongish challenge.
6060 """
61- challenge = "" .join (random .choice (string .ascii_uppercase ) for x in range (6 )) # noqa
62- challenge += "" .join (random .choice ("~!@#$%^&*()_+" ) for x in range (6 )) # noqa
63- challenge += "" .join (random .choice (string .ascii_lowercase ) for x in range (6 ))
64- challenge += "" .join (random .choice (string .digits ) for x in range (6 )) # noqa
61+ challenge = "" .join (secrets .choice (string .ascii_uppercase ) for x in range (6 )) # noqa
62+ challenge += "" .join (secrets .choice ("~!@#$%^&*()_+" ) for x in range (6 )) # noqa
63+ challenge += "" .join (secrets .choice (string .ascii_lowercase ) for x in range (6 ))
64+ challenge += "" .join (secrets .choice (string .digits ) for x in range (6 )) # noqa
6565 return challenge
6666
6767
6868def get_random_secret (length ):
6969 """ Similar to get_pseudo_random_string, but accepts a length parameter. """
70- secret_key = '' .join (random .choice (string .ascii_uppercase ) for x in range (round (length / 4 )))
71- secret_key = secret_key + '' .join (random .choice ("~!@#$%^&*()_+" ) for x in range (round (length / 4 )))
72- secret_key = secret_key + '' .join (random .choice (string .ascii_lowercase ) for x in range (round (length / 4 )))
73- return secret_key + '' .join (random .choice (string .digits ) for x in range (round (length / 4 )))
70+ secret_key = '' .join (secrets .choice (string .ascii_uppercase ) for x in range (round (length / 4 )))
71+ secret_key = secret_key + '' .join (secrets .choice ("~!@#$%^&*()_+" ) for x in range (round (length / 4 )))
72+ secret_key = secret_key + '' .join (secrets .choice (string .ascii_lowercase ) for x in range (round (length / 4 )))
73+ return secret_key + '' .join (secrets .choice (string .digits ) for x in range (round (length / 4 )))
7474
7575
7676def get_state_token_secret ():
Original file line number Diff line number Diff line change 22
33import base64
44import os
5- import random
5+ import secrets
66import string
77
88_basedir = os .path .abspath (os .path .dirname (__file__ ))
99
1010
1111# generate random secrets for unittest
1212def get_random_secret (length ):
13- secret_key = '' .join (random .choice (string .ascii_uppercase ) for x in range (round (length / 4 )))
14- secret_key = secret_key + '' .join (random .choice ("~!@#$%^&*()_+" ) for x in range (round (length / 4 )))
15- secret_key = secret_key + '' .join (random .choice (string .ascii_lowercase ) for x in range (round (length / 4 )))
16- return secret_key + '' .join (random .choice (string .digits ) for x in range (round (length / 4 )))
13+ secret_key = '' .join (secrets .choice (string .ascii_uppercase ) for x in range (round (length / 4 )))
14+ secret_key = secret_key + '' .join (secrets .choice ("~!@#$%^&*()_+" ) for x in range (round (length / 4 )))
15+ secret_key = secret_key + '' .join (secrets .choice (string .ascii_lowercase ) for x in range (round (length / 4 )))
16+ return secret_key + '' .join (secrets .choice (string .digits ) for x in range (round (length / 4 )))
1717
1818
1919THREADS_PER_PAGE = 8
@@ -26,6 +26,10 @@ def get_random_secret(length):
2626
2727TESTING = True
2828
29+ # All the secrets below must be generated using CRYPTOGRAPHICALLY SECURE RANDOMNESS and kept private
30+ # (ideally they would not be stored directly in this config file).
31+ # See Lemur's documentation for more information on secret management.
32+
2933# this is the secret key used by flask session management (utf8 encoded)
3034SECRET_KEY = get_random_secret (length = 32 ).encode ('utf8' )
3135
You can’t perform that action at this time.
0 commit comments