Fixing CI/CD issues with keep-alive

This commit is contained in:
Miroslav Stampar 2026-02-02 12:19:20 +01:00
parent 96645deee1
commit 4af3195041
3 changed files with 24 additions and 12 deletions

View File

@ -188,7 +188,7 @@ c1cb56f2a43e9f2f6b25d5f3d504e856ea21df6fc14af5e37b1000feef2bdb5a lib/core/optio
48797d6c34dd9bb8a53f7f3794c85f4288d82a9a1d6be7fcf317d388cb20d4b3 lib/core/replication.py 48797d6c34dd9bb8a53f7f3794c85f4288d82a9a1d6be7fcf317d388cb20d4b3 lib/core/replication.py
0b8c38a01bb01f843d94a6c5f2075ee47520d0c4aa799cecea9c3e2c5a4a23a6 lib/core/revision.py 0b8c38a01bb01f843d94a6c5f2075ee47520d0c4aa799cecea9c3e2c5a4a23a6 lib/core/revision.py
888daba83fd4a34e9503fe21f01fef4cc730e5cde871b1d40e15d4cbc847d56c lib/core/session.py 888daba83fd4a34e9503fe21f01fef4cc730e5cde871b1d40e15d4cbc847d56c lib/core/session.py
8508162b2a95e54102ee8aec95888d7e2061d73b7d0e9ecd47d4f5e22ca94820 lib/core/settings.py 87350eb153acd7d278f60b5e2cabc43b7b98cdaf1642433ac3f7a55d54198b56 lib/core/settings.py
cd5a66deee8963ba8e7e9af3dd36eb5e8127d4d68698811c29e789655f507f82 lib/core/shell.py cd5a66deee8963ba8e7e9af3dd36eb5e8127d4d68698811c29e789655f507f82 lib/core/shell.py
bcb5d8090d5e3e0ef2a586ba09ba80eef0c6d51feb0f611ed25299fbb254f725 lib/core/subprocessng.py bcb5d8090d5e3e0ef2a586ba09ba80eef0c6d51feb0f611ed25299fbb254f725 lib/core/subprocessng.py
d35650179816193164a5f177102f18379dfbe6bb6d40fbb67b78d907b41c8038 lib/core/target.py d35650179816193164a5f177102f18379dfbe6bb6d40fbb67b78d907b41c8038 lib/core/target.py
@ -618,7 +618,7 @@ edf23e7105539d700a1ae1bc52436e57e019b345a7d0227e4d85b6353ef535fa thirdparty/ide
d846fdc47a11a58da9e463a948200f69265181f3dbc38148bfe4141fade10347 thirdparty/identywaf/LICENSE d846fdc47a11a58da9e463a948200f69265181f3dbc38148bfe4141fade10347 thirdparty/identywaf/LICENSE
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 thirdparty/__init__.py e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 thirdparty/__init__.py
879d96f2460bc6c79c0db46b5813080841c7403399292ce76fe1dc0a6ed353d8 thirdparty/keepalive/__init__.py 879d96f2460bc6c79c0db46b5813080841c7403399292ce76fe1dc0a6ed353d8 thirdparty/keepalive/__init__.py
c7ac7253fa450030f9c42f11bb19689055bb8c39621bcfbeca856ba3c9342760 thirdparty/keepalive/keepalive.py ae394bfae5204dfeffeccc15c356d9bf21708f9e48016681cfb8040ff8857998 thirdparty/keepalive/keepalive.py
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 thirdparty/magic/__init__.py e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 thirdparty/magic/__init__.py
4d89a52f809c28ce1dc17bb0c00c775475b8ce01c2165942877596a6180a2fd8 thirdparty/magic/magic.py 4d89a52f809c28ce1dc17bb0c00c775475b8ce01c2165942877596a6180a2fd8 thirdparty/magic/magic.py
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 thirdparty/multipart/__init__.py e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 thirdparty/multipart/__init__.py

