mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Sanitise input for the keys and IDs
This commit is contained in:
parent
86623f913d
commit
91ed307af9
1 changed files with 5 additions and 0 deletions
|
@ -37,6 +37,8 @@ import logging
|
|||
from salt.key import get_key
|
||||
import salt.crypt
|
||||
import salt.utils
|
||||
from salt.utils.sanitisers import clean
|
||||
|
||||
|
||||
__func_alias__ = {
|
||||
'list_': 'list',
|
||||
|
@ -318,6 +320,8 @@ def gen(id_=None, keysize=2048):
|
|||
'''
|
||||
if id_ is None:
|
||||
id_ = hashlib.sha512(os.urandom(32)).hexdigest()
|
||||
else:
|
||||
id_ = clean.filename(id_)
|
||||
ret = {'priv': '',
|
||||
'pub': ''}
|
||||
priv = salt.crypt.gen_keys(__opts__['pki_dir'], id_, keysize)
|
||||
|
@ -371,6 +375,7 @@ def gen_accept(id_, keysize=2048, force=False):
|
|||
>>> wheel.cmd('key.list', ['accepted'])
|
||||
{'minions': ['foo', 'minion1', 'minion2', 'minion3']}
|
||||
'''
|
||||
id_ = clean.id(id_)
|
||||
ret = gen(id_, keysize)
|
||||
acc_path = os.path.join(__opts__['pki_dir'], 'minions', id_)
|
||||
if os.path.isfile(acc_path) and not force:
|
||||
|
|
Loading…
Add table
Reference in a new issue