From 0d45d38c4924592f8ea59b99a2f05a42aeb533e7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 29 Nov 2023 00:17:55 +0100 Subject: [PATCH] Continued: - renamed $DOMAINS to $DOMAIN_LIST (Bash script) - need to exclude None as possible value for parameter 'path' - added another parked domain --- fba/helpers/blacklist.py | 1 + fba/http/federation.py | 2 +- fba/http/network.py | 6 +++--- fba/models/instances.py | 4 ++-- nodeinfo.sh | 20 ++++++++++---------- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/fba/helpers/blacklist.py b/fba/helpers/blacklist.py index 019a070..6d0c6ff 100644 --- a/fba/helpers/blacklist.py +++ b/fba/helpers/blacklist.py @@ -54,6 +54,7 @@ _blacklist = { "hexbear.net" : "Is a Lemmy instance with malicious JavaScript code (shell commands)", "mastodon.n41.lat" : "Somehow this instance repeatedly causes an OOM here", "fb.me" : "Facebook websites are never Fediverse instances", + "osl.academy" : "Parked domain, no fediverse instance", "icolectiva.org" : "Parked domain, no fediverse instance", "blombus.com" : "Parked domain, no fediverse instance", "eliotberriot.com" : "Parked domain, no fediverse instance", diff --git a/fba/http/federation.py b/fba/http/federation.py index 0523938..a821d23 100644 --- a/fba/http/federation.py +++ b/fba/http/federation.py @@ -275,7 +275,7 @@ def fetch_generator_from_path(domain: str, path: str = "/") -> str: elif path == "": raise ValueError("Parameter 'path' is empty") elif not path.startswith("/"): - raise ValueError("path='{path}' does not start with / but should") + raise ValueError(f"path='{path}' does not start with / but should") software = None diff --git a/fba/http/network.py b/fba/http/network.py index 26fa126..1e694d0 100644 --- a/fba/http/network.py +++ b/fba/http/network.py @@ -66,7 +66,7 @@ def post_json_api(domain: str, path: str, data: str = "", headers: dict = dict() elif path == "": raise ValueError("Parameter 'path' is empty") elif not path.startswith("/"): - raise ValueError("path='{path}' does not start with / but should") + raise ValueError(f"path='{path}' does not start with / but should") elif not isinstance(data, str): raise ValueError(f"data[]='{type(data)}' is not of type 'str'") elif not isinstance(headers, dict): @@ -163,7 +163,7 @@ def get_json_api(domain: str, path: str, headers: dict, timeout: tuple) -> dict: elif path == "": raise ValueError("Parameter 'path' is empty") elif not path.startswith("/"): - raise ValueError("path='{path}' does not start with / but should") + raise ValueError(f"path='{path}' does not start with / but should") elif not isinstance(headers, dict): raise ValueError(f"headers[]='{type(headers)}' is not of type 'list'") elif not isinstance(timeout, tuple): @@ -259,7 +259,7 @@ def fetch_response(domain: str, path: str, headers: dict, timeout: tuple, allow_ elif path == "": raise ValueError("Parameter 'path' is empty") elif not path.startswith("/"): - raise ValueError("path='{path}' does not start with / but should") + raise ValueError(f"path='{path}' does not start with / but should") elif not isinstance(headers, dict): raise ValueError(f"headers[]='{type(headers)}' is not of type 'dict'") elif not isinstance(timeout, tuple): diff --git a/fba/models/instances.py b/fba/models/instances.py index 91af969..3195274 100644 --- a/fba/models/instances.py +++ b/fba/models/instances.py @@ -178,8 +178,8 @@ def add(domain: str, origin: str, command: str, path: str = None, software: str raise ValueError(f"path[]='{type(path)}' is not of type 'str'") elif path == "": raise ValueError("Parameter 'path' is empty") - elif not path.startswith("/"): - raise ValueError("path='{path}' does not start with / but should") + elif path is not None and not path.startswith("/"): + raise ValueError(f"path='{path}' does not start with / but should") elif not isinstance(software, str) and software is not None: raise ValueError(f"software[]='{type(software)}' is not of type 'str'") elif software == "": diff --git a/nodeinfo.sh b/nodeinfo.sh index 3ec3862..f286f05 100755 --- a/nodeinfo.sh +++ b/nodeinfo.sh @@ -1,7 +1,7 @@ #!/bin/sh MODE="" -DOMAINS="" +DOMAIN_LIST="" SOFTWARE_LIST="" if [ "$1" = "--help" ] @@ -10,15 +10,15 @@ then exit 255 elif [ -n "$1" -a -f "$1" ] then - DOMAINS=$(cat "$1") + DOMAIN_LIST=$(cat "$1") MODE="file" elif [ "$1" = "--nodeinfo" ] then - DOMAINS=$(sqlite3 blocks.db "SELECT domain FROM instances WHERE software IS NULL AND nodeinfo_url IS NOT NULL ORDER BY last_updated ASC;") + DOMAIN_LIST=$(sqlite3 blocks.db "SELECT domain FROM instances WHERE software IS NULL AND nodeinfo_url IS NOT NULL ORDER BY last_updated ASC;") MODE="nodeinfo" elif [ "$1" = "--timeout" ] then - DOMAINS=$(sqlite3 blocks.db "SELECT domain FROM instances WHERE last_error_details LIKE '%Timeout%' ORDER BY last_updated ASC;") + DOMAIN_LIST=$(sqlite3 blocks.db "SELECT domain FROM instances WHERE last_error_details LIKE '%Timeout%' ORDER BY last_updated ASC;") MODE="timeout" elif [ "$1" = "--software" -a -f "software.txt" ] then @@ -26,25 +26,25 @@ then MODE="software" elif [ "$1" = "--generator" ] then - DOMAINS=$(sqlite3 blocks.db "SELECT domain FROM instances WHERE detection_mode='GENERATOR' ORDER BY last_updated ASC;") + DOMAIN_LIST=$(sqlite3 blocks.db "SELECT domain FROM instances WHERE detection_mode='GENERATOR' ORDER BY last_updated ASC;") MODE="generator" elif [ "$1" = "--same" ] then - DOMAINS=$(sqlite3 blocks.db "SELECT domain FROM instances WHERE domain=software ORDER BY last_updated ASC;") + DOMAIN_LIST=$(sqlite3 blocks.db "SELECT domain FROM instances WHERE domain=software ORDER BY last_updated ASC;") MODE="same" else - DOMAINS=$(sqlite3 blocks.db "SELECT domain FROM instances WHERE software IS NULL AND nodeinfo_url IS NOT NULL ORDER BY last_updated ASC;") + DOMAIN_LIST=$(sqlite3 blocks.db "SELECT domain FROM instances WHERE software IS NULL AND nodeinfo_url IS NOT NULL ORDER BY last_updated ASC;") fi -if [ -z "${DOMAINS}" -a -z "${SOFTWARE_LIST}" ] +if [ -z "${DOMAIN_LIST}" -a -z "${SOFTWARE_LIST}" ] then echo "$0: No domains or software found! MODE='${MODE}'" exit 255 fi -if [ -n "${DOMAINS}" ] +if [ -n "${DOMAIN_LIST}" ] then - for DOMAIN in ${DOMAINS}; + for DOMAIN in ${DOMAIN_LIST}; do echo "$0: DOMAIN='${DOMAIN}'" if [ -n "$1" -a -z "${MODE}" ] -- 2.39.5