mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-12-03 16:24:15 +03:00
Fix timeout inconsistency in network requests
Add explicit timeout parameter to urllib.request.urlopen() calls to ensure consistent timeout behavior and prevent hanging in poor network conditions.
This commit is contained in:
parent
03be59042f
commit
ad76636313
|
|
@ -3919,7 +3919,7 @@ def getLatestRevision():
|
|||
req = _urllib.request.Request(url="https://raw.githubusercontent.com/sqlmapproject/sqlmap/master/lib/core/settings.py", headers={HTTP_HEADER.USER_AGENT: fetchRandomAgent()})
|
||||
|
||||
try:
|
||||
content = getUnicode(_urllib.request.urlopen(req).read())
|
||||
content = getUnicode(_urllib.request.urlopen(req, timeout=conf.timeout).read())
|
||||
retVal = extractRegexResult(r"VERSION\s*=\s*[\"'](?P<result>[\d.]+)", content)
|
||||
except:
|
||||
pass
|
||||
|
|
@ -3987,7 +3987,7 @@ def createGithubIssue(errMsg, excMsg):
|
|||
req = _urllib.request.Request(url="https://api.github.com/search/issues?q=%s" % _urllib.parse.quote("repo:sqlmapproject/sqlmap Unhandled exception (#%s)" % key), headers={HTTP_HEADER.USER_AGENT: fetchRandomAgent()})
|
||||
|
||||
try:
|
||||
content = _urllib.request.urlopen(req).read()
|
||||
content = _urllib.request.urlopen(req, timeout=conf.timeout).read()
|
||||
_ = json.loads(content)
|
||||
duplicate = _["total_count"] > 0
|
||||
closed = duplicate and _["items"][0]["state"] == "closed"
|
||||
|
|
@ -4006,7 +4006,7 @@ def createGithubIssue(errMsg, excMsg):
|
|||
req = _urllib.request.Request(url="https://api.github.com/repos/sqlmapproject/sqlmap/issues", data=getBytes(json.dumps(data)), headers={HTTP_HEADER.AUTHORIZATION: "token %s" % token, HTTP_HEADER.USER_AGENT: fetchRandomAgent()})
|
||||
|
||||
try:
|
||||
content = getText(_urllib.request.urlopen(req).read())
|
||||
content = getText(_urllib.request.urlopen(req, timeout=conf.timeout).read())
|
||||
except Exception as ex:
|
||||
content = None
|
||||
_excMsg = getSafeExString(ex)
|
||||
|
|
|
|||
|
|
@ -661,7 +661,7 @@ class Connect(object):
|
|||
|
||||
logger.log(CUSTOM_LOGGING.TRAFFIC_OUT, requestMsg)
|
||||
|
||||
conn = _urllib.request.urlopen(req)
|
||||
conn = _urllib.request.urlopen(req, timeout=conf.timeout)
|
||||
|
||||
if not kb.authHeader and getRequestHeader(req, HTTP_HEADER.AUTHORIZATION) and (conf.authType or "").lower() == AUTH_TYPE.BASIC.lower():
|
||||
kb.authHeader = getUnicode(getRequestHeader(req, HTTP_HEADER.AUTHORIZATION))
|
||||
|
|
|
|||
|
|
@ -750,7 +750,7 @@ def _client(url, options=None):
|
|||
headers["Authorization"] = "Basic %s" % encodeBase64("%s:%s" % (DataStore.username or "", DataStore.password or ""), binary=False)
|
||||
|
||||
req = _urllib.request.Request(url, data, headers)
|
||||
response = _urllib.request.urlopen(req)
|
||||
response = _urllib.request.urlopen(req, timeout=conf.timeout)
|
||||
text = getText(response.read())
|
||||
except:
|
||||
if options:
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ def _search(dork):
|
|||
|
||||
try:
|
||||
req = _urllib.request.Request("https://www.google.com/ncr", headers=requestHeaders)
|
||||
conn = _urllib.request.urlopen(req)
|
||||
conn = _urllib.request.urlopen(req, timeout=conf.timeout)
|
||||
except Exception as ex:
|
||||
errMsg = "unable to connect to Google ('%s')" % getSafeExString(ex)
|
||||
raise SqlmapConnectionException(errMsg)
|
||||
|
|
@ -72,7 +72,7 @@ def _search(dork):
|
|||
|
||||
try:
|
||||
req = _urllib.request.Request(url, headers=requestHeaders)
|
||||
conn = _urllib.request.urlopen(req)
|
||||
conn = _urllib.request.urlopen(req, timeout=conf.timeout)
|
||||
|
||||
requestMsg = "HTTP request:\nGET %s" % url
|
||||
requestMsg += " %s" % _http_client.HTTPConnection._http_vsn_str
|
||||
|
|
@ -138,7 +138,7 @@ def _search(dork):
|
|||
|
||||
try:
|
||||
req = _urllib.request.Request(url, data=getBytes(data), headers=requestHeaders)
|
||||
conn = _urllib.request.urlopen(req)
|
||||
conn = _urllib.request.urlopen(req, timeout=conf.timeout)
|
||||
|
||||
requestMsg = "HTTP request:\nGET %s" % url
|
||||
requestMsg += " %s" % _http_client.HTTPConnection._http_vsn_str
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user