Skip to content

Commit df42934

Browse files
committed
Fixing DeprecationWarning (logger.warn)
1 parent 90b444c commit df42934

File tree

99 files changed

+429
-428
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+429
-428
lines changed

lib/controller/checks.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ def genCmpPayload():
810810

811811
except KeyboardInterrupt:
812812
warnMsg = "user aborted during detection phase"
813-
logger.warn(warnMsg)
813+
logger.warning(warnMsg)
814814

815815
if conf.multipleTargets:
816816
msg = "how do you want to proceed? [ne(X)t target/(s)kip current test/(e)nd detection phase/(n)ext parameter/(c)hange verbosity/(q)uit]"
@@ -826,7 +826,7 @@ def genCmpPayload():
826826
choice = None
827827
while not ((choice or "").isdigit() and 0 <= int(choice) <= 6):
828828
if choice:
829-
logger.warn("invalid value")
829+
logger.warning("invalid value")
830830
msg = "enter new verbosity level: [0-6] "
831831
choice = readInput(msg, default=str(conf.verbose), checkBatch=False)
832832
conf.verbose = int(choice)
@@ -851,7 +851,7 @@ def genCmpPayload():
851851
warnMsg = "in OR boolean-based injection cases, please consider usage "
852852
warnMsg += "of switch '--drop-set-cookie' if you experience any "
853853
warnMsg += "problems during data retrieval"
854-
logger.warn(warnMsg)
854+
logger.warning(warnMsg)
855855

856856
if not checkFalsePositives(injection):
857857
if conf.hostname in kb.vulnHosts:
@@ -976,7 +976,7 @@ def _():
976976

977977
if not retVal:
978978
warnMsg = "false positive or unexploitable injection point detected"
979-
logger.warn(warnMsg)
979+
logger.warning(warnMsg)
980980

981981
kb.injection = popValue()
982982

@@ -1002,7 +1002,7 @@ def checkSuhosinPatch(injection):
10021002
warnMsg = "parameter length constraining "
10031003
warnMsg += "mechanism detected (e.g. Suhosin patch). "
10041004
warnMsg += "Potential problems in enumeration phase can be expected"
1005-
logger.warn(warnMsg)
1005+
logger.warning(warnMsg)
10061006

10071007
kb.injection = popValue()
10081008

@@ -1023,15 +1023,15 @@ def checkFilteredChars(injection):
10231023
warnMsg += "filtered by the back-end server. There is a strong "
10241024
warnMsg += "possibility that sqlmap won't be able to properly "
10251025
warnMsg += "exploit this vulnerability"
1026-
logger.warn(warnMsg)
1026+
logger.warning(warnMsg)
10271027

10281028
# inference techniques depend on character '>'
10291029
if not any(_ in injection.data for _ in (PAYLOAD.TECHNIQUE.ERROR, PAYLOAD.TECHNIQUE.UNION, PAYLOAD.TECHNIQUE.QUERY)):
10301030
if not checkBooleanExpression("%d>%d" % (randInt + 1, randInt)):
10311031
warnMsg = "it appears that the character '>' is "
10321032
warnMsg += "filtered by the back-end server. You are strongly "
10331033
warnMsg += "advised to rerun with the '--tamper=between'"
1034-
logger.warn(warnMsg)
1034+
logger.warning(warnMsg)
10351035

10361036
kb.injection = popValue()
10371037

@@ -1122,7 +1122,7 @@ def _(page):
11221122

11231123
else:
11241124
infoMsg += "not be injectable"
1125-
logger.warn(infoMsg)
1125+
logger.warning(infoMsg)
11261126

11271127
kb.heuristicMode = True
11281128
kb.disableHtmlDecoding = True
@@ -1230,7 +1230,7 @@ def checkDynamicContent(firstPage, secondPage):
12301230
if count > conf.retries:
12311231
warnMsg = "target URL content appears to be too dynamic. "
12321232
warnMsg += "Switching to '--text-only' "
1233-
logger.warn(warnMsg)
1233+
logger.warning(warnMsg)
12341234

