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

Skip to content

Commit ae2b029

Browse files
committed
Dealing with deprecated raises
1 parent 1d9c11b commit ae2b029

15 files changed

Lines changed: 46 additions & 50 deletions

lib/core/bigarray.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def pop(self):
9090
except IOError, ex:
9191
errMsg = "exception occurred while retrieving data "
9292
errMsg += "from a temporary file ('%s')" % ex.message
93-
raise SqlmapSystemException, errMsg
93+
raise SqlmapSystemException(errMsg)
9494

9595
return self.chunks[-1].pop()
9696

@@ -115,7 +115,7 @@ def _dump(self, chunk):
115115
errMsg += "make sure that there is enough disk space left. If problem persists, "
116116
errMsg += "try to set environment variable 'TEMP' to a location "
117117
errMsg += "writeable by the current user"
118-
raise SqlmapSystemException, errMsg
118+
raise SqlmapSystemException(errMsg)
119119

120120
def _checkcache(self, index):
121121
if (self.cache and self.cache.index != index and self.cache.dirty):
@@ -129,7 +129,7 @@ def _checkcache(self, index):
129129
except IOError, ex:
130130
errMsg = "exception occurred while retrieving data "
131131
errMsg += "from a temporary file ('%s')" % ex.message
132-
raise SqlmapSystemException, errMsg
132+
raise SqlmapSystemException(errMsg)
133133

134134
def __getstate__(self):
135135
return self.chunks, self.filenames

lib/core/common.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -596,9 +596,7 @@ def paramToDict(place, parameters=None):
596596
testableParameters[parameter] = "=".join(parts[1:])
597597
if not conf.multipleTargets and not (conf.csrfToken and parameter == conf.csrfToken):
598598
_ = urldecode(testableParameters[parameter], convall=True)
599-
if (_.endswith("'") and _.count("'") == 1
600-
or re.search(r'\A9{3,}', _) or re.search(r'\A-\d+\Z', _) or re.search(DUMMY_USER_INJECTION, _))\
601-
and not parameter.upper().startswith(GOOGLE_ANALYTICS_COOKIE_PREFIX):
599+
if (_.endswith("'") and _.count("'") == 1 or re.search(r'\A9{3,}', _) or re.search(r'\A-\d+\Z', _) or re.search(DUMMY_USER_INJECTION, _)) and not parameter.upper().startswith(GOOGLE_ANALYTICS_COOKIE_PREFIX):
602600
warnMsg = "it appears that you have provided tainted parameter values "
603601
warnMsg += "('%s') with most likely leftover " % element
604602
warnMsg += "chars/statements from manual SQL injection test(s). "
@@ -1371,7 +1369,7 @@ def parseTargetDirect():
13711369
raise SqlmapSyntaxException(errMsg)
13721370

13731371
if dbmsName in (DBMS.MSSQL, DBMS.SYBASE):
1374-
import _mssql
1372+
__import__("_mssql")
13751373
import pymssql
13761374

13771375
if not hasattr(pymssql, "__version__") or pymssql.__version__ < "1.0.2":
@@ -1381,17 +1379,17 @@ def parseTargetDirect():
13811379
raise SqlmapMissingDependence(errMsg)
13821380

