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

Skip to content

Commit 7447773

Browse files
committed
Update for consistency (all other enums are using _ in between words)
1 parent ae6ce7d commit 7447773

28 files changed

Lines changed: 122 additions & 122 deletions

lib/controller/checks.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
from lib.core.dicts import FROM_DUMMY_TABLE
4949
from lib.core.enums import DBMS
5050
from lib.core.enums import HEURISTIC_TEST
51-
from lib.core.enums import HTTPHEADER
51+
from lib.core.enums import HTTP_HEADER
5252
from lib.core.enums import HTTPMETHOD
5353
from lib.core.enums import NULLCONNECTION
5454
from lib.core.enums import PAYLOAD
@@ -1118,15 +1118,15 @@ def checkNullConnection():
11181118
try:
11191119
page, headers, _ = Request.getPage(method=HTTPMETHOD.HEAD)
11201120

1121-
if not page and HTTPHEADER.CONTENT_LENGTH in (headers or {}):
1121+
if not page and HTTP_HEADER.CONTENT_LENGTH in (headers or {}):
11221122
kb.nullConnection = NULLCONNECTION.HEAD
11231123

11241124
infoMsg = "NULL connection is supported with HEAD header"
11251125
logger.info(infoMsg)
11261126
else:
1127-
page, headers, _ = Request.getPage(auxHeaders={HTTPHEADER.RANGE: "bytes=-1"})
1127+
page, headers, _ = Request.getPage(auxHeaders={HTTP_HEADER.RANGE: "bytes=-1"})
11281128

1129-
if page and len(page) == 1 and HTTPHEADER.CONTENT_RANGE in (headers or {}):
1129+
if page and len(page) == 1 and HTTP_HEADER.CONTENT_RANGE in (headers or {}):
11301130
kb.nullConnection = NULLCONNECTION.RANGE
11311131

11321132
infoMsg = "NULL connection is supported with GET header "

lib/core/common.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
from lib.core.enums import DBMS
6565
from lib.core.enums import EXPECTED
6666
from lib.core.enums import HEURISTIC_TEST
67-
from lib.core.enums import HTTPHEADER
67+
from lib.core.enums import HTTP_HEADER
6868
from lib.core.enums import HTTPMETHOD
6969
from lib.core.enums import OS
7070
from lib.core.enums import PLACE
@@ -1188,14 +1188,14 @@ def parseTargetUrl():
11881188
if not conf.referer and intersect(REFERER_ALIASES, conf.testParameter, True):
11891189
debugMsg = "setting the HTTP Referer header to the target url"
11901190
logger.debug(debugMsg)
1191-
conf.httpHeaders = filter(lambda (key, value): key != HTTPHEADER.REFERER, conf.httpHeaders)
1192-
conf.httpHeaders.append((HTTPHEADER.REFERER, conf.url))
1191+
conf.httpHeaders = filter(lambda (key, value): key != HTTP_HEADER.REFERER, conf.httpHeaders)
1192+
conf.httpHeaders.append((HTTP_HEADER.REFERER, conf.url))
11931193

11941194
if not conf.host and intersect(HOST_ALIASES, conf.testParameter, True):
11951195
debugMsg = "setting the HTTP Host header to the target url"
11961196
logger.debug(debugMsg)
1197-
conf.httpHeaders = filter(lambda (key, value): key != HTTPHEADER.HOST, conf.httpHeaders)
1198-
conf.httpHeaders.append((HTTPHEADER.HOST, getHostHeader(conf.url)))
1197+
conf.httpHeaders = filter(lambda (key, value): key != HTTP_HEADER.HOST, conf.httpHeaders)
1198+
conf.httpHeaders.append((HTTP_HEADER.HOST, getHostHeader(conf.url)))
11991199

12001200
if conf.url != originalUrl:
12011201
kb.originalUrls[conf.url] = originalUrl

lib/core/enums.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class DUMP_FORMAT:
133133
HTML = "HTML"
134134
SQLITE = "SQLITE"
135135

136-
class HTTPHEADER:
136+
class HTTP_HEADER:
137137
ACCEPT = "Accept"
138138
ACCEPT_CHARSET = "Accept-Charset"
139139
ACCEPT_ENCODING = "Accept-Encoding"

