From 98d9258c795e73c5f29158845d0d993634dff702 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 29 Nov 2023 23:08:45 +0100 Subject: [PATCH] Continued: - check domain more again blacklist to avoid bad function invocations - improved some debug logging messages --- fba/models/instances.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/fba/models/instances.py b/fba/models/instances.py index 64873d5..8a46dcb 100644 --- a/fba/models/instances.py +++ b/fba/models/instances.py @@ -84,6 +84,8 @@ def _set_data(key: str, domain: str, value: any): raise ValueError("Parameter 'key' is empty") elif not key in _pending: raise ValueError(f"key='{key}' not found in _pending") + elif blacklist.is_blacklisted(domain): + raise Exception(f"domain='{domain}' is blacklisted but function has been invoked") elif not utils.is_primitive(value): raise ValueError(f"value[]='{type(value)}' is not a primitive type") @@ -98,10 +100,13 @@ def has_pending(domain: str) -> bool: if not is_registered(domain): raise ValueError(f"domain='{domain}' is not registered but function was invoked.") + elif blacklist.is_blacklisted(domain): + raise Exception(f"domain='{domain}' is blacklisted but function has been invoked") has = False + logger.debug("Checking %d _pending array elements ...", len(_pending)) for key in _pending: - logger.debug("key='%s',domain='%s',_pending[key]()=%d", key, domain, len(_pending[key])) + logger.debug("domain='%s',_pending[%s]()=%d", key, domain, key, len(_pending[key])) if domain in _pending[key]: logger.debug("domain='%s' at key='%s' has pending data ...", domain, key) has = True @@ -118,10 +123,13 @@ def update(domain: str): raise Exception(f"domain='{domain}' cannot be updated while not being registered") elif not has_pending(domain): raise Exception(f"domain='{domain}' has no pending instance data, but function invoked") + elif blacklist.is_blacklisted(domain): + raise Exception(f"domain='{domain}' is blacklisted but function has been invoked") - logger.debug("Updating instance data for domain='%s' ...", domain) sql_string = "" fields = list() + + logger.debug("Checking %d _pending array elements ...", len(_pending)) for key in _pending: logger.debug("Checking key='%s',domain='%s'", key, domain) if domain in _pending[key]: -- 2.39.2