mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-25 02:53:46 +03:00
Further pleasing the pylint gods
This commit is contained in:
parent
1f7ee039ad
commit
f8e9f9c87d
|
@ -70,7 +70,6 @@ enable=import-error,
|
||||||
unused-wildcard-import,
|
unused-wildcard-import,
|
||||||
global-variable-not-assigned,
|
global-variable-not-assigned,
|
||||||
undefined-loop-variable,
|
undefined-loop-variable,
|
||||||
global-statement,
|
|
||||||
global-at-module-level,
|
global-at-module-level,
|
||||||
bad-open-mode,
|
bad-open-mode,
|
||||||
redundant-unittest-assert,
|
redundant-unittest-assert,
|
||||||
|
|
|
@ -561,7 +561,7 @@ def checkSqlInjection(place, parameter, value):
|
||||||
candidates = trueSet - falseSet - errorSet
|
candidates = trueSet - falseSet - errorSet
|
||||||
|
|
||||||
if candidates:
|
if candidates:
|
||||||
candidates = sorted(candidates, key=lambda _: len(_))
|
candidates = sorted(candidates, key=len)
|
||||||
for candidate in candidates:
|
for candidate in candidates:
|
||||||
if re.match(r"\A[\w.,! ]+\Z", candidate) and ' ' in candidate and candidate.strip() and len(candidate) > CANDIDATE_SENTENCE_MIN_LENGTH:
|
if re.match(r"\A[\w.,! ]+\Z", candidate) and ' ' in candidate and candidate.strip() and len(candidate) > CANDIDATE_SENTENCE_MIN_LENGTH:
|
||||||
conf.string = candidate
|
conf.string = candidate
|
||||||
|
@ -595,7 +595,7 @@ def checkSqlInjection(place, parameter, value):
|
||||||
candidates = filterNone(_.strip() if _.strip() in trueRawResponse and _.strip() not in falseRawResponse else None for _ in (trueSet - falseSet - errorSet))
|
candidates = filterNone(_.strip() if _.strip() in trueRawResponse and _.strip() not in falseRawResponse else None for _ in (trueSet - falseSet - errorSet))
|
||||||
|
|
||||||
if candidates:
|
if candidates:
|
||||||
candidates = sorted(candidates, key=lambda _: len(_))
|
candidates = sorted(candidates, key=len)
|
||||||
for candidate in candidates:
|
for candidate in candidates:
|
||||||
if re.match(r"\A\w+\Z", candidate):
|
if re.match(r"\A\w+\Z", candidate):
|
||||||
break
|
break
|
||||||
|
@ -609,7 +609,7 @@ def checkSqlInjection(place, parameter, value):
|
||||||
candidates = filterNone(_.strip() if _.strip() in falseRawResponse and _.strip() not in trueRawResponse else None for _ in (falseSet - trueSet))
|
candidates = filterNone(_.strip() if _.strip() in falseRawResponse and _.strip() not in trueRawResponse else None for _ in (falseSet - trueSet))
|
||||||
|
|
||||||
if candidates:
|
if candidates:
|
||||||
candidates = sorted(candidates, key=lambda _: len(_))
|
candidates = sorted(candidates, key=len)
|
||||||
for candidate in candidates:
|
for candidate in candidates:
|
||||||
if re.match(r"\A\w+\Z", candidate):
|
if re.match(r"\A\w+\Z", candidate):
|
||||||
break
|
break
|
||||||
|
|
|
@ -53,7 +53,7 @@ class BigArray(list):
|
||||||
List-like class used for storing large amounts of data (disk cached)
|
List-like class used for storing large amounts of data (disk cached)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, items=[]):
|
def __init__(self, items=None):
|
||||||
self.chunks = [[]]
|
self.chunks = [[]]
|
||||||
self.chunk_length = sys.maxsize
|
self.chunk_length = sys.maxsize
|
||||||
self.cache = None
|
self.cache = None
|
||||||
|
@ -61,7 +61,7 @@ class BigArray(list):
|
||||||
self._os_remove = os.remove
|
self._os_remove = os.remove
|
||||||
self._size_counter = 0
|
self._size_counter = 0
|
||||||
|
|
||||||
for item in items:
|
for item in (items or []):
|
||||||
self.append(item)
|
self.append(item)
|
||||||
|
|
||||||
def append(self, value):
|
def append(self, value):
|
||||||
|
@ -139,12 +139,6 @@ class BigArray(list):
|
||||||
self.__init__()
|
self.__init__()
|
||||||
self.chunks, self.filenames = state
|
self.chunks, self.filenames = state
|
||||||
|
|
||||||
def __getslice__(self, i, j):
|
|
||||||
i = max(0, len(self) + i if i < 0 else i)
|
|
||||||
j = min(len(self), len(self) + j if j < 0 else j)
|
|
||||||
|
|
||||||
return BigArray(self[_] for _ in xrange(i, j))
|
|
||||||
|
|
||||||
def __getitem__(self, y):
|
def __getitem__(self, y):
|
||||||
if y < 0:
|
if y < 0:
|
||||||
y += len(self)
|
y += len(self)
|
||||||
|
|
|
@ -2328,8 +2328,7 @@ def initCommonOutputs():
|
||||||
kb.commonOutputs = {}
|
kb.commonOutputs = {}
|
||||||
key = None
|
key = None
|
||||||
|
|
||||||
with openFile(paths.COMMON_OUTPUTS, 'r') as f:
|
for line in openFile(paths.COMMON_OUTPUTS, 'r'):
|
||||||
for line in f:
|
|
||||||
if line.find('#') != -1:
|
if line.find('#') != -1:
|
||||||
line = line[:line.find('#')]
|
line = line[:line.find('#')]
|
||||||
|
|
||||||
|
@ -3921,7 +3920,7 @@ def normalizeUnicode(value, charset=string.printable[:string.printable.find(' ')
|
||||||
|
|
||||||
# Reference: http://www.peterbe.com/plog/unicode-to-ascii
|
# Reference: http://www.peterbe.com/plog/unicode-to-ascii
|
||||||
|
|
||||||
>>> normalizeUnicode(u'\u0161u\u0107uraj') == u'sucuraj'
|
>>> normalizeUnicode(u'\\u0161u\\u0107uraj') == u'sucuraj'
|
||||||
True
|
True
|
||||||
>>> normalizeUnicode(getUnicode(decodeHex("666f6f00626172"))) == u'foobar'
|
>>> normalizeUnicode(getUnicode(decodeHex("666f6f00626172"))) == u'foobar'
|
||||||
True
|
True
|
||||||
|
@ -4096,7 +4095,7 @@ def expandMnemonics(mnemonics, parser, args):
|
||||||
debugMsg = "mnemonic '%s' resolved to %s). " % (name, found)
|
debugMsg = "mnemonic '%s' resolved to %s). " % (name, found)
|
||||||
logger.debug(debugMsg)
|
logger.debug(debugMsg)
|
||||||
else:
|
else:
|
||||||
found = sorted(options.keys(), key=lambda x: len(x))[0]
|
found = sorted(options.keys(), key=len)[0]
|
||||||
warnMsg = "detected ambiguity (mnemonic '%s' can be resolved to any of: %s). " % (name, ", ".join("'%s'" % key for key in options))
|
warnMsg = "detected ambiguity (mnemonic '%s' can be resolved to any of: %s). " % (name, ", ".join("'%s'" % key for key in options))
|
||||||
warnMsg += "Resolved to shortest of those ('%s')" % found
|
warnMsg += "Resolved to shortest of those ('%s')" % found
|
||||||
logger.warn(warnMsg)
|
logger.warn(warnMsg)
|
||||||
|
@ -5043,7 +5042,6 @@ def parseRequestFile(reqFile, checkParams=True):
|
||||||
def getSafeExString(ex, encoding=None):
|
def getSafeExString(ex, encoding=None):
|
||||||
"""
|
"""
|
||||||
Safe way how to get the proper exception represtation as a string
|
Safe way how to get the proper exception represtation as a string
|
||||||
(Note: errors to be avoided: 1) "%s" % Exception(u'\u0161') and 2) "%s" % str(Exception(u'\u0161'))
|
|
||||||
|
|
||||||
>>> getSafeExString(SqlmapBaseException('foobar')) == 'foobar'
|
>>> getSafeExString(SqlmapBaseException('foobar')) == 'foobar'
|
||||||
True
|
True
|
||||||
|
|
|
@ -184,15 +184,15 @@ class OrderedSet(collections.MutableSet):
|
||||||
def __contains__(self, key):
|
def __contains__(self, key):
|
||||||
return key in self.map
|
return key in self.map
|
||||||
|
|
||||||
def add(self, key):
|
def add(self, value):
|
||||||
if key not in self.map:
|
if value not in self.map:
|
||||||
end = self.end
|
end = self.end
|
||||||
curr = end[1]
|
curr = end[1]
|
||||||
curr[2] = end[1] = self.map[key] = [key, curr, end]
|
curr[2] = end[1] = self.map[value] = [value, curr, end]
|
||||||
|
|
||||||
def discard(self, key):
|
def discard(self, value):
|
||||||
if key in self.map:
|
if value in self.map:
|
||||||
key, prev, next = self.map.pop(key)
|
value, prev, next = self.map.pop(value)
|
||||||
prev[2] = next
|
prev[2] = next
|
||||||
next[1] = prev
|
next[1] = prev
|
||||||
|
|
||||||
|
|
|
@ -468,7 +468,6 @@ class Dump(object):
|
||||||
shutil.copyfile(dumpFileName, candidate)
|
shutil.copyfile(dumpFileName, candidate)
|
||||||
except IOError:
|
except IOError:
|
||||||
pass
|
pass
|
||||||
finally:
|
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
count += 1
|
count += 1
|
||||||
|
|
|
@ -838,6 +838,7 @@ def _setPreprocessFunctions():
|
||||||
if conf.preprocess:
|
if conf.preprocess:
|
||||||
for script in re.split(PARAMETER_SPLITTING_REGEX, conf.preprocess):
|
for script in re.split(PARAMETER_SPLITTING_REGEX, conf.preprocess):
|
||||||
found = False
|
found = False
|
||||||
|
function = None
|
||||||
|
|
||||||
script = safeFilepathEncode(script.strip())
|
script = safeFilepathEncode(script.strip())
|
||||||
|
|
||||||
|
|
|
@ -79,9 +79,9 @@ class Replication(object):
|
||||||
errMsg = "wrong number of columns used in replicating insert"
|
errMsg = "wrong number of columns used in replicating insert"
|
||||||
raise SqlmapValueException(errMsg)
|
raise SqlmapValueException(errMsg)
|
||||||
|
|
||||||
def execute(self, sql, parameters=[]):
|
def execute(self, sql, parameters=None):
|
||||||
try:
|
try:
|
||||||
self.parent.cursor.execute(sql, parameters)
|
self.parent.cursor.execute(sql, parameters or [])
|
||||||
except sqlite3.OperationalError as ex:
|
except sqlite3.OperationalError as ex:
|
||||||
errMsg = "problem occurred ('%s') while accessing sqlite database " % getSafeExString(ex, UNICODE_ENCODING)
|
errMsg = "problem occurred ('%s') while accessing sqlite database " % getSafeExString(ex, UNICODE_ENCODING)
|
||||||
errMsg += "located at '%s'. Please make sure that " % self.parent.dbpath
|
errMsg += "located at '%s'. Please make sure that " % self.parent.dbpath
|
||||||
|
|
|
@ -18,7 +18,7 @@ from lib.core.enums import OS
|
||||||
from thirdparty.six import unichr as _unichr
|
from thirdparty.six import unichr as _unichr
|
||||||
|
|
||||||
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
|
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
|
||||||
VERSION = "1.3.5.154"
|
VERSION = "1.3.5.155"
|
||||||
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
|
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
|
||||||
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
|
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)
|
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)
|
||||||
|
|
|
@ -53,11 +53,11 @@ class MSSQLBannerHandler(ContentHandler):
|
||||||
elif name == "servicepack":
|
elif name == "servicepack":
|
||||||
self._inServicePack = True
|
self._inServicePack = True
|
||||||
|
|
||||||
def characters(self, data):
|
def characters(self, content):
|
||||||
if self._inVersion:
|
if self._inVersion:
|
||||||
self._version += sanitizeStr(data)
|
self._version += sanitizeStr(content)
|
||||||
elif self._inServicePack:
|
elif self._inServicePack:
|
||||||
self._servicePack += sanitizeStr(data)
|
self._servicePack += sanitizeStr(content)
|
||||||
|
|
||||||
def endElement(self, name):
|
def endElement(self, name):
|
||||||
if name == "signature":
|
if name == "signature":
|
||||||
|
|
|
@ -57,10 +57,10 @@ class _GetchMacCarbon(object):
|
||||||
"""
|
"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
import Carbon
|
import Carbon
|
||||||
Carbon.Evt # see if it has this (in Unix, it doesn't)
|
|
||||||
|
_ = Carbon.Evt # see if it has this (in Unix, it doesn't)
|
||||||
|
|
||||||
def __call__(self):
|
def __call__(self):
|
||||||
import Carbon
|
|
||||||
if Carbon.Evt.EventAvail(0x0008)[0] == 0: # 0x0008 is the keyDownMask
|
if Carbon.Evt.EventAvail(0x0008)[0] == 0: # 0x0008 is the keyDownMask
|
||||||
return ''
|
return ''
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -635,7 +635,7 @@ def attackDumpedTable():
|
||||||
col_passwords = set()
|
col_passwords = set()
|
||||||
attack_dict = {}
|
attack_dict = {}
|
||||||
|
|
||||||
for column in sorted(columns, key=lambda _: len(_), reverse=True):
|
for column in sorted(columns, key=len, reverse=True):
|
||||||
if column and column.lower() in COMMON_USER_COLUMNS:
|
if column and column.lower() in COMMON_USER_COLUMNS:
|
||||||
col_user = column
|
col_user = column
|
||||||
break
|
break
|
||||||
|
|
|
@ -11,7 +11,7 @@ from lib.core.data import logger
|
||||||
from lib.core.enums import CUSTOM_LOGGING
|
from lib.core.enums import CUSTOM_LOGGING
|
||||||
from lib.core.enums import TIMEOUT_STATE
|
from lib.core.enums import TIMEOUT_STATE
|
||||||
|
|
||||||
def timeout(func, args=(), kwargs={}, duration=1, default=None):
|
def timeout(func, args=None, kwargs=None, duration=1, default=None):
|
||||||
class InterruptableThread(threading.Thread):
|
class InterruptableThread(threading.Thread):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
|
@ -20,7 +20,7 @@ def timeout(func, args=(), kwargs={}, duration=1, default=None):
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
try:
|
try:
|
||||||
self.result = func(*args, **kwargs)
|
self.result = func(*(args or ()), **(kwargs or {}))
|
||||||
self.timeout_state = TIMEOUT_STATE.NORMAL
|
self.timeout_state = TIMEOUT_STATE.NORMAL
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logger.log(CUSTOM_LOGGING.TRAFFIC_IN, ex)
|
logger.log(CUSTOM_LOGGING.TRAFFIC_IN, ex)
|
||||||
|
|
|
@ -66,9 +66,6 @@ class xrange(object):
|
||||||
def __hash__(self):
|
def __hash__(self):
|
||||||
return hash(self._slice)
|
return hash(self._slice)
|
||||||
|
|
||||||
def __cmp__(self, other):
|
|
||||||
return (cmp(type(self), type(other)) or cmp(self._slice, other._slice))
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '%s(%r, %r, %r)' % (type(self).__name__, self.start, self.stop, self.step)
|
return '%s(%r, %r, %r)' % (type(self).__name__, self.start, self.stop, self.step)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user