12351235
conf.textOnly = True
12361236
return
@@ -1288,7 +1288,7 @@ def checkStability():
12881288
warnMsg += "injectable parameters are detected, or in case of "
12891289
warnMsg += "junk results, refer to user's manual paragraph "
12901290
warnMsg += "'Page comparison'"
1291-
logger.warn(warnMsg)
1291+
logger.warning(warnMsg)
12921292

12931293
message = "how do you want to proceed? [(C)ontinue/(s)tring/(r)egex/(q)uit] "
12941294
choice = readInput(message, default='C').upper()
@@ -1513,7 +1513,7 @@ def checkConnection(suppressOutput=False):
15131513
warnMsg = "you provided '%s' as the string to " % conf.string
15141514
warnMsg += "match, but such a string is not within the target "
15151515
warnMsg += "URL raw response, sqlmap will carry on anyway"
1516-
logger.warn(warnMsg)
1516+
logger.warning(warnMsg)
15171517

15181518
if conf.regexp:
15191519
infoMsg = "testing if the provided regular expression matches within "
@@ -1524,7 +1524,7 @@ def checkConnection(suppressOutput=False):
15241524
warnMsg = "you provided '%s' as the regular expression " % conf.regexp
15251525
warnMsg += "which does not have any match within the target URL raw response. sqlmap "
15261526
warnMsg += "will carry on anyway"
1527-
logger.warn(warnMsg)
1527+
logger.warning(warnMsg)
15281528

15291529
kb.errorIsNone = False
15301530

@@ -1539,12 +1539,12 @@ def checkConnection(suppressOutput=False):
15391539
elif wasLastResponseDBMSError():
15401540
warnMsg = "there is a DBMS error found in the HTTP response body "
15411541
warnMsg += "which could interfere with the results of the tests"
1542-
logger.warn(warnMsg)
1542+
logger.warning(warnMsg)
15431543
elif wasLastResponseHTTPError():
15441544
if getLastRequestHTTPError() not in (conf.ignoreCode or []):
15451545
warnMsg = "the web server responded with an HTTP error code (%d) " % getLastRequestHTTPError()
15461546
warnMsg += "which could interfere with the results of the tests"
1547-
logger.warn(warnMsg)
1547+
logger.warning(warnMsg)
15481548
else:
15491549
kb.errorIsNone = True
15501550

lib/controller/controller.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,12 @@ def _showInjections():
186186
if conf.tamper:
187187
warnMsg = "changes made by tampering scripts are not "
188188
warnMsg += "included in shown payload content(s)"
189-
logger.warn(warnMsg)
189+
logger.warning(warnMsg)
190190

191191
if conf.hpp:
192192
warnMsg = "changes made by HTTP parameter pollution are not "
193193
warnMsg += "included in shown payload content(s)"
194-
logger.warn(warnMsg)
194+
logger.warning(warnMsg)
195195

196196
def _randomFillBlankFields(value):
197197
retVal = value
@@ -556,7 +556,7 @@ def start():
556556

557557
if not check:
558558
warnMsg = "%sparameter '%s' does not appear to be dynamic" % ("%s " % paramType if paramType != parameter else "", parameter)
559-
logger.warn(warnMsg)
559+
logger.warning(warnMsg)
560560

561561
if conf.skipStatic:
562562
infoMsg = "skipping static %sparameter '%s'" % ("%s " % paramType if paramType != parameter else "", parameter)
@@ -612,7 +612,7 @@ def start():
612612

613613
if not injectable:
614614
warnMsg = "%sparameter '%s' does not seem to be injectable" % ("%s " % paramType if paramType != parameter else "", parameter)
615-
logger.warn(warnMsg)
615+
logger.warning(warnMsg)
616616

617617
finally:
618618
if place == PLACE.COOKIE:
@@ -709,7 +709,7 @@ def start():
709709

