summaryrefslogtreecommitdiff
path: root/cloudinit/util.py
diff options
context:
space:
mode:
authorDimitri John Ledkov <xnox@ubuntu.com>2020-02-18 17:03:24 +0000
committerGitHub <noreply@github.com>2020-02-18 12:03:24 -0500
commit3e2f7356effc9e9cccc5ae945846279804eedc46 (patch)
tree446560050e9ca8b31faff82cf55d8d24e38ebd4c /cloudinit/util.py
parentc90932f5cb68e789636c5e6b0b74fceb1d38c6a4 (diff)
downloadvyos-cloud-init-3e2f7356effc9e9cccc5ae945846279804eedc46.tar.gz
vyos-cloud-init-3e2f7356effc9e9cccc5ae945846279804eedc46.zip
utils: use SystemRandom when generating random password. (#204)
As noticed by Seth Arnold, non-deterministic SystemRandom should be used when creating security sensitive random strings.
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r--cloudinit/util.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py
index d99e82fa..c02b3d9a 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -397,9 +397,10 @@ def translate_bool(val, addons=None):
def rand_str(strlen=32, select_from=None):
+ r = random.SystemRandom()
if not select_from:
select_from = string.ascii_letters + string.digits
- return "".join([random.choice(select_from) for _x in range(0, strlen)])
+ return "".join([r.choice(select_from) for _x in range(0, strlen)])
def rand_dict_key(dictionary, postfix=None):