Better exception messages (including types)

This commit is contained in:
Miroslav Stampar
2019-02-12 10:42:32 +01:00
parent 27265f56ba
commit ba883b77df
4 changed files with 14 additions and 6 deletions

View File

@@ -84,6 +84,7 @@ from lib.core.enums import PLACE
from lib.core.enums import PAYLOAD
from lib.core.enums import REFLECTIVE_COUNTER
from lib.core.enums import SORT_ORDER
from lib.core.exception import SqlmapBaseException
from lib.core.exception import SqlmapDataException
from lib.core.exception import SqlmapGenericException
from lib.core.exception import SqlmapNoneDataException
@@ -4784,6 +4785,8 @@ def getSafeExString(ex, encoding=None):
u'foobar'
"""
retVal = None
if getattr(ex, "message", None):
retVal = ex.message
elif getattr(ex, "msg", None):
@@ -4792,8 +4795,11 @@ def getSafeExString(ex, encoding=None):
retVal = ex[1]
elif isinstance(ex, (list, tuple)) and len(ex) > 0 and isinstance(ex[0], basestring):
retVal = ex[0]
else:
if retVal is None:
retVal = str(ex)
elif not isinstance(ex, SqlmapBaseException):
retVal = "%s: %s" % (type(ex).__name__, retVal)
return getUnicode(retVal or "", encoding=encoding).strip()

View File

@@ -19,7 +19,7 @@ from lib.core.enums import DBMS_DIRECTORY_NAME
from lib.core.enums import OS
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
VERSION = "1.3.2.18"
VERSION = "1.3.2.19"
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

View File

@@ -18,6 +18,7 @@ from lib.core.data import kb
from lib.core.data import logger
from lib.core.datatype import AttribDict
from lib.core.enums import PAYLOAD
from lib.core.exception import SqlmapBaseException
from lib.core.exception import SqlmapConnectionException
from lib.core.exception import SqlmapThreadException
from lib.core.exception import SqlmapUserQuitException
@@ -95,7 +96,8 @@ def exceptionHandledFunction(threadFunction, silent=False):
raise
except Exception as ex:
if not silent and kb.get("threadContinue"):
logger.error("thread %s: %s" % (threading.currentThread().getName(), ex.message))
errMsg = ex.message if isinstance(ex, SqlmapBaseException) else "%s: %s" % (type(ex).__name__, ex.message)
logger.error("thread %s: '%s'" % (threading.currentThread().getName(), errMsg))
if conf.get("verbose") > 1:
traceback.print_exc()