lib/core/option.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
from lib.core.enums import AUTH_TYPE
6868
from lib.core.enums import CUSTOM_LOGGING
6969
from lib.core.enums import DUMP_FORMAT
70-
from lib.core.enums import HTTPHEADER
70+
from lib.core.enums import HTTP_HEADER
7171
from lib.core.enums import HTTPMETHOD
7272
from lib.core.enums import MOBILES
7373
from lib.core.enums import PAYLOAD
@@ -292,9 +292,9 @@ def _parseBurpLog(content):
292292
key, value = line.split(": ", 1)
293293

294294
# Cookie and Host headers
295-
if key.upper() == HTTPHEADER.COOKIE.upper():
295+
if key.upper() == HTTP_HEADER.COOKIE.upper():
296296
cookie = value
297-
elif key.upper() == HTTPHEADER.HOST.upper():
297+
elif key.upper() == HTTP_HEADER.HOST.upper():
298298
if '://' in value:
299299
scheme, value = value.split('://')[:2]
300300
splitValue = value.split(":")
@@ -306,11 +306,11 @@ def _parseBurpLog(content):
306306
# Avoid to add a static content length header to
307307
# conf.httpHeaders and consider the following lines as
308308
# POSTed data
309-
if key.upper() == HTTPHEADER.CONTENT_LENGTH.upper():
309+
if key.upper() == HTTP_HEADER.CONTENT_LENGTH.upper():
310310
params = True
311311

312312
# Avoid proxy and connection type related headers
313-
elif key not in (HTTPHEADER.PROXY_CONNECTION, HTTPHEADER.CONNECTION):
313+
elif key not in (HTTP_HEADER.PROXY_CONNECTION, HTTP_HEADER.CONNECTION):
314314
conf.httpHeaders.append((getUnicode(key), getUnicode(value)))
315315

316316
if CUSTOM_INJECTION_MARK_CHAR in re.sub(PROBLEMATIC_CUSTOM_INJECTION_PATTERNS, "", value or ""):
@@ -1190,16 +1190,16 @@ def _setHTTPExtraHeaders():
11901190
raise SqlmapSyntaxException(errMsg)
11911191

11921192
elif not conf.httpHeaders or len(conf.httpHeaders) == 1:
1193-
conf.httpHeaders.append((HTTPHEADER.ACCEPT_LANGUAGE, "en-us,en;q=0.5"))
1193+
conf.httpHeaders.append((HTTP_HEADER.ACCEPT_LANGUAGE, "en-us,en;q=0.5"))
11941194
if not conf.charset:
1195-
conf.httpHeaders.append((HTTPHEADER.ACCEPT_CHARSET, "ISO-8859-15,utf-8;q=0.7,*;q=0.7"))
1195+
conf.httpHeaders.append((HTTP_HEADER.ACCEPT_CHARSET, "ISO-8859-15,utf-8;q=0.7,*;q=0.7"))
11961196
else:
1197-
conf.httpHeaders.append((HTTPHEADER.ACCEPT_CHARSET, "%s;q=0.7,*;q=0.1" % conf.charset))
1197+
conf.httpHeaders.append((HTTP_HEADER.ACCEPT_CHARSET, "%s;q=0.7,*;q=0.1" % conf.charset))
11981198

11991199
# Invalidating any caching mechanism in between
12001200
# Reference: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
1201-
conf.httpHeaders.append((HTTPHEADER.CACHE_CONTROL, "no-cache,no-store"))
1202-
conf.httpHeaders.append((HTTPHEADER.PRAGMA, "no-cache"))
1201+
conf.httpHeaders.append((HTTP_HEADER.CACHE_CONTROL, "no-cache,no-store"))
1202+
conf.httpHeaders.append((HTTP_HEADER.PRAGMA, "no-cache"))
12031203

