Get rid of evals

- eval is evil. Get rid of the remaining evals. They were not assessed
  as dangerous but it's matter of policy now.
This commit is contained in:
Peter Šurda 2018-02-18 20:14:21 +01:00
parent 616920e21a
commit 07149c73c8
Signed by untrusted user: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87
2 changed files with 7 additions and 12 deletions

View File

@ -375,10 +375,9 @@ def bmSettings(): #Allows the viewing and modification of keys.dat settings.
main()
def validAddress(address):
address_information = api.decodeAddress(address)
address_information = eval(address_information)
address_information = json.loads(api.decodeAddress(address))
if 'success' in str(address_information.get('status')).lower():
if 'success' in str(address_information['status']).lower():
return True
else:
return False
@ -1346,15 +1345,14 @@ def UI(usrInput): #Main user menu
elif usrInput == "addinfo":
tmp_address = userInput('\nEnter the Bitmessage Address.')
address_information = api.decodeAddress(tmp_address)
address_information = eval(address_information)
address_information = json.loads(api.decodeAddress(tmp_address))
print '\n------------------------------'
if 'success' in str(address_information.get('status')).lower():
if 'success' in str(address_information['status']).lower():
print ' Valid Address'
print ' Address Version: %s' % str(address_information.get('addressVersion'))
print ' Stream Number: %s' % str(address_information.get('streamNumber'))
print ' Address Version: %s' % str(address_information['addressVersion'])
print ' Stream Number: %s' % str(address_information['streamNumber'])
else:
print ' Invalid Address !'

View File

@ -18,10 +18,7 @@ class Inventory():
def __init__(self):
#super(self.__class__, self).__init__()
self._moduleName = BMConfigParser().safeGet("inventory", "storage")
#import_module("." + self._moduleName, "storage")
#import_module("storage." + self._moduleName)
self._className = "storage." + self._moduleName + "." + self._moduleName.title() + "Inventory"
self._inventoryClass = eval(self._className)
self._inventoryClass = getattr(getattr(storage, self._moduleName), "{}Inventory".format(self._moduleName.title()))
self._realInventory = self._inventoryClass()
self.numberOfInventoryLookupsPerformed = 0