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
5
5
~~~~~~~~~~~~~~~~~~~~
6
6
7
7
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
+
8
16
1.3.0 - `2023-02-13 `
9
17
~~~~~~~~~~~~~~~~~~~~
10
18
This 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 1
1
import os .path
2
- import random
2
+ import secrets
3
3
import string
4
4
from celery .schedules import crontab
5
5
18
18
19
19
20
20
def 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 )))
25
25
26
26
27
27
# 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
143
143
144
144
An example of how you might generate a random string:
145
145
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 ))
151
151
152
152
153
153
.. data :: LEMUR_ENCRYPTION_KEYS
Original file line number Diff line number Diff line change 8
8
"""
9
9
import base64
10
10
import json
11
- import random
12
11
import re
12
+ import secrets
13
13
import socket
14
14
import ssl
15
15
import string
@@ -58,19 +58,19 @@ def get_psuedo_random_string():
58
58
"""
59
59
Create a random and strongish challenge.
60
60
"""
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
65
65
return challenge
66
66
67
67
68
68
def get_random_secret (length ):
69
69
""" 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 )))
74
74
75
75
76
76
def get_state_token_secret ():
Original file line number Diff line number Diff line change 2
2
3
3
import base64
4
4
import os
5
- import random
5
+ import secrets
6
6
import string
7
7
8
8
_basedir = os .path .abspath (os .path .dirname (__file__ ))
9
9
10
10
11
11
# generate random secrets for unittest
12
12
def 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 )))
17
17
18
18
19
19
THREADS_PER_PAGE = 8
@@ -26,6 +26,10 @@ def get_random_secret(length):
26
26
27
27
TESTING = True
28
28
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
+
29
33
# this is the secret key used by flask session management (utf8 encoded)
30
34
SECRET_KEY = get_random_secret (length = 32 ).encode ('utf8' )
31
35
You can’t perform that action at this time.
0 commit comments