View File

@ -20,7 +20,7 @@ from lib.core.enums import OS
from thirdparty import six from thirdparty import six
# sqlmap version (<major>.<minor>.<month>.<monthly commit>) # sqlmap version (<major>.<minor>.<month>.<monthly commit>)
VERSION = "1.10.2.3" VERSION = "1.10.2.4"
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable" TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34} TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE) VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

View File

@ -164,7 +164,9 @@ class ConnectionManager:
def set_ready(self, connection, ready): def set_ready(self, connection, ready):
self._lock.acquire() self._lock.acquire()
try:
if connection in self._readymap: self._readymap[connection] = ready if connection in self._readymap: self._readymap[connection] = ready
finally:
self._lock.release() self._lock.release()
def get_ready_conn(self, host): def get_ready_conn(self, host):
@ -258,6 +260,16 @@ class KeepAliveHandler:
if DEBUG: DEBUG.info("STATUS: %s, %s", r.status, r.reason) if DEBUG: DEBUG.info("STATUS: %s, %s", r.status, r.reason)
if not r.will_close:
try:
headers = getattr(r, 'msg', None)
if headers:
c_head = headers.get("connection")
if c_head and "close" in c_head.lower():
r.will_close = True
except Exception:
pass
# if not a persistent connection, don't try to reuse it # if not a persistent connection, don't try to reuse it
if r.will_close: if r.will_close:
if DEBUG: DEBUG.info('server will close connection, discarding') if DEBUG: DEBUG.info('server will close connection, discarding')
@ -322,16 +334,16 @@ class KeepAliveHandler:
def _start_transaction(self, h, req): def _start_transaction(self, h, req):
try: try:
if req.data is not None: if req.data:
data = req.data data = req.data
if hasattr(req, 'selector'): if hasattr(req, 'selector'):
h.putrequest(req.get_method() or 'POST', req.selector, skip_host=req.has_header("Host"), skip_accept_encoding=req.has_header("Accept-encoding")) h.putrequest(req.get_method() or 'POST', req.selector, skip_host=req.has_header("Host"), skip_accept_encoding=req.has_header("Accept-encoding"))
else: else:
h.putrequest(req.get_method() or 'POST', req.get_selector(), skip_host=req.has_header("Host"), skip_accept_encoding=req.has_header("Accept-encoding")) h.putrequest(req.get_method() or 'POST', req.get_selector(), skip_host=req.has_header("Host"), skip_accept_encoding=req.has_header("Accept-encoding"))
if not req.has_header('Content-type'): if 'Content-type' not in req.headers:
h.putheader('Content-type', h.putheader('Content-type',
'application/x-www-form-urlencoded') 'application/x-www-form-urlencoded')
if not req.has_header('Content-length'): if 'Content-length' not in req.headers:
h.putheader('Content-length', '%d' % len(data)) h.putheader('Content-length', '%d' % len(data))
else: else:
if hasattr(req, 'selector'): if hasattr(req, 'selector'):
@ -341,17 +353,17 @@ class KeepAliveHandler:
except (socket.error, _http_client.HTTPException) as err: except (socket.error, _http_client.HTTPException) as err:
raise _urllib.error.URLError(err) raise _urllib.error.URLError(err)
if not req.has_header('Connection'): if 'Connection' not in req.headers:
h.putheader('Connection', 'keep-alive') h.putheader('Connection', 'keep-alive')
for args in self.parent.addheaders: for args in self.parent.addheaders:
if not req.has_header(args[0]): if args[0] not in req.headers:
h.putheader(*args) h.putheader(*args)
for k, v in req.headers.items(): for k, v in req.headers.items():
h.putheader(k, v) h.putheader(k, v)
h.endheaders() h.endheaders()
if req.data is not None: if req.data:
h.send(data) h.send(req.data)
def _get_connection(self, host): def _get_connection(self, host):
raise NotImplementedError() raise NotImplementedError()