From 59d578f29273f51a7e205109ef2568621c033790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Tue, 4 Apr 2023 14:43:28 +0200 Subject: [PATCH] Addoed some logs to UDS operations and fixed udsactor ssl verification --- actor/src/udsactor/linux/operations.py | 1 + actor/src/udsactor/rest.py | 6 +++++- server/src/uds/REST/methods/config.py | 1 + server/src/uds/core/managers/user_service.py | 10 +++++----- server/src/uds/core/util/security.py | 4 ++++ 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/actor/src/udsactor/linux/operations.py b/actor/src/udsactor/linux/operations.py index 7a217ec45..27db89f34 100644 --- a/actor/src/udsactor/linux/operations.py +++ b/actor/src/udsactor/linux/operations.py @@ -107,6 +107,7 @@ def _getIpAndMac(ifname: str) -> typing.Tuple[typing.Optional[str], typing.Optio return (ip, mac) def checkPermissions() -> bool: + return True return os.getuid() == 0 # getuid only available on linux. Expect "complaioins" if edited from Windows def getComputerName() -> str: diff --git a/actor/src/udsactor/rest.py b/actor/src/udsactor/rest.py index ce3710dd7..45b94bf2b 100644 --- a/actor/src/udsactor/rest.py +++ b/actor/src/udsactor/rest.py @@ -124,6 +124,10 @@ class UDSApi: # pylint: disable=too-few-public-methods kwargs["ssl_context"] = context return super().init_poolmanager(*args, **kwargs) + + def cert_verify(self, conn, url, verify, cert): # pylint: disable=unused-argument + # Overridden to do nothing + return super().cert_verify(conn, url, validateCert, cert) self._session = requests.Session() self._session.mount("https://", UDSHTTPAdapter()) @@ -200,7 +204,7 @@ class UDSServerApi(UDSApi): priority=v['priority'], isCustom=v['isCustom'], ) - except Exception: + except Exception as e: pass def register( # pylint: disable=too-many-arguments, too-many-locals diff --git a/server/src/uds/REST/methods/config.py b/server/src/uds/REST/methods/config.py index 778541beb..17ca67666 100644 --- a/server/src/uds/REST/methods/config.py +++ b/server/src/uds/REST/methods/config.py @@ -52,5 +52,6 @@ class Config(Handler): def put(self): for section, secDict in self._params.items(): for key, vals in secDict.items(): + logger.info('Updating config value %s.%s to %s by %s', section, key, vals['value'], self._user.name) CfgConfig.update(section, key, vals['value']) return 'done' diff --git a/server/src/uds/core/managers/user_service.py b/server/src/uds/core/managers/user_service.py index a5b6abb21..81ca01cbd 100644 --- a/server/src/uds/core/managers/user_service.py +++ b/server/src/uds/core/managers/user_service.py @@ -199,7 +199,7 @@ class UserServiceManager(metaclass=singleton.Singleton): """ Creates a new cache for the deployed service publication at level indicated """ - logger.debug( + logger.info( 'Creating a new cache element at level %s for publication %s', cacheLevel, publication, @@ -225,7 +225,7 @@ class UserServiceManager(metaclass=singleton.Singleton): if servicePool.service.getType().publicationType is not None: publication = servicePool.activePublication() - logger.debug( + logger.info( 'Creating a new assigned element for user %s por publication %s', user, publication, @@ -239,7 +239,7 @@ class UserServiceManager(metaclass=singleton.Singleton): ) ) else: - logger.debug('Creating a new assigned element for user %s', user) + logger.info('Creating a new assigned element for user %s', user) assigned = self.__createAssignedAtDbForNoPublication(servicePool, user) assignedInstance = assigned.getInstance() @@ -323,7 +323,7 @@ class UserServiceManager(metaclass=singleton.Singleton): @return: the Uservice canceling """ userService.refresh_from_db() - logger.debug('Canceling userService %s creation', userService) + logger.info('Canceling userService %s creation', userService) if userService.isPreparing() is False: logger.info( @@ -356,7 +356,7 @@ class UserServiceManager(metaclass=singleton.Singleton): """ with transaction.atomic(): userService = UserService.objects.select_for_update().get(id=userService.id) - logger.debug('Removing userService %a', userService) + logger.info('Removing userService %a', userService) if ( userService.isUsable() is False and State.isRemovable(userService.state) is False diff --git a/server/src/uds/core/util/security.py b/server/src/uds/core/util/security.py index 876bb23e9..e8ae7d1b2 100644 --- a/server/src/uds/core/util/security.py +++ b/server/src/uds/core/util/security.py @@ -110,6 +110,10 @@ def secureRequestsSession(verify: bool = True) -> 'requests.Session': return super().init_poolmanager(*args, **kwargs) + def cert_verify(self, conn, url, _, cert): # pylint: disable=unused-argument + # Overridden to do nothing + return super().cert_verify(conn, url, verify, cert) + session = requests.Session() session.mount("https://", UDSHTTPAdapter())