Skip to content

Commit f8e9f9c

Browse files
committed
Further pleasing the pylint gods
1 parent 1f7ee03 commit f8e9f9c

File tree

14 files changed

+38
-50
lines changed

14 files changed

+38
-50
lines changed

.pylintrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ enable=import-error,
7070
unused-wildcard-import,
7171
global-variable-not-assigned,
7272
undefined-loop-variable,
73-
global-statement,
7473
global-at-module-level,
7574
bad-open-mode,
7675
redundant-unittest-assert,

lib/controller/checks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ def genCmpPayload():
561561
candidates = trueSet - falseSet - errorSet
562562

563563
if candidates:
564-
candidates = sorted(candidates, key=lambda _: len(_))
564+
candidates = sorted(candidates, key=len)
565565
for candidate in candidates:
566566
if re.match(r"\A[\w.,! ]+\Z", candidate) and ' ' in candidate and candidate.strip() and len(candidate) > CANDIDATE_SENTENCE_MIN_LENGTH:
567567
conf.string = candidate
@@ -595,7 +595,7 @@ def genCmpPayload():
595595
candidates = filterNone(_.strip() if _.strip() in trueRawResponse and _.strip() not in falseRawResponse else None for _ in (trueSet - falseSet - errorSet))
596596

597597
if candidates:
598-
candidates = sorted(candidates, key=lambda _: len(_))
598+
candidates = sorted(candidates, key=len)
599599
for candidate in candidates:
600600
if re.match(r"\A\w+\Z", candidate):
601601
break
@@ -609,7 +609,7 @@ def genCmpPayload():
609609
candidates = filterNone(_.strip() if _.strip() in falseRawResponse and _.strip() not in trueRawResponse else None for _ in (falseSet - trueSet))
610610

611611
if candidates:
612-
candidates = sorted(candidates, key=lambda _: len(_))
612+
candidates = sorted(candidates, key=len)
613613
for candidate in candidates:
614614
if re.match(r"\A\w+\Z", candidate):
615615
break

