From 7439ba8c91c89203b422468337d10815664881da Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 4 Jul 2023 12:47:48 +0200 Subject: [PATCH] Continued: - used domain_helper.raise_on(domain) instead --- fba/models/error_log.py | 1 + fba/models/instances.py | 15 ++------------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/fba/models/error_log.py b/fba/models/error_log.py index bfa27f2..47c9eca 100644 --- a/fba/models/error_log.py +++ b/fba/models/error_log.py @@ -28,6 +28,7 @@ logger = logging.getLogger(__name__) def add(domain: str, error: dict): logger.debug("domain='%s',error[]='%s' - CALLED!", domain, type(error)) domain_helper.raise_on(domain) + if config.get("write_error_log").lower() != "true": logger.debug("Writing to error_log is disabled in configuruation file - EXIT!") return diff --git a/fba/models/instances.py b/fba/models/instances.py index 5a374a5..c1ca5ea 100644 --- a/fba/models/instances.py +++ b/fba/models/instances.py @@ -313,20 +313,9 @@ def is_recent(domain: str, column: str = "last_instance_fetch") -> bool: def deobfuscate(char: str, domain: str, blocked_hash: str = None) -> tuple: logger.debug("char='%s',domain='%s',blocked_hash='%s' - CALLED!", char, domain, blocked_hash) + domain_helper.raise_on(domain) - if not isinstance(domain, str): - raise ValueError(f"Parameter domain[]='{type(domain)}' is not 'str'") - elif domain == "": - raise ValueError("Parameter 'domain' is empty") - elif domain.lower() != domain: - raise ValueError(f"Parameter domain='{domain}' must be all lower-case") - elif domain.endswith(".arpa"): - raise ValueError(f"domain='{domain}' is a domain for reversed IP addresses, please don't crawl them!") - elif domain.endswith(".onion"): - raise ValueError(f"domain='{domain}' is a TOR domain, please don't crawl them!") - elif domain.endswith(".tld"): - raise ValueError(f"domain='{domain}' is a fake domain, please don't crawl them!") - elif not isinstance(char, str): + if not isinstance(char, str): raise ValueError(f"Parameter char[]='{type(char)}' is not 'str'") elif char == "": raise ValueError("Parameter 'char' is empty") -- 2.39.5