mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Merge pull request #15841 from thatch45/random_audit
Add some calls to systemrandom where it might be good to have a
This commit is contained in:
commit
9849bf3dee
@ -93,7 +93,7 @@ class LoadAuth(object):
|
|||||||
if f_time > self.max_fail:
|
if f_time > self.max_fail:
|
||||||
self.max_fail = f_time
|
self.max_fail = f_time
|
||||||
deviation = self.max_fail / 4
|
deviation = self.max_fail / 4
|
||||||
r_time = random.uniform(
|
r_time = random.SystemRandom().uniform(
|
||||||
self.max_fail - deviation,
|
self.max_fail - deviation,
|
||||||
self.max_fail + deviation
|
self.max_fail + deviation
|
||||||
)
|
)
|
||||||
|
@ -486,7 +486,7 @@ def get_or_set_hash(name,
|
|||||||
ret = get(name, None)
|
ret = get(name, None)
|
||||||
|
|
||||||
if ret is None:
|
if ret is None:
|
||||||
val = ''.join([random.choice(chars) for _ in range(length)])
|
val = ''.join([random.SystemRandom().choice(chars) for _ in range(length)])
|
||||||
|
|
||||||
if ':' in name:
|
if ':' in name:
|
||||||
name, rest = name.split(':', 1)
|
name, rest = name.split(':', 1)
|
||||||
|
@ -116,7 +116,7 @@ def add(name,
|
|||||||
# Set random password, since without a password the account will not be
|
# Set random password, since without a password the account will not be
|
||||||
# available. TODO: add shadow module
|
# available. TODO: add shadow module
|
||||||
randpass = ''.join(
|
randpass = ''.join(
|
||||||
random.choice(string.letters + string.digits) for x in xrange(20)
|
random.SystemRandom().choice(string.letters + string.digits) for x in xrange(20)
|
||||||
)
|
)
|
||||||
_dscl('/Users/{0} {1!r}'.format(name, randpass), ctype='passwd')
|
_dscl('/Users/{0} {1!r}'.format(name, randpass), ctype='passwd')
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ def add_user(name, password=None, runas=None):
|
|||||||
if password is None:
|
if password is None:
|
||||||
# Generate a random, temporary password. RabbitMQ requires one.
|
# Generate a random, temporary password. RabbitMQ requires one.
|
||||||
clear_pw = True
|
clear_pw = True
|
||||||
password = ''.join(random.choice(
|
password = ''.join(random.SystemRandom().choice(
|
||||||
string.ascii_uppercase + string.digits) for x in range(15))
|
string.ascii_uppercase + string.digits) for x in range(15))
|
||||||
|
|
||||||
res = __salt__['cmd.run'](
|
res = __salt__['cmd.run'](
|
||||||
|
@ -404,7 +404,7 @@ def rand_str(size=9999999999):
|
|||||||
salt '*' test.rand_str
|
salt '*' test.rand_str
|
||||||
'''
|
'''
|
||||||
hasher = getattr(hashlib, __opts__.get('hash_type', 'md5'))
|
hasher = getattr(hashlib, __opts__.get('hash_type', 'md5'))
|
||||||
return hasher(str(random.randint(0, size))).hexdigest()
|
return hasher(str(random.SystemRandom().randint(0, size))).hexdigest()
|
||||||
|
|
||||||
|
|
||||||
def exception(message='Test Exception'):
|
def exception(message='Test Exception'):
|
||||||
|
@ -46,7 +46,7 @@ def _makepass(password, hasher='sha256'):
|
|||||||
"0123456789!?.,:;/*-+_()"
|
"0123456789!?.,:;/*-+_()"
|
||||||
r = {
|
r = {
|
||||||
'Method': h.name,
|
'Method': h.name,
|
||||||
'Salt': ''.join(random.choice(c) for x in xrange(20)),
|
'Salt': ''.join(random.SystemRandom().choice(c) for x in xrange(20)),
|
||||||
}
|
}
|
||||||
|
|
||||||
# Salt the password hash
|
# Salt the password hash
|
||||||
|
@ -79,7 +79,7 @@ def gen(id_=None, keysize=2048):
|
|||||||
returned as a dict containing pub and priv keys
|
returned as a dict containing pub and priv keys
|
||||||
'''
|
'''
|
||||||
if id_ is None:
|
if id_ is None:
|
||||||
id_ = hashlib.sha512(str(random.randint(0, 99999999))).hexdigest()
|
id_ = hashlib.sha512(str(random.SystemRandom().randint(0, 99999999))).hexdigest()
|
||||||
ret = {'priv': '',
|
ret = {'priv': '',
|
||||||
'pub': ''}
|
'pub': ''}
|
||||||
priv = salt.crypt.gen_keys(__opts__['pki_dir'], id_, keysize)
|
priv = salt.crypt.gen_keys(__opts__['pki_dir'], id_, keysize)
|
||||||
|
Loading…
Reference in New Issue
Block a user