lib/core/bigarray.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ class BigArray(list):
5353
List-like class used for storing large amounts of data (disk cached)
5454
"""
5555

56-
def __init__(self, items=[]):
56+
def __init__(self, items=None):
5757
self.chunks = [[]]
5858
self.chunk_length = sys.maxsize
5959
self.cache = None
6060
self.filenames = set()
6161
self._os_remove = os.remove
6262
self._size_counter = 0
6363

64-
for item in items:
64+
for item in (items or []):
6565
self.append(item)
6666

6767
def append(self, value):
@@ -139,12 +139,6 @@ def __setstate__(self, state):
139139
self.__init__()
140140
self.chunks, self.filenames = state
141141

142-
def __getslice__(self, i, j):
143-
i = max(0, len(self) + i if i < 0 else i)
144-
j = min(len(self), len(self) + j if j < 0 else j)
145-
146-
return BigArray(self[_] for _ in xrange(i, j))
147-
148142
def __getitem__(self, y):
149143
if y < 0:
150144
y += len(self)

lib/core/common.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2328,22 +2328,21 @@ def initCommonOutputs():
23282328
kb.commonOutputs = {}
23292329
key = None
23302330

2331-
with openFile(paths.COMMON_OUTPUTS, 'r') as f:
2332-
for line in f:
2333-
if line.find('#') != -1:
2334-
line = line[:line.find('#')]
2331+
for line in openFile(paths.COMMON_OUTPUTS, 'r'):
2332+
if line.find('#') != -1:
2333+
line = line[:line.find('#')]
23352334

2336-
line = line.strip()
2335+
line = line.strip()
23372336

2338-
if len(line) > 1:
2339-
if line.startswith('[') and line.endswith(']'):
2340-
key = line[1:-1]
2341-
elif key:
2342-
if key not in kb.commonOutputs:
2343-
kb.commonOutputs[key] = set()
2337+
if len(line) > 1:
2338+
if line.startswith('[') and line.endswith(']'):
2339+
key = line[1:-1]
2340+
elif key:
2341+
if key not in kb.commonOutputs:
2342+
kb.commonOutputs[key] = set()
23442343

2345-
if line not in kb.commonOutputs[key]:
2346-
kb.commonOutputs[key].add(line)
2344+
if line not in kb.commonOutputs[key]:
2345+
kb.commonOutputs[key].add(line)
23472346

23482347
def getFileItems(filename, commentPrefix='#', unicoded=True, lowercase=False, unique=False):
23492348
"""
@@ -3921,7 +3920,7 @@ def normalizeUnicode(value, charset=string.printable[:string.printable.find(' ')
39213920
39223921
# Reference: http://www.peterbe.com/plog/unicode-to-ascii
39233922
3924-
>>> normalizeUnicode(u'\u0161u\u0107uraj') == u'sucuraj'
3923+
>>> normalizeUnicode(u'\\u0161u\\u0107uraj') == u'sucuraj'
39253924
True
39263925
>>> normalizeUnicode(getUnicode(decodeHex("666f6f00626172"))) == u'foobar'
39273926
True
@@ -4096,7 +4095,7 @@ def __init__(self):
40964095
debugMsg = "mnemonic '%s' resolved to %s). " % (name, found)
40974096
logger.debug(debugMsg)
40984097
else:
4099-
found = sorted(options.keys(), key=lambda x: len(x))[0]
4098+
found = sorted(options.keys(), key=len)[0]
41004099
warnMsg = "detected ambiguity (mnemonic '%s' can be resolved to any of: %s). " % (name, ", ".join("'%s'" % key for key in options))
41014100
warnMsg += "Resolved to shortest of those ('%s')" % found
41024101
logger.warn(warnMsg)
@@ -5043,7 +5042,6 @@ def _parseBurpLog(content):
50435042
def getSafeExString(ex, encoding=None):
50445043
"""
50455044
Safe way how to get the proper exception represtation as a string
5046-
(Note: errors to be avoided: 1) "%s" % Exception(u'\u0161') and 2) "%s" % str(Exception(u'\u0161'))
50475045
50485046
>>> getSafeExString(SqlmapBaseException('foobar')) == 'foobar'
50495047
True

lib/core/datatype.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,15 +184,15 @@ def __len__(self):
184184
def __contains__(self, key):
185185
return key in self.map
186186

187-
def add(self, key):
188-
if key not in self.map:
187+
def add(self, value):
188+
if value not in self.map:
189189
end = self.end
190190
curr = end[1]
191-
curr[2] = end[1] = self.map[key] = [key, curr, end]
191+
curr[2] = end[1] = self.map[value] = [value, curr, end]
192192

193-
def discard(self, key):
194-
if key in self.map:
195-
key, prev, next = self.map.pop(key)
193+
def discard(self, value):
194+
if value in self.map:
195+
value, prev, next = self.map.pop(value)
196196
prev[2] = next
197197
next[1] = prev
198198

lib/core/dump.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,7 @@ def dbTableValues(self, tableValues):
468468
shutil.copyfile(dumpFileName, candidate)
469469
except IOError:
470470
pass
471-
finally:
472-
break
471+
break
473472
else:
474473
count += 1
475474

lib/core/option.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,7 @@ def _setPreprocessFunctions():
838838
if conf.preprocess:
839839
for script in re.split(PARAMETER_SPLITTING_REGEX, conf.preprocess):
840840
found = False
841+
function = None
841842

842843
script = safeFilepathEncode(script.strip())
843844

lib/core/replication.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ def insert(self, values):
7979
errMsg = "wrong number of columns used in replicating insert"
8080
raise SqlmapValueException(errMsg)
8181

82-
def execute(self, sql, parameters=[]):
82+
def execute(self, sql, parameters=None):
8383
try:
84-
self.parent.cursor.execute(sql, parameters)
84+
self.parent.cursor.execute(sql, parameters or [])
8585
except sqlite3.OperationalError as ex:
8686
errMsg = "problem occurred ('%s') while accessing sqlite database " % getSafeExString(ex, UNICODE_ENCODING)
8787
errMsg += "located at '%s'. Please make sure that " % self.parent.dbpath

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from thirdparty.six import unichr as _unichr
1919

2020
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
21-
VERSION = "1.3.5.154"
21+
VERSION = "1.3.5.155"
2222
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2323
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2424
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

lib/parse/banner.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ def startElement(self, name, attrs):
5353
elif name == "servicepack":
5454
self._inServicePack = True
5555

56-
def characters(self, data):
56+
def characters(self, content):
5757
if self._inVersion:
58-
self._version += sanitizeStr(data)
58+
self._version += sanitizeStr(content)
5959
elif self._inServicePack:
60-
self._servicePack += sanitizeStr(data)
60+
self._servicePack += sanitizeStr(content)
6161

6262
def endElement(self, name):
6363
if name == "signature":

0 commit comments

Comments
 (0)