710710
if conf.multipleTargets:
711711
warnMsg = "user aborted in multiple target mode"
712-
logger.warn(warnMsg)
712+
logger.warning(warnMsg)
713713

714714
message = "do you want to skip to the next target in list? [Y/n/q]"
715715
choice = readInput(message, default='Y').upper()
@@ -749,7 +749,7 @@ def start():
749749
warnMsg = "it appears that the target "
750750
warnMsg += "has a maximum connections "
751751
warnMsg += "constraint"
752-
logger.warn(warnMsg)
752+
logger.warning(warnMsg)
753753

754754
if kb.dataOutputFlag and not conf.multipleTargets:
755755
logger.info("fetched data logged to text files under '%s'" % conf.outputPath)

lib/core/common.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ def setDbms(dbms):
351351
elif kb.dbms is not None and kb.dbms != dbms:
352352
warnMsg = "there appears to be a high probability that "
353353
warnMsg += "this could be a false positive case"
354-
logger.warn(warnMsg)
354+
logger.warning(warnMsg)
355355

356356
msg = "sqlmap previously fingerprinted back-end DBMS as "
357357
msg += "%s. However now it has been fingerprinted " % kb.dbms
@@ -371,7 +371,7 @@ def setDbms(dbms):
371371
break
372372
else:
373373
warnMsg = "invalid value"
374-
logger.warn(warnMsg)
374+
logger.warning(warnMsg)
375375

376376
elif kb.dbms is None:
377377
kb.dbms = aliasToDbmsEnum(dbms)
@@ -429,7 +429,7 @@ def setOs(os):
429429
break
430430
else:
431431
warnMsg = "invalid value"
432-
logger.warn(warnMsg)
432+
logger.warning(warnMsg)
433433

434434
elif kb.os is None and isinstance(os, six.string_types):
435435
kb.os = os.capitalize()
@@ -466,7 +466,7 @@ def setArch():
466466
break
467467
else:
468468
warnMsg = "invalid value. Valid values are 1 and 2"
469-
logger.warn(warnMsg)
469+
logger.warning(warnMsg)
470470

471471
return kb.arch
472472

@@ -663,7 +663,7 @@ def paramToDict(place, parameters=None):
663663
warnMsg += "chars/statements from manual SQL injection test(s). "
664664
warnMsg += "Please, always use only valid parameter values "
665665
warnMsg += "so sqlmap could be able to run properly"
666-
logger.warn(warnMsg)
666+
logger.warning(warnMsg)
667667

668668
message = "are you really sure that you want to continue (sqlmap could have problems)? [y/N] "
669669

@@ -673,7 +673,7 @@ def paramToDict(place, parameters=None):
673673
warnMsg = "provided value for parameter '%s' is empty. " % parameter
674674
warnMsg += "Please, always use only valid parameter values "
675675
warnMsg += "so sqlmap could be able to run properly"
676-
logger.warn(warnMsg)
676+
logger.warning(warnMsg)
677677

678678
if place in (PLACE.POST, PLACE.GET):
679679
for regex in (r"\A((?:<[^>]+>)+\w+)((?:<[^>]+>)+)\Z", r"\A([^\w]+.*\w+)([^\w]+)\Z"):
@@ -738,7 +738,7 @@ def walk(head, current=None):
738738
if len(conf.testParameter) > 1:
739739
warnMsg = "provided parameters '%s' " % paramStr
740740
warnMsg += "are not inside the %s" % place
741-
logger.warn(warnMsg)
741+
logger.warning(warnMsg)
742742
else:
743743
parameter = conf.testParameter[0]
744744

@@ -763,7 +763,7 @@ def walk(head, current=None):
763763
if len(decoded) > MIN_ENCODED_LEN_CHECK and all(_ in getBytes(string.printable) for _ in decoded):
764764
warnMsg = "provided parameter '%s' " % parameter
765765
warnMsg += "appears to be '%s' encoded" % encoding
766-
logger.warn(warnMsg)
766+
logger.warning(warnMsg)
767767
break
768768
except:
769769
pass
@@ -814,7 +814,7 @@ def getManualDirectories():
814814
else:
815815
warnMsg = "unable to automatically retrieve the web server "
816816
warnMsg += "document root"
817-
logger.warn(warnMsg)
817+
logger.warning(warnMsg)
818818

819819
directories = []
820820

@@ -900,7 +900,7 @@ def getAutoDirectories():
900900
retVal.add(directory)
901901
else:
902902
warnMsg = "unable to automatically parse any web server path"
903-
logger.warn(warnMsg)
903+
logger.warning(warnMsg)
904904

905905
return list(retVal)
906906

@@ -1637,7 +1637,7 @@ def parseTargetDirect():
16371637
if remote:
16381638
warnMsg = "direct connection over the network for "
16391639
warnMsg += "%s DBMS is not supported" % dbmsName
1640-
logger.warn(warnMsg)
1640+
logger.warning(warnMsg)
16411641

16421642
conf.hostname = "localhost"
16431643
conf.port = 0
@@ -1900,7 +1900,7 @@ def parseUnionPage(page):
19001900
if re.search(r"(?si)\A%s.*%s\Z" % (kb.chars.start, kb.chars.stop), page):
19011901
if len(page) > LARGE_OUTPUT_THRESHOLD:
19021902
warnMsg = "large output detected. This might take a while"
1903-
logger.warn(warnMsg)
1903+
logger.warning(warnMsg)
19041904

19051905
data = BigArray()
19061906
keys = set()
@@ -2789,7 +2789,7 @@ def wasLastResponseDelayed():
27892789
if len(kb.responseTimes[kb.responseTimeMode]) < MIN_TIME_RESPONSES:
27902790
warnMsg = "time-based standard deviation method used on a model "
27912791
warnMsg += "with less than %d response times" % MIN_TIME_RESPONSES
2792-
logger.warn(warnMsg)
2792+
logger.warning(warnMsg)
27932793

27942794
lowerStdLimit = average(kb.responseTimes[kb.responseTimeMode]) + TIME_STDEV_COEFF * deviation
27952795
retVal = (threadData.lastQueryDuration >= max(MIN_VALID_DELAYED_RESPONSE, lowerStdLimit))
@@ -3593,7 +3593,7 @@ def initTechnique(technique=None):
35933593
else:
35943594
warnMsg = "there is no injection data available for technique "
35953595
warnMsg += "'%s'" % enumValueToNameLookup(PAYLOAD.TECHNIQUE, technique)
3596-
logger.warn(warnMsg)
3596+
logger.warning(warnMsg)
35973597

35983598
except SqlmapDataException:
35993599
errMsg = "missing data in old session file(s). "
@@ -3744,7 +3744,7 @@ def showHttpErrorCodes():
37443744
if kb.httpErrorCodes:
37453745
warnMsg = "HTTP error codes detected during run:\n"
37463746
warnMsg += ", ".join("%d (%s) - %d times" % (code, _http_client.responses[code] if code in _http_client.responses else '?', count) for code, count in kb.httpErrorCodes.items())
3747-
logger.warn(warnMsg)
3747+
logger.warning(warnMsg)
37483748
if any((str(_).startswith('4') or str(_).startswith('5')) and _ != _http_client.INTERNAL_SERVER_ERROR and _ != kb.originalCode for _ in kb.httpErrorCodes):
37493749
msg = "too many 4xx and/or 5xx HTTP error codes "
37503750
msg += "could mean that some kind of protection is involved (e.g. WAF)"
@@ -3972,7 +3972,7 @@ def createGithubIssue(errMsg, excMsg):
39723972
if closed:
39733973
warnMsg += " and resolved. Please update to the latest "
39743974
warnMsg += "development version from official GitHub repository at '%s'" % GIT_PAGE
3975-
logger.warn(warnMsg)
3975+
logger.warning(warnMsg)
39763976
return
39773977
except:
39783978
pass
@@ -4002,7 +4002,7 @@ def createGithubIssue(errMsg, excMsg):
40024002
warnMsg += " ('%s')" % _excMsg
40034003
if "Unauthorized" in warnMsg:
40044004
warnMsg += ". Please update to the latest revision"
4005-
logger.warn(warnMsg)
4005+
logger.warning(warnMsg)
40064006

