Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b1a8986

Browse files
committed
Some more trivial refactoring
1 parent 496075e commit b1a8986

1 file changed

Lines changed: 16 additions & 14 deletions

File tree

lib/core/common.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2333,7 +2333,7 @@ def longestCommonPrefix(*sequences):
23332333
return sequences[0]
23342334

23352335
def commonFinderOnly(initial, sequence):
2336-
return longestCommonPrefix(*filter(lambda x: x.startswith(initial), sequence))
2336+
return longestCommonPrefix(*filter(lambda _: _.startswith(initial), sequence))
23372337

23382338
def pushValue(value):
23392339
"""
@@ -2431,7 +2431,7 @@ def adjustTimeDelay(lastQueryDuration, lowerStdLimit):
24312431
if candidate:
24322432
kb.delayCandidates = [candidate] + kb.delayCandidates[:-1]
24332433

2434-
if all((x == candidate for x in kb.delayCandidates)) and candidate < conf.timeSec:
2434+
if all((_ == candidate for _ in kb.delayCandidates)) and candidate < conf.timeSec:
24352435
conf.timeSec = candidate
24362436

24372437
infoMsg = "adjusting time delay to "
@@ -2543,8 +2543,8 @@ def _(match):
25432543
return char if char in charset else match.group(0)
25442544
result = value
25452545
if plusspace:
2546-
result = result.replace("+", " ") # plus sign has a special meaning in URL encoded data (hence the usage of urllib.unquote_plus in convall case)
2547-
result = re.sub("%([0-9a-fA-F]{2})", _, result)
2546+
result = result.replace('+', ' ') # plus sign has a special meaning in URL encoded data (hence the usage of urllib.unquote_plus in convall case)
2547+
result = re.sub(r"%([0-9a-fA-F]{2})", _, result)
25482548

25492549
if isinstance(result, str):
25502550
result = unicode(result, encoding or UNICODE_ENCODING, "replace")
@@ -2944,8 +2944,8 @@ def isStackingAvailable():
29442944
retVal = True
29452945
else:
29462946
for technique in getPublicTypeMembers(PAYLOAD.TECHNIQUE, True):
2947-
_ = getTechniqueData(technique)
2948-
if _ and "stacked" in _["title"].lower():
2947+
data = getTechniqueData(technique)
2948+
if data and "stacked" in data["title"].lower():
29492949
retVal = True
29502950
break
29512951

@@ -3007,7 +3007,7 @@ def saveConfig(conf, filename):
30073007
if option in defaults:
30083008
value = str(defaults[option])
30093009
else:
3010-
value = "0"
3010+
value = '0'
30113011
elif datatype == OPTION_TYPE.STRING:
30123012
value = ""
30133013

@@ -3131,7 +3131,7 @@ def priorityFunction(test):
31313131
if test.stype == PAYLOAD.TECHNIQUE.UNION:
31323132
retVal = SORT_ORDER.LAST
31333133

3134-
elif 'details' in test and 'dbms' in test.details:
3134+
elif "details" in test and "dbms" in test.details:
31353135
if intersect(test.details.dbms, Backend.getIdentifiedDbms()):
31363136
retVal = SORT_ORDER.SECOND
31373137
else:
@@ -3210,7 +3210,7 @@ def decodeIntToUnicode(value):
32103210
raw = hexdecode(_)
32113211

32123212
if Backend.isDbms(DBMS.MYSQL):
3213-
# https://github.com/sqlmapproject/sqlmap/issues/1531
3213+
# Note: https://github.com/sqlmapproject/sqlmap/issues/1531
32143214
retVal = getUnicode(raw, conf.encoding or UNICODE_ENCODING)
32153215
elif Backend.isDbms(DBMS.MSSQL):
32163216
retVal = getUnicode(raw, "UTF-16-BE")
@@ -3387,7 +3387,7 @@ def maskSensitiveData(msg):
33873387
retVal = retVal.replace(match.group(3), '*' * len(match.group(3)))
33883388

33893389
if getpass.getuser():
3390-
retVal = re.sub(r"(?i)\b%s\b" % re.escape(getpass.getuser()), "*" * len(getpass.getuser()), retVal)
3390+
retVal = re.sub(r"(?i)\b%s\b" % re.escape(getpass.getuser()), '*' * len(getpass.getuser()), retVal)
33913391

33923392
return retVal
33933393

@@ -3462,7 +3462,7 @@ def _(value):
34623462
value = value.replace(2 * REFLECTED_REPLACEMENT_REGEX, REFLECTED_REPLACEMENT_REGEX)
34633463
return value
34643464

3465-
payload = getUnicode(urldecode(payload.replace(PAYLOAD_DELIMITER, ''), convall=True))
3465+
payload = getUnicode(urldecode(payload.replace(PAYLOAD_DELIMITER, ""), convall=True))
34663466
regex = _(filterStringValue(payload, r"[A-Za-z0-9]", REFLECTED_REPLACEMENT_REGEX.encode("string-escape")))
34673467

34683468
if regex != payload:
@@ -3518,7 +3518,7 @@ def _thread(regex):
35183518
warnMsg = "reflective value(s) found and filtering out"
35193519
singleTimeWarnMessage(warnMsg)
35203520

3521-
if re.search(r"FRAME[^>]+src=[^>]*%s" % REFLECTED_VALUE_MARKER, retVal, re.I):
3521+
if re.search(r"(?i)FRAME[^>]+src=[^>]*%s" % REFLECTED_VALUE_MARKER, retVal):
35223522
warnMsg = "frames detected containing attacked parameter values. Please be sure to "
35233523
warnMsg += "test those separately in case that attack on this page fails"
35243524
singleTimeWarnMessage(warnMsg)
@@ -3547,7 +3547,7 @@ def normalizeUnicode(value):
35473547
'sucuraj'
35483548
"""
35493549

3550-
return unicodedata.normalize('NFKD', value).encode('ascii', 'ignore') if isinstance(value, unicode) else value
3550+
return unicodedata.normalize("NFKD", value).encode("ascii", "ignore") if isinstance(value, unicode) else value
35513551

35523552
def safeSQLIdentificatorNaming(name, isTable=False):
35533553
"""
@@ -3669,7 +3669,7 @@ def __init__(self):
36693669

36703670
for mnemonic in (mnemonics or "").split(','):
36713671
found = None
3672-
name = mnemonic.split('=')[0].replace("-", "").strip()
3672+
name = mnemonic.split('=')[0].replace('-', "").strip()
36733673
value = mnemonic.split('=')[1] if len(mnemonic.split('=')) > 1 else None
36743674
pointer = head
36753675

@@ -4242,8 +4242,10 @@ def hashDBRetrieve(key, unserialize=False, checkConf=False):
42424242

42434243
_ = "%s%s%s" % (conf.url or "%s%s" % (conf.hostname, conf.port), key, HASHDB_MILESTONE_VALUE)
42444244
retVal = conf.hashDB.retrieve(_, unserialize) if kb.resumeValues and not (checkConf and any((conf.flushSession, conf.freshQueries))) else None
4245+
42454246
if not kb.inferenceMode and not kb.fileReadMode and isinstance(retVal, basestring) and any(_ in retVal for _ in (PARTIAL_VALUE_MARKER, PARTIAL_HEX_VALUE_MARKER)):
42464247
retVal = None
4248+
42474249
return retVal
42484250

42494251
def resetCookieJar(cookieJar):

0 commit comments

Comments
 (0)