2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-25 02:52:07 +00:00

Modify input in bandit-friendly way

bandit erroneously flags 'input' based
on possible python2-ism.  Avoid the
error by using 'getinput', making that
input or raw_input based on the python version.
This commit is contained in:
Jarrod Johnson 2022-02-08 10:59:15 -05:00
parent 6e03f6ee0a
commit e7b1791df3
2 changed files with 8 additions and 8 deletions

View File

@ -42,9 +42,9 @@ _attraliases = {
}
try:
input = raw_input
getinput = raw_input
except NameError:
pass
getinput = input
class NestedDict(dict):
@ -284,9 +284,9 @@ class Command(object):
nodename = list(self.read(
'/noderange/{0}/nodes/'.format(noderange)))[0].get('item', {}).get('href', None)
nodename = nodename[:-1]
p = input('Command is about to affect node {0}, continue (y/n)? '.format(nodename))
p = getinput('Command is about to affect node {0}, continue (y/n)? '.format(nodename))
else:
p = input('Command is about to affect {0} nodes, continue (y/n)? '.format(nsize))
p = getinput('Command is about to affect {0} nodes, continue (y/n)? '.format(nsize))
if p.lower() != 'y':
sys.stderr.write('Aborting at user request\n')
sys.exit(1)
@ -401,7 +401,7 @@ class Command(object):
if fingerprint == khf[hostid]:
return
else:
replace = input(
replace = getinput(
"MISMATCHED CERTIFICATE DATA, ACCEPT NEW? (y/n):")
if replace not in ('y', 'Y'):
raise Exception("BAD CERTIFICATE")

View File

@ -242,10 +242,10 @@ if __name__ == "__main__":
readline.set_pre_input_hook(hook)
if sys.version_info >= (3,):
result = input(prompt)
getinput = input
else:
result = raw_input(prompt)
getinput = raw_input
result = getinput(prompt)
readline.set_pre_input_hook()
return result