From 0aafe5700db84daee4c5ff1ea789e4e0e1037610 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 24 Jun 2023 09:39:12 +0200 Subject: [PATCH] Continued: - check if domain is wanted before trying to deobfuscate it --- fba/networks/pleroma.py | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/fba/networks/pleroma.py b/fba/networks/pleroma.py index 84a535f..f8fb931 100644 --- a/fba/networks/pleroma.py +++ b/fba/networks/pleroma.py @@ -109,11 +109,8 @@ def fetch_blocks(domain: str, nodeinfo_url: str) -> list: if blocked == "": logger.warning("blocked is empty after tidyup.domain(): domain='%s',block_level='%s'", domain, block_level) continue - elif blocked.endswith(".arpa"): - logger.debug("blocked='%s' is a reverse IP address - SKIPPED!", blocked) - continue - elif blocked.endswith(".tld"): - logger.debug("blocked='%s' is a fake domain - SKIPPED!", blocked) + elif not utils.is_domain_wanted(blocked): + logger.debug("blocked='%s' is not wanted - SKIPPED!", blocked) continue logger.debug("Invoking utils.deobfuscate_domain(%s, %s) ...", blocked, domain) @@ -145,11 +142,8 @@ def fetch_blocks(domain: str, nodeinfo_url: str) -> list: if blocked == "": logger.warning("blocked is empty after tidyup.domain(): domain='%s',block_level='%s'", domain, block_level) continue - elif blocked.endswith(".arpa"): - logger.debug("blocked='%s' is a reverse IP address - SKIPPED!", blocked) - continue - elif blocked.endswith(".tld"): - logger.debug("blocked='%s' is a fake domain - SKIPPED!", blocked) + elif not utils.is_domain_wanted(blocked): + logger.debug("blocked='%s' is not wanted - SKIPPED!", blocked) continue logger.debug("Invoking utils.deobfuscate_domain(%s, %s) ...", blocked, domain) @@ -221,14 +215,13 @@ def fetch_blocks(domain: str, nodeinfo_url: str) -> list: if blocked == "": logger.warning("blocked is empty after tidyup.domain(): domain='%s',block_level='%s'", domain, block_level) continue + elif not utils.is_domain_wanted(blocked): + logger.debug("blocked='%s' is not wanted - SKIPPED!", blocked) + continue logger.debug("Invoking utils.deobfuscate_domain(%s, %s) ...", blocked, domain) blocked = utils.deobfuscate_domain(blocked, domain) - logger.debug("blocked='%s' - DEOBFUSCATED!", blocked) - if not utils.is_domain_wanted(blocked): - logger.debug("blocked='%s' is not wanted - SKIPPED!", blocked) - continue logger.debug("Checking %d blockdict records ...", len(blockdict)) for block in blockdict: @@ -298,14 +291,13 @@ def fetch_blocks(domain: str, nodeinfo_url: str) -> list: if blocked == "": logger.warning("blocked is empty after tidyup.domain(): domain='%s',block_level='%s'", domain, block_level) continue + elif not utils.is_domain_wanted(blocked): + logger.warning("blocked='%s' is not wanted - SKIPPED!", blocked) + continue logger.debug("Invoking utils.deobfuscate_domain(%s, %s) ...", blocked, domain) blocked = utils.deobfuscate_domain(blocked, domain) - logger.debug("blocked='%s' - DEOBFUSCATED!", blocked) - if not utils.is_domain_wanted(blocked): - logger.warning("blocked='%s' is not wanted - SKIPPED!", blocked) - continue logger.debug("Appending blocker='%s',blocked='%s',reason='%s',block_level='%s' ...",domain, blocked, reason, block_level) blockdict.append({ -- 2.39.5