From 3fc86482dce0eaa8fbdeb40594c7a59850ed7911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Fri, 31 Mar 2023 15:41:59 +0200 Subject: [PATCH 1/2] Some minor typing fixes --- server/src/uds/core/ui/user_interface.py | 2 +- server/src/uds/core/workers/__init__.py | 4 ++-- .../workers/servicepools_cache_updater.py | 4 ++-- server/src/uds/transports/__init__.py | 2 +- server/src/uds/web/views/service.py | 22 +++++++++---------- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/server/src/uds/core/ui/user_interface.py b/server/src/uds/core/ui/user_interface.py index 6d27378a7..4d3d99f7d 100644 --- a/server/src/uds/core/ui/user_interface.py +++ b/server/src/uds/core/ui/user_interface.py @@ -621,7 +621,7 @@ class gui: """ - def __init__(self, **options): + def __init__(self, **options) -> None: super().__init__(**options) self._isSerializable: bool = options.get('serializable', '') != '' self._type(gui.InputField.HIDDEN_TYPE) diff --git a/server/src/uds/core/workers/__init__.py b/server/src/uds/core/workers/__init__.py index b051b0d0a..bfbafdceb 100644 --- a/server/src/uds/core/workers/__init__.py +++ b/server/src/uds/core/workers/__init__.py @@ -48,8 +48,8 @@ def initialize() -> None: from uds.core.managers import taskManager # Dinamycally import children of this package. - pkgpath = os.path.dirname(sys.modules[__name__].__file__) - for _, name, _ in pkgutil.iter_modules([pkgpath]): + pkgpath = os.path.dirname(sys.modules[__name__].__file__) # type: ignore + for _, name, _ in pkgutil.iter_modules([pkgpath]): # type: ignore logger.debug('Importing worker %s', name) # __import__(name, globals(), locals(), [], 1) importlib.import_module('.' + name, __name__) # import module diff --git a/server/src/uds/core/workers/servicepools_cache_updater.py b/server/src/uds/core/workers/servicepools_cache_updater.py index 7bdf4ae78..c791d1d92 100644 --- a/server/src/uds/core/workers/servicepools_cache_updater.py +++ b/server/src/uds/core/workers/servicepools_cache_updater.py @@ -95,7 +95,7 @@ class ServiceCacheUpdater(Job): for servicePool in servicePoolsNeedingCaching: servicePool.userServices.update() # Cleans cached queries # If this deployedService don't have a publication active and needs it, ignore it - spServiceInstance = servicePool.service.getInstance() + spServiceInstance = servicePool.service.getInstance() # type: ignore if ( servicePool.activePublication() is None @@ -146,7 +146,7 @@ class ServiceCacheUpdater(Job): ) inAssigned: int = ( servicePool.assignedUserServices() - .filter(userServiceManager().getStateFilter(servicePool.service)) + .filter(userServiceManager().getStateFilter(servicePool.service)) # type: ignore .count() ) # if we bypasses max cache, we will reduce it in first place. This is so because this will free resources on service provider diff --git a/server/src/uds/transports/__init__.py b/server/src/uds/transports/__init__.py index 6d05c4eec..b78f85875 100644 --- a/server/src/uds/transports/__init__.py +++ b/server/src/uds/transports/__init__.py @@ -57,7 +57,7 @@ def __init__(): from uds.core import transports # Dinamycally import children of this package. The __init__.py files of each module must import classes so they can get registered - pkgpath = os.path.dirname(sys.modules[__name__].__file__) + pkgpath = os.path.dirname(sys.modules[__name__].__file__) # type: ignore for _, name, _ in pkgutil.iter_modules([pkgpath]): # __import__(name, globals(), locals(), [], 1) importlib.import_module('.' + name, __name__) # import module diff --git a/server/src/uds/web/views/service.py b/server/src/uds/web/views/service.py index b355dea3e..faa61c3d3 100644 --- a/server/src/uds/web/views/service.py +++ b/server/src/uds/web/views/service.py @@ -38,7 +38,7 @@ from django.http import HttpResponse from django.views.decorators.cache import cache_page, never_cache from uds.core.auths.auth import webLoginRequired, webPassword -from uds.core.managers import userServiceManager +from uds.core.managers.user_service import UserServiceManager from uds.core.ui.images import DEFAULT_IMAGE from uds.core.util.model import processUuid from uds.models import Transport, Image @@ -66,7 +66,7 @@ def transportOwnLink( # For type checkers to "be happy" try: - res = userServiceManager().getService( + res = UserServiceManager().getService( request.user, request.os, request.ip, idService, idTransport ) ip, userService, iads, trans, itrans = res @@ -162,12 +162,12 @@ def userServiceStatus( userService: typing.Optional['UserService'] = None status = 'running' # If service exists (meta or not) - if userServiceManager().isMetaService(idService): - userService = userServiceManager().locateMetaService( + if UserServiceManager().isMetaService(idService): + userService = UserServiceManager().locateMetaService( user=request.user, idService=idService ) else: - userService = userServiceManager().locateUserService( + userService = UserServiceManager().locateUserService( user=request.user, idService=idService, create=False ) if userService: @@ -196,11 +196,11 @@ def userServiceStatus( def action( request: 'ExtendedHttpRequestWithUser', idService: str, actionString: str ) -> HttpResponse: - userService = userServiceManager().locateMetaService( + userService = UserServiceManager().locateMetaService( request.user, idService ) if not userService: - userService = userServiceManager().locateUserService( + userService = UserServiceManager().locateUserService( request.user, idService, create=False ) @@ -220,12 +220,12 @@ def action( ), log.WEB, ) - userServiceManager().requestLogoff(userService) + UserServiceManager().requestLogoff(userService) userService.release() elif ( actionString == 'reset' and userService.deployed_service.allow_users_reset - and userService.deployed_service.service.getType().canReset + and userService.deployed_service.service.getType().canReset # type: ignore ): rebuild = True log.doLog( @@ -236,8 +236,8 @@ def action( ), log.WEB, ) - # userServiceManager().requestLogoff(userService) - userServiceManager().reset(userService) + # UserServiceManager().requestLogoff(userService) + UserServiceManager().reset(userService) if rebuild: From d43167707c66af1b4285571ffd24eb475f7758cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Fri, 31 Mar 2023 16:22:02 +0200 Subject: [PATCH 2/2] Removed TLS1.0 & TLS1.1 support --- client-py3/full/src/UDSClientLauncher.py | 2 +- client-py3/full/src/uds/forward.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client-py3/full/src/UDSClientLauncher.py b/client-py3/full/src/UDSClientLauncher.py index aa823ec18..d27b74dc6 100644 --- a/client-py3/full/src/UDSClientLauncher.py +++ b/client-py3/full/src/UDSClientLauncher.py @@ -45,7 +45,7 @@ class UdsApplication(QtWidgets.QApplication): tunnel.kill() def event(self, evnt: QtCore.QEvent) -> bool: - if evnt.type() == QtCore.QEvent.FileOpen: + if evnt.type() == QtCore.QEvent.Type.FileOpen: fe = typing.cast(QtGui.QFileOpenEvent, evnt) logger.debug('Got url: %s', fe.url().url()) fe.accept() diff --git a/client-py3/full/src/uds/forward.py b/client-py3/full/src/uds/forward.py index 694352716..743ef7fb7 100644 --- a/client-py3/full/src/uds/forward.py +++ b/client-py3/full/src/uds/forward.py @@ -216,7 +216,7 @@ class ForwardThread(threading.Thread): class SubHandler(Handler): chain_host = self.redirectHost chain_port = self.redirectPort - ssh_transport = self.client.get_transport() + ssh_transport = self.client.get_transport() # type: ignore event = self.stopEvent thread = self