Further pleasing the pylint gods

This commit is contained in:
Miroslav Stampar
2019-05-30 22:40:51 +02:00
parent 1f7ee039ad
commit f8e9f9c87d
14 changed files with 38 additions and 50 deletions

View File

@@ -53,7 +53,7 @@ class BigArray(list):
List-like class used for storing large amounts of data (disk cached)
"""
def __init__(self, items=[]):
def __init__(self, items=None):
self.chunks = [[]]
self.chunk_length = sys.maxsize
self.cache = None
@@ -61,7 +61,7 @@ class BigArray(list):
self._os_remove = os.remove
self._size_counter = 0
for item in items:
for item in (items or []):
self.append(item)
def append(self, value):
@@ -139,12 +139,6 @@ class BigArray(list):
self.__init__()
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):
if y < 0:
y += len(self)

View File

@@ -2328,22 +2328,21 @@ def initCommonOutputs():
kb.commonOutputs = {}
key = None
with openFile(paths.COMMON_OUTPUTS, 'r') as f:
for line in f:
if line.find('#') != -1:
line = line[:line.find('#')]
for line in openFile(paths.COMMON_OUTPUTS, 'r'):
if line.find('#') != -1:
line = line[:line.find('#')]
line = line.strip()
line = line.strip()
if len(line) > 1:
if line.startswith('[') and line.endswith(']'):
key = line[1:-1]
elif key:
if key not in kb.commonOutputs:
kb.commonOutputs[key] = set()
if len(line) > 1:
if line.startswith('[') and line.endswith(']'):
key = line[1:-1]
elif key:
if key not in kb.commonOutputs:
kb.commonOutputs[key] = set()
if line not in kb.commonOutputs[key]:
kb.commonOutputs[key].add(line)
if line not in kb.commonOutputs[key]:
kb.commonOutputs[key].add(line)
def getFileItems(filename, commentPrefix='#', unicoded=True, lowercase=False, unique=False):
"""
@@ -3921,7 +3920,7 @@ def normalizeUnicode(value, charset=string.printable[:string.printable.find(' ')
# Reference: http://www.peterbe.com/plog/unicode-to-ascii
>>> normalizeUnicode(u'\u0161u\u0107uraj') == u'sucuraj'
>>> normalizeUnicode(u'\\u0161u\\u0107uraj') == u'sucuraj'
True
>>> normalizeUnicode(getUnicode(decodeHex("666f6f00626172"))) == u'foobar'
True
@@ -4096,7 +4095,7 @@ def expandMnemonics(mnemonics, parser, args):
debugMsg = "mnemonic '%s' resolved to %s). " % (name, found)
logger.debug(debugMsg)
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 += "Resolved to shortest of those ('%s')" % found
logger.warn(warnMsg)
@@ -5043,7 +5042,6 @@ def parseRequestFile(reqFile, checkParams=True):
def getSafeExString(ex, encoding=None):
"""
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'
True

View File

@@ -184,15 +184,15 @@ class OrderedSet(collections.MutableSet):
def __contains__(self, key):
return key in self.map
def add(self, key):
if key not in self.map:
def add(self, value):
if value not in self.map:
end = self.end
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):
if key in self.map:
key, prev, next = self.map.pop(key)
def discard(self, value):
if value in self.map:
value, prev, next = self.map.pop(value)
prev[2] = next
next[1] = prev

View File

@@ -468,8 +468,7 @@ class Dump(object):
shutil.copyfile(dumpFileName, candidate)
except IOError:
pass
finally:
break
break
else:
count += 1

View File

@@ -838,6 +838,7 @@ def _setPreprocessFunctions():
if conf.preprocess:
for script in re.split(PARAMETER_SPLITTING_REGEX, conf.preprocess):
found = False
function = None
script = safeFilepathEncode(script.strip())

View File

@@ -79,9 +79,9 @@ class Replication(object):
errMsg = "wrong number of columns used in replicating insert"
raise SqlmapValueException(errMsg)
def execute(self, sql, parameters=[]):
def execute(self, sql, parameters=None):
try:
self.parent.cursor.execute(sql, parameters)
self.parent.cursor.execute(sql, parameters or [])
except sqlite3.OperationalError as ex:
errMsg = "problem occurred ('%s') while accessing sqlite database " % getSafeExString(ex, UNICODE_ENCODING)
errMsg += "located at '%s'. Please make sure that " % self.parent.dbpath

View File

@@ -18,7 +18,7 @@ from lib.core.enums import OS
from thirdparty.six import unichr as _unichr
# 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_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)