40074007
def maskSensitiveData(msg):
40084008
"""
@@ -4395,7 +4395,7 @@ def __init__(self):
43954395

43964396
if not options:
43974397
warnMsg = "mnemonic '%s' can't be resolved" % name
4398-
logger.warn(warnMsg)
4398+
logger.warning(warnMsg)
43994399
elif name in options:
44004400
found = name
44014401
debugMsg = "mnemonic '%s' resolved to %s). " % (name, found)
@@ -4404,7 +4404,7 @@ def __init__(self):
44044404
found = sorted(options.keys(), key=len)[0]
44054405
warnMsg = "detected ambiguity (mnemonic '%s' can be resolved to any of: %s). " % (name, ", ".join("'%s'" % key for key in options))
44064406
warnMsg += "Resolved to shortest of those ('%s')" % found
4407-
logger.warn(warnMsg)
4407+
logger.warning(warnMsg)
44084408

44094409
if found:
44104410
found = options[found]
@@ -4810,7 +4810,7 @@ def checkOldOptions(args):
48104810
warnMsg = "switch/option '%s' is deprecated" % _
48114811
if DEPRECATED_OPTIONS[_]:
48124812
warnMsg += " (hint: %s)" % DEPRECATED_OPTIONS[_]
4813-
logger.warn(warnMsg)
4813+
logger.warning(warnMsg)
48144814

48154815
def checkSystemEncoding():
48164816
"""
@@ -4828,7 +4828,7 @@ def checkSystemEncoding():
48284828
logger.critical(errMsg)
48294829

48304830
warnMsg = "temporary switching to charset 'cp1256'"
4831-
logger.warn(warnMsg)
4831+
logger.warning(warnMsg)
48324832

48334833
_reload_module(sys)
48344834
sys.setdefaultencoding("cp1256")

lib/core/dump.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ def dbTableValues(self, tableValues):
421421
tempDir = tempfile.mkdtemp(prefix="sqlmapdb")
422422
warnMsg = "currently unable to use regular dump directory. "
423423
warnMsg += "Using temporary directory '%s' instead" % tempDir
424-
logger.warn(warnMsg)
424+
logger.warning(warnMsg)
425425

426426
dumpDbPath = tempDir
427427

@@ -445,7 +445,7 @@ def dbTableValues(self, tableValues):
445445
warnMsg = "unable to create dump directory "
446446
warnMsg += "'%s' (%s). " % (dumpDbPath, getSafeExString(ex))
447447
warnMsg += "Using temporary directory '%s' instead" % tempDir
448-
logger.warn(warnMsg)
448+
logger.warning(warnMsg)
449449

450450
dumpDbPath = tempDir
451451

@@ -624,7 +624,7 @@ def dbTableValues(self, tableValues):
624624
_ = re.sub(r"[^\w]", UNSAFE_DUMP_FILEPATH_REPLACEMENT, normalizeUnicode(unsafeSQLIdentificatorNaming(column)))
625625
filepath = os.path.join(dumpDbPath, "%s-%d.bin" % (_, randomInt(8)))
626626
warnMsg = "writing binary ('%s') content to file '%s' " % (mimetype, filepath)
627-
logger.warn(warnMsg)
627+
logger.warning(warnMsg)
628628

629629
with openFile(filepath, "w+b", None) as f:
630630
_ = safechardecode(value, True)
@@ -672,7 +672,7 @@ def dbTableValues(self, tableValues):
672672
if not warnFile:
673673
logger.info(msg)
674674
else:
675-
logger.warn(msg)
675+
logger.warning(msg)
676676

677677
def dbColumns(self, dbColumnsDict, colConsider, dbs):
678678
if conf.api:

0 commit comments

Comments
 (0)