13831381
elif dbmsName == DBMS.MYSQL:
1384-
import pymysql
1382+
__import__("pymysql")
13851383
elif dbmsName == DBMS.PGSQL:
1386-
import psycopg2
1384+
__import__("psycopg2")
13871385
elif dbmsName == DBMS.ORACLE:
1388-
import cx_Oracle
1386+
__import__("cx_Oracle")
13891387
elif dbmsName == DBMS.SQLITE:
1390-
import sqlite3
1388+
__import__("sqlite3")
13911389
elif dbmsName == DBMS.ACCESS:
1392-
import pyodbc
1390+
__import__("pyodbc")
13931391
elif dbmsName == DBMS.FIREBIRD:
1394-
import kinterbasdb
1392+
__import__("kinterbasdb")
13951393
except:
13961394
if _sqlalchemy and data[3] in _sqlalchemy.dialects.__all__:
13971395
pass
@@ -2005,7 +2003,7 @@ def parseXmlFile(xmlFile, handler):
20052003
errMsg = "something appears to be wrong with "
20062004
errMsg += "the file '%s' ('%s'). Please make " % (xmlFile, getSafeExString(ex))
20072005
errMsg += "sure that you haven't made any changes to it"
2008-
raise SqlmapInstallationException, errMsg
2006+
raise SqlmapInstallationException(errMsg)
20092007

20102008
def getSQLSnippet(dbms, sfile, **variables):
20112009
"""

lib/core/convert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def _(self):
8080
if len(self.stack) > 1:
8181
func = self.stack[-2]
8282
if func not in PICKLE_REDUCE_WHITELIST:
83-
raise Exception, "abusing reduce() is bad, Mkay!"
83+
raise Exception("abusing reduce() is bad, Mkay!")
8484
self.load_reduce()
8585

8686
def loads(str):

lib/core/option.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ def _parseBurpLog(content):
337337

338338
if not host:
339339
errMsg = "invalid format of a request file"
340-
raise SqlmapSyntaxException, errMsg
340+
raise SqlmapSyntaxException(errMsg)
341341

342342
if not url.startswith("http"):
343343
url = "%s://%s:%s%s" % (scheme or "http", host, port or "80", url)
@@ -402,7 +402,7 @@ def __contains__(self, name):
402402
errMsg = "something appears to be wrong with "
403403
errMsg += "the file '%s' ('%s'). Please make " % (paths.QUERIES_XML, getSafeExString(ex))
404404
errMsg += "sure that you haven't made any changes to it"
405-
raise SqlmapInstallationException, errMsg
405+
raise SqlmapInstallationException(errMsg)
406406

407407
for node in tree.findall("*"):
408408
queries[node.attrib['value']] = iterate(node)
@@ -1128,7 +1128,7 @@ def _setHTTPHandlers():
11281128
_ = urlparse.urlsplit(conf.proxy)
11291129
except Exception, ex:
11301130
errMsg = "invalid proxy address '%s' ('%s')" % (conf.proxy, getSafeExString(ex))
1131-
raise SqlmapSyntaxException, errMsg
1131+
raise SqlmapSyntaxException(errMsg)
11321132

11331133
hostnamePort = _.netloc.split(":")
11341134

@@ -1255,7 +1255,7 @@ def _setSafeVisit():
12551255
kb.safeReq.post = None
12561256
else:
12571257
errMsg = "invalid format of a safe request file"
1258-
raise SqlmapSyntaxException, errMsg
1258+
raise SqlmapSyntaxException(errMsg)
12591259
else:
12601260
if not re.search(r"\Ahttp[s]*://", conf.safeUrl):
12611261
if ":443/" in conf.safeUrl:
@@ -1580,7 +1580,7 @@ def _createTemporaryDirectory():
15801580
except (OSError, IOError), ex:
15811581
errMsg = "there has been a problem while accessing "
15821582
errMsg += "temporary directory location(s) ('%s')" % getSafeExString(ex)
1583-
raise SqlmapSystemException, errMsg
1583+
raise SqlmapSystemException(errMsg)
15841584
else:
15851585
try:
15861586
if not os.path.isdir(tempfile.gettempdir()):
@@ -1607,7 +1607,7 @@ def _createTemporaryDirectory():
16071607
except (OSError, IOError, WindowsError), ex:
16081608
errMsg = "there has been a problem while setting "
16091609
errMsg += "temporary directory location ('%s')" % getSafeExString(ex)
1610-
raise SqlmapSystemException, errMsg
1610+
raise SqlmapSystemException(errMsg)
16111611

16121612
def _cleanupOptions():
16131613
"""

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from lib.core.enums import OS
2020

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

lib/core/wordlist.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def adjust(self):
4747
errMsg = "something appears to be wrong with "
4848
errMsg += "the file '%s' ('%s'). Please make " % (self.current, getSafeExString(ex))
4949
errMsg += "sure that you haven't made any changes to it"
50-
raise SqlmapInstallationException, errMsg
50+
raise SqlmapInstallationException(errMsg)
5151
if len(_.namelist()) == 0:
5252
errMsg = "no file(s) inside '%s'" % self.current
5353
raise SqlmapDataException(errMsg)
@@ -73,7 +73,7 @@ def next(self):
7373
errMsg = "something appears to be wrong with "
7474
errMsg += "the file '%s' ('%s'). Please make " % (self.current, getSafeExString(ex))
7575
errMsg += "sure that you haven't made any changes to it"
76-
raise SqlmapInstallationException, errMsg
76+
raise SqlmapInstallationException(errMsg)
7777
except StopIteration:
7878
self.adjust()
7979
retVal = self.iter.next().rstrip()

lib/parse/cmdline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ def _(self, *args):
909909
for arg in shlex.split(command):
910910
argv.append(getUnicode(arg, encoding=sys.stdin.encoding))
911911
except ValueError, ex:
912-
raise SqlmapSyntaxException, "something went wrong during command line parsing ('%s')" % ex.message
912+
raise SqlmapSyntaxException("something went wrong during command line parsing ('%s')" % ex.message)
913913

914914
for i in xrange(len(argv)):
915915
if argv[i] == "-hh":

lib/parse/payloads.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def loadBoundaries():
7878
errMsg = "something appears to be wrong with "
7979
errMsg += "the file '%s' ('%s'). Please make " % (paths.BOUNDARIES_XML, getSafeExString(ex))
8080
errMsg += "sure that you haven't made any changes to it"
81-
raise SqlmapInstallationException, errMsg
81+
raise SqlmapInstallationException(errMsg)
8282

8383
root = doc.getroot()
8484
parseXmlNode(root)
@@ -93,7 +93,7 @@ def loadPayloads():
9393
errMsg = "something appears to be wrong with "
9494
errMsg += "the file '%s' ('%s'). Please make " % (payloadFilePath, getSafeExString(ex))
9595
errMsg += "sure that you haven't made any changes to it"
96-
raise SqlmapInstallationException, errMsg
96+
raise SqlmapInstallationException(errMsg)
9797

9898
root = doc.getroot()
9999
parseXmlNode(root)

lib/parse/sitemap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def parseSitemap(url, retVal=None):
3232
content = Request.getPage(url=url, raise404=True)[0] if not abortedFlag else ""
3333
except httplib.InvalidURL:
3434
errMsg = "invalid URL given for sitemap ('%s')" % url
35-
raise SqlmapSyntaxException, errMsg
35+
raise SqlmapSyntaxException(errMsg)
3636

3737
for match in re.finditer(r"<loc>\s*([^<]+)", content or ""):
3838
if abortedFlag:

lib/request/basicauthhandler.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@ def http_error_auth_reqed(self, auth_header, host, req, headers):
3030
self.retried_count = 0
3131
else:
3232
if self.retried_count > 5:
33-
raise urllib2.HTTPError(req.get_full_url(), 401, "basic auth failed",
34-
headers, None)
33+
raise urllib2.HTTPError(req.get_full_url(), 401, "basic auth failed", headers, None)
3534
else:
3635
self.retried_count += 1
3736

38-
return urllib2.HTTPBasicAuthHandler.http_error_auth_reqed(
39-
self, auth_header, host, req, headers)
37+
return urllib2.HTTPBasicAuthHandler.http_error_auth_reqed(self, auth_header, host, req, headers)

0 commit comments

Comments
 (0)