From 3ac1283900cff14863e83b4c524dcbbf6373b4b0 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Tue, 4 Jun 2019 12:15:39 +0200 Subject: [PATCH] Further pleasing pylint deity --- lib/controller/controller.py | 2 ++ lib/core/common.py | 21 +++++++++++++-------- lib/core/compat.py | 2 ++ lib/core/option.py | 4 +++- lib/core/settings.py | 2 +- lib/core/subprocessng.py | 9 +++++---- lib/core/testing.py | 2 ++ lib/request/comparison.py | 2 ++ lib/takeover/metasploit.py | 2 +- lib/techniques/blind/inference.py | 6 ++++-- lib/utils/brute.py | 2 ++ lib/utils/crawler.py | 2 ++ lib/utils/progress.py | 2 ++ 13 files changed, 41 insertions(+), 17 deletions(-) diff --git a/lib/controller/controller.py b/lib/controller/controller.py index 0e260720e..95620b801 100644 --- a/lib/controller/controller.py +++ b/lib/controller/controller.py @@ -5,6 +5,8 @@ Copyright (c) 2006-2019 sqlmap developers (http://sqlmap.org/) See the file 'LICENSE' for copying permission """ +from __future__ import division + import os import re import time diff --git a/lib/core/common.py b/lib/core/common.py index 785e1bf3f..bfd1aa209 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -5,6 +5,8 @@ Copyright (c) 2006-2019 sqlmap developers (http://sqlmap.org/) See the file 'LICENSE' for copying permission """ +from __future__ import division + import binascii import codecs import collections @@ -2530,7 +2532,7 @@ def pushValue(value): Push value to the stack (thread dependent) """ - _ = None + exception = None success = False for i in xrange(PUSH_VALUE_EXCEPTION_RETRY_COUNT): @@ -2539,13 +2541,13 @@ def pushValue(value): success = True break except Exception as ex: - _ = ex + exception = ex if not success: getCurrentThreadData().valueStack.append(None) - if _: - raise _ + if exception: + raise exception def popValue(): """ @@ -5045,6 +5047,8 @@ def getSafeExString(ex, encoding=None): >>> getSafeExString(SqlmapBaseException('foobar')) == 'foobar' True + >>> getSafeExString(OSError(0, 'foobar')) == 'OSError: foobar' + True """ retVal = None @@ -5053,10 +5057,11 @@ def getSafeExString(ex, encoding=None): retVal = ex.message elif getattr(ex, "msg", None): retVal = ex.msg - elif isinstance(ex, (list, tuple)) and len(ex) > 1 and isinstance(ex[1], six.string_types): - retVal = ex[1] - elif isinstance(ex, (list, tuple)) and len(ex) > 0 and isinstance(ex[0], six.string_types): - retVal = ex[0] + elif getattr(ex, "args", None): + for candidate in ex.args[::-1]: + if isinstance(candidate, six.string_types): + retVal = candidate + break if retVal is None: retVal = str(ex) diff --git a/lib/core/compat.py b/lib/core/compat.py index 436700749..3dbdd7084 100644 --- a/lib/core/compat.py +++ b/lib/core/compat.py @@ -5,6 +5,8 @@ Copyright (c) 2006-2019 sqlmap developers (http://sqlmap.org/) See the file 'LICENSE' for copying permission """ +from __future__ import division + import binascii import functools import math diff --git a/lib/core/option.py b/lib/core/option.py index b55574e04..08e1494b3 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -5,6 +5,8 @@ Copyright (c) 2006-2019 sqlmap developers (http://sqlmap.org/) See the file 'LICENSE' for copying permission """ +from __future__ import division + import functools import glob import inspect @@ -1885,7 +1887,7 @@ def _setKnowledgeBaseAttributes(flushAll=True): kb.heuristicMode = False kb.heuristicPage = False kb.heuristicTest = None - kb.hintValue = None + kb.hintValue = "" kb.htmlFp = [] kb.httpErrorCodes = {} kb.inferenceMode = False diff --git a/lib/core/settings.py b/lib/core/settings.py index 1c4737330..61c2ff72f 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -18,7 +18,7 @@ from lib.core.enums import OS from thirdparty.six import unichr as _unichr # sqlmap version (...) -VERSION = "1.3.6.9" +VERSION = "1.3.6.10" 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) diff --git a/lib/core/subprocessng.py b/lib/core/subprocessng.py index fa77fbbde..47ad47156 100644 --- a/lib/core/subprocessng.py +++ b/lib/core/subprocessng.py @@ -5,6 +5,8 @@ Copyright (c) 2006-2019 sqlmap developers (http://sqlmap.org/) See the file 'LICENSE' for copying permission """ +from __future__ import division + import errno import os import subprocess @@ -12,7 +14,6 @@ import time from lib.core.compat import buffer from lib.core.settings import IS_WIN -from thirdparty import six if IS_WIN: try: @@ -98,7 +99,7 @@ class Popen(subprocess.Popen): except ValueError: return self._close('stdin') except (subprocess.pywintypes.error, Exception) as ex: - if (ex[0] if six.PY2 else ex.errno) in (109, errno.ESHUTDOWN): + if ex.args[0] in (109, errno.ESHUTDOWN): return self._close('stdin') raise @@ -119,7 +120,7 @@ class Popen(subprocess.Popen): except (ValueError, NameError): return self._close(which) except (subprocess.pywintypes.error, Exception) as ex: - if (ex[0] if six.PY2 else ex.errno) in (109, errno.ESHUTDOWN): + if ex.args[0] in (109, errno.ESHUTDOWN): return self._close(which) raise @@ -137,7 +138,7 @@ class Popen(subprocess.Popen): try: written = os.write(self.stdin.fileno(), input) except OSError as ex: - if (ex[0] if six.PY2 else ex.errno) == errno.EPIPE: # broken pipe + if ex.args[0] == errno.EPIPE: # broken pipe return self._close('stdin') raise diff --git a/lib/core/testing.py b/lib/core/testing.py index 14d4de5c4..20f6e53e0 100644 --- a/lib/core/testing.py +++ b/lib/core/testing.py @@ -5,6 +5,8 @@ Copyright (c) 2006-2019 sqlmap developers (http://sqlmap.org/) See the file 'LICENSE' for copying permission """ +from __future__ import division + import codecs import doctest import logging diff --git a/lib/request/comparison.py b/lib/request/comparison.py index 6d0de9eba..19157212e 100644 --- a/lib/request/comparison.py +++ b/lib/request/comparison.py @@ -5,6 +5,8 @@ Copyright (c) 2006-2019 sqlmap developers (http://sqlmap.org/) See the file 'LICENSE' for copying permission """ +from __future__ import division + import re from lib.core.common import extractRegexResult diff --git a/lib/takeover/metasploit.py b/lib/takeover/metasploit.py index 2cc04f2c5..728be7219 100644 --- a/lib/takeover/metasploit.py +++ b/lib/takeover/metasploit.py @@ -598,7 +598,7 @@ class Metasploit(object): except select.error as ex: # Reference: https://github.com/andymccurdy/redis-py/pull/743/commits/2b59b25bb08ea09e98aede1b1f23a270fc085a9f - if (ex[0] if six.PY2 else ex.errno) == errno.EINTR: + if ex.args[0] == errno.EINTR: continue else: return proc.returncode diff --git a/lib/techniques/blind/inference.py b/lib/techniques/blind/inference.py index 8f132b548..c57f9083a 100644 --- a/lib/techniques/blind/inference.py +++ b/lib/techniques/blind/inference.py @@ -5,6 +5,8 @@ Copyright (c) 2006-2019 sqlmap developers (http://sqlmap.org/) See the file 'LICENSE' for copying permission """ +from __future__ import division + import re import threading import time @@ -196,7 +198,7 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None with hintlock: hintValue = kb.hintValue - if payload is not None and hintValue is not None and len(hintValue) >= idx: + if payload is not None and len(hintValue or "") > 0 and len(hintValue) >= idx: if Backend.getIdentifiedDbms() in (DBMS.SQLITE, DBMS.ACCESS, DBMS.MAXDB, DBMS.DB2): posValue = hintValue[idx - 1] else: @@ -213,7 +215,7 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None return hintValue[idx - 1] with hintlock: - kb.hintValue = None + kb.hintValue = "" return None diff --git a/lib/utils/brute.py b/lib/utils/brute.py index ff4e7c17b..1334374b0 100644 --- a/lib/utils/brute.py +++ b/lib/utils/brute.py @@ -5,6 +5,8 @@ Copyright (c) 2006-2019 sqlmap developers (http://sqlmap.org/) See the file 'LICENSE' for copying permission """ +from __future__ import division + import time from lib.core.common import clearConsoleLine diff --git a/lib/utils/crawler.py b/lib/utils/crawler.py index f1ace276b..43f2bd1ed 100644 --- a/lib/utils/crawler.py +++ b/lib/utils/crawler.py @@ -5,6 +5,8 @@ Copyright (c) 2006-2019 sqlmap developers (http://sqlmap.org/) See the file 'LICENSE' for copying permission """ +from __future__ import division + import os import re import tempfile diff --git a/lib/utils/progress.py b/lib/utils/progress.py index d33c71448..cc509c3db 100644 --- a/lib/utils/progress.py +++ b/lib/utils/progress.py @@ -5,6 +5,8 @@ Copyright (c) 2006-2019 sqlmap developers (http://sqlmap.org/) See the file 'LICENSE' for copying permission """ +from __future__ import division + import time from lib.core.common import dataToStdout