12041204
def _defaultHTTPUserAgent():
12051205
"""
@@ -1243,24 +1243,24 @@ def _setHTTPUserAgent():
12431243
except:
12441244
item = MOBILES.IPHONE
12451245

1246-
conf.httpHeaders.append((HTTPHEADER.USER_AGENT, item[1]))
1246+
conf.httpHeaders.append((HTTP_HEADER.USER_AGENT, item[1]))
12471247

12481248
elif conf.agent:
12491249
debugMsg = "setting the HTTP User-Agent header"
12501250
logger.debug(debugMsg)
12511251

1252-
conf.httpHeaders.append((HTTPHEADER.USER_AGENT, conf.agent))
1252+
conf.httpHeaders.append((HTTP_HEADER.USER_AGENT, conf.agent))
12531253

12541254
elif not conf.randomAgent:
12551255
_ = True
12561256

12571257
for header, _ in conf.httpHeaders:
1258-
if header == HTTPHEADER.USER_AGENT:
1258+
if header == HTTP_HEADER.USER_AGENT:
12591259
_ = False
12601260
break
12611261

12621262
if _:
1263-
conf.httpHeaders.append((HTTPHEADER.USER_AGENT, _defaultHTTPUserAgent()))
1263+
conf.httpHeaders.append((HTTP_HEADER.USER_AGENT, _defaultHTTPUserAgent()))
12641264

12651265
else:
12661266
if not kb.userAgents:
@@ -1275,7 +1275,7 @@ def _setHTTPUserAgent():
12751275
warnMsg += "file '%s'" % paths.USER_AGENTS
12761276
logger.warn(warnMsg)
12771277

1278-
conf.httpHeaders.append((HTTPHEADER.USER_AGENT, _defaultHTTPUserAgent()))
1278+
conf.httpHeaders.append((HTTP_HEADER.USER_AGENT, _defaultHTTPUserAgent()))
12791279
return
12801280

12811281
count = len(kb.userAgents)
@@ -1286,7 +1286,7 @@ def _setHTTPUserAgent():
12861286
userAgent = kb.userAgents[randomRange(stop=count - 1)]
12871287

12881288
userAgent = sanitizeStr(userAgent)
1289-
conf.httpHeaders.append((HTTPHEADER.USER_AGENT, userAgent))
1289+
conf.httpHeaders.append((HTTP_HEADER.USER_AGENT, userAgent))
12901290

12911291
infoMsg = "fetched random HTTP User-Agent header from "
12921292
infoMsg += "file '%s': %s" % (paths.USER_AGENTS, userAgent)
@@ -1301,7 +1301,7 @@ def _setHTTPReferer():
13011301
debugMsg = "setting the HTTP Referer header"
13021302
logger.debug(debugMsg)
13031303

1304-
conf.httpHeaders.append((HTTPHEADER.REFERER, conf.referer))
1304+
conf.httpHeaders.append((HTTP_HEADER.REFERER, conf.referer))
13051305

13061306
def _setHTTPCookies():
13071307
"""
@@ -1312,7 +1312,7 @@ def _setHTTPCookies():
13121312
debugMsg = "setting the HTTP Cookie header"
13131313
logger.debug(debugMsg)
13141314

1315-
conf.httpHeaders.append((HTTPHEADER.COOKIE, conf.cookie))
1315+
conf.httpHeaders.append((HTTP_HEADER.COOKIE, conf.cookie))
13161316

13171317
def _setHTTPTimeout():
13181318
"""

lib/core/target.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from lib.core.dicts import DBMS_DICT
2929
from lib.core.dump import dumper
3030
from lib.core.enums import HASHDB_KEYS
31-
from lib.core.enums import HTTPHEADER
31+
from lib.core.enums import HTTP_HEADER
3232
from lib.core.enums import HTTPMETHOD
3333
from lib.core.enums import PLACE
3434
from lib.core.enums import POST_HINT
@@ -247,7 +247,7 @@ def process(match, repl):
247247

248248
httpHeader = httpHeader.title()
249249

250-
if httpHeader == HTTPHEADER.USER_AGENT:
250+
if httpHeader == HTTP_HEADER.USER_AGENT:
251251
conf.parameters[PLACE.USER_AGENT] = urldecode(headerValue)
252252

253253
condition = any((not conf.testParameter, intersect(conf.testParameter, USER_AGENT_ALIASES)))
@@ -256,7 +256,7 @@ def process(match, repl):
256256
conf.paramDict[PLACE.USER_AGENT] = {PLACE.USER_AGENT: headerValue}
257257
testableParameters = True
258258

259-
elif httpHeader == HTTPHEADER.REFERER:
259+
elif httpHeader == HTTP_HEADER.REFERER:
260260
conf.parameters[PLACE.REFERER] = urldecode(headerValue)
261261

262262
condition = any((not conf.testParameter, intersect(conf.testParameter, REFERER_ALIASES)))
@@ -265,7 +265,7 @@ def process(match, repl):
265265
conf.paramDict[PLACE.REFERER] = {PLACE.REFERER: headerValue}
266266
testableParameters = True
267267

268-
elif httpHeader == HTTPHEADER.HOST:
268+
elif httpHeader == HTTP_HEADER.HOST:
269269
conf.parameters[PLACE.HOST] = urldecode(headerValue)
270270

271271
condition = any((not conf.testParameter, intersect(conf.testParameter, HOST_ALIASES)))

lib/request/basic.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from lib.core.data import conf
2424
from lib.core.data import kb
2525
from lib.core.data import logger
26-
from lib.core.enums import HTTPHEADER
26+
from lib.core.enums import HTTP_HEADER
2727
from lib.core.enums import PLACE
2828
from lib.core.exception import SqlmapCompressionException
2929
from lib.core.htmlentities import htmlEntities
@@ -56,28 +56,28 @@ def forgeHeaders(items=None):
5656
headers = dict(("-".join(_.capitalize() for _ in key.split('-')), value) for (key, value) in headers.items())
5757

5858
if conf.cj:
59-
if HTTPHEADER.COOKIE in headers:
59+
if HTTP_HEADER.COOKIE in headers:
6060
for cookie in conf.cj:
61-
if ("%s=" % cookie.name) in headers[HTTPHEADER.COOKIE]:
61+
if ("%s=" % cookie.name) in headers[HTTP_HEADER.COOKIE]:
6262
if kb.mergeCookies is None:
63-
message = "you provided a HTTP %s header value. " % HTTPHEADER.COOKIE
63+
message = "you provided a HTTP %s header value. " % HTTP_HEADER.COOKIE
6464
message += "The target url provided its own cookies within "
65-
message += "the HTTP %s header which intersect with yours. " % HTTPHEADER.SET_COOKIE
65+
message += "the HTTP %s header which intersect with yours. " % HTTP_HEADER.SET_COOKIE
6666
message += "Do you want to merge them in futher requests? [Y/n] "
6767
_ = readInput(message, default="Y")
6868
kb.mergeCookies = not _ or _[0] in ("y", "Y")
6969

7070
if kb.mergeCookies:
7171
_ = lambda x: re.sub("(?i)%s=[^%s]+" % (cookie.name, DEFAULT_COOKIE_DELIMITER), "%s=%s" % (cookie.name, cookie.value), x)
72-
headers[HTTPHEADER.COOKIE] = _(headers[HTTPHEADER.COOKIE])
72+
headers[HTTP_HEADER.COOKIE] = _(headers[HTTP_HEADER.COOKIE])
7373

7474
if PLACE.COOKIE in conf.parameters:
7575
conf.parameters[PLACE.COOKIE] = _(conf.parameters[PLACE.COOKIE])
7676

77-
conf.httpHeaders = [(item[0], item[1] if item[0] != HTTPHEADER.COOKIE else _(item[1])) for item in conf.httpHeaders]
77+
conf.httpHeaders = [(item[0], item[1] if item[0] != HTTP_HEADER.COOKIE else _(item[1])) for item in conf.httpHeaders]
7878

7979
elif not kb.testMode:
80-
headers[HTTPHEADER.COOKIE] += "%s %s=%s" % (DEFAULT_COOKIE_DELIMITER, cookie.name, cookie.value)
80+
headers[HTTP_HEADER.COOKIE] += "%s %s=%s" % (DEFAULT_COOKIE_DELIMITER, cookie.name, cookie.value)
8181

8282
if kb.testMode:
8383
resetCookieJar(conf.cj)

0 commit comments

Comments
 (0)