From: Roland Häder Date: Sat, 26 Aug 2023 21:03:37 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f2f2ba6db3b0d001cef2ac3e662d61124e9d2a77;p=fba.git Continued: - warn about invalid SHA256 domain digests (aka. hashes) - some mastodon instances maybe not include them at all? --- diff --git a/fba/networks/mastodon.py b/fba/networks/mastodon.py index c1eb6b7..4eebffe 100644 --- a/fba/networks/mastodon.py +++ b/fba/networks/mastodon.py @@ -15,6 +15,7 @@ # along with this program. If not, see . import logging +import validators import bs4 @@ -202,6 +203,9 @@ def fetch_blocks(domain: str, nodeinfo_url: str) -> list: elif block["severity"] in ["accept", "accepted"]: logger.debug("block[domain]='%s' has unwanted severity level '%s' - SKIPPED!", block["domain"], block["severity"]) continue + elif "digest" in block and validators.hashes.sha256(block["digest"]): + logger.warning("block[domain]='%s' has invalid block[digest]='%s' - SKIPPED!", block["domain"], block["digest"]) + continue reason = tidyup.reason(block["comment"]) if "comment" in block and block["comment"] is not None and block["comment"] != "" else None @@ -209,7 +213,7 @@ def fetch_blocks(domain: str, nodeinfo_url: str) -> list: blocklist.append({ "blocker" : domain, "blocked" : block["domain"], - "hash" : block["digest"], + "hash" : block["digest"] if "digest" in block else None, "reason" : reason, "block_level": blocks.alias_block_level(block["severity"]), })