More messagetypes hardening
- only load modules at program start
This commit is contained in:
parent
757740369b
commit
fde194f9b0
|
@ -3,6 +3,7 @@ from os import path, listdir
|
|||
from string import lower
|
||||
|
||||
from debug import logger
|
||||
import messagetypes
|
||||
import paths
|
||||
|
||||
class MsgBase(object):
|
||||
|
@ -15,9 +16,8 @@ def constructObject(data):
|
|||
if data[""] not in whitelist:
|
||||
return None
|
||||
try:
|
||||
m = import_module("messagetypes." + data[""])
|
||||
classBase = getattr(m, data[""].title())
|
||||
except (NameError, ImportError):
|
||||
classBase = getattr(getattr(messagetypes, data[""]), data[""].title())
|
||||
except (NameError, AttributeError):
|
||||
logger.error("Don't know how to handle message type: \"%s\"", data[""], exc_info=True)
|
||||
return None
|
||||
try:
|
||||
|
@ -43,7 +43,7 @@ else:
|
|||
if splitted[1] != ".py":
|
||||
continue
|
||||
try:
|
||||
import_module("." + splitted[0], "messagetypes")
|
||||
import_module(".{}".format(splitted[0]), "messagetypes")
|
||||
except ImportError:
|
||||
logger.error("Error importing %s", mod, exc_info=True)
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue
Block a user