if "domain" not in row:
logger.warning("row='%s' does not contain element 'domain' - SKIPPED!", row)
continue
- elif row["domain"] is None or row["domain"] == "":
+ elif row["domain"] in [None, ""]:
logger.debug("row[domain]='%s' is empty - SKIPPED!", row["domain"])
continue
if "domain" not in entry:
logger.warning("entry()=%d does not contain 'domain' - SKIPPED!", len(entry))
continue
- elif entry["domain"] is None or entry["domain"] == "":
+ elif entry["domain"] in [None, ""]:
logger.debug("entry[domain]='%s' is empty - SKIPPED!", entry["domain"])
continue
elif not domain_helper.is_wanted(entry["domain"]):
block["reason"] = tidyup.reason(block["reason"]) if block["reason"] is not None and block["reason"] != "" else None
logger.debug("blocked='%s',reason='%s' - AFTER!", block["blocked"], block["reason"])
- if block["blocked"] is None or block["blocked"] == "":
+ if block["blocked"] in [None, ""]:
logger.warning("block[blocked]='%s' is empty, blocker='%s'", block["blocked"], blocker)
continue
elif block["blocked"].endswith(".onion"):
nodeinfo_url = row["nodeinfo_url"]
logger.debug("Looking up instance by domain, blocked='%s'", block["blocked"])
- if block["blocked"] is None or block["blocked"] == "":
+ if block["blocked"] in [None, ""]:
logger.debug("block[blocked]='%s' is empty - SKIPPED!", block["blocked"])
continue
domain = tidyup.domain(domain) if domain not in [None, ""] else None
logger.debug("domain='%s' - AFTER!", domain)
- if domain is None or domain == "":
+ if domain in [None, ""]:
logger.debug("domain='%s' is empty after tidyup.domain() - SKIPPED!", domain)
continue
domain = tidyup.domain(domain) if domain not in[None, ""] else None
logger.debug("domain='%s' - AFTER!", domain)
- if domain is None or domain == "":
+ if domain in [None, ""]:
logger.debug("domain='%s' is empty after tidyup.domain() - SKIPPED!", domain)
continue
domain = tidyup.domain(href) if href not in [None, ""] else None
logger.debug("domain='%s' - AFTER!", domain)
- if domain is None or domain == "":
+ if domain in [None, ""]:
logger.debug("domain='%s' is empty after tidyup.domain() - SKIPPED!", domain)
continue
domain = tidyup.domain(domain) if domain not in[None, ""] else None
logger.debug("domain='%s' - AFTER!", domain)
- if domain is None or domain == "":
+ if domain in [None, ""]:
logger.debug("domain='%s' is empty after tidyup.domain() - SKIPPED!", domain)
continue
elif not domain_helper.is_wanted(domain):
domain = tidyup.domain(row.contents[0]) if row.contents[0] not in [None, ""] else None
logger.debug("domain='%s' - AFTER!", domain)
- if domain is None or domain == "":
+ if domain in [None, ""]:
logger.debug("domain='%s' is empty after tidyup.domain() - SKIPPED!", domain)
continue
logger.debug("blocking()=%d", len(blocking))
if len(blocking) == 0:
+ logger.debug("Empty blocking list, trying individual fetch_blocks() for row[software]='%s' ...", row["software"])
if row["software"] == "pleroma":
logger.debug("domain='%s',software='%s'", row["domain"], row["software"])
blocking = pleroma.fetch_blocks(row["domain"])
domain = tidyup.domain(row["hostname"]) if row["hostname"] not in [None, ""] else None
logger.debug("domain='%s' - AFTER!", domain)
- if domain is None or domain == "":
+ if domain in [None, ""]:
logger.debug("domain='%s' is empty after tidyup.domain(): row[hostname]='%s' - SKIPPED!", domain, row["hostname"])
continue
domain = tidyup.domain(domain) if domain not in[None, ""] else None
logger.debug("domain='%s' - AFTER!", domain)
- if domain is None or domain == "":
+ if domain in [None, ""]:
logger.debug("domain='%s' is empty after tidyup.domain() from origin='%s' - SKIPPED!", domain, row["domain"])
continue
elif domain not in peers:
domain = tidyup.domain(domain) if domain not in[None, ""] else None
logger.debug("domain='%s' - AFTER!", domain)
- if domain is None or domain == "":
+ if domain in [None, ""]:
logger.debug("domain='%s' is empty after tidyup.domain() from origin='%s' - SKIPPED!", domain, row["domain"])
continue
elif domain not in peers:
domain = tidyup.domain(domain) if domain not in[None, ""] else None
logger.debug("domain='%s' - AFTER!", domain)
- if domain is None or domain == "":
+ if domain in [None, ""]:
logger.debug("domain='%s' is empty after tidyup.domain() from origin='%s' - SKIPPED!", domain, row["domain"])
continue
elif domain not in peers:
blocked = utils.deobfuscate(blocked, blocker)
logger.debug("blocked='%s' - AFTER!", blocked)
+ logger.debug("Checking if blocker='%s' has pending data ...", blocker)
if instances.has_pending(blocker):
logger.debug("Flushing updates for blocker='%s' ...", blocker)
instances.update(blocker)
+ logger.debug("Checking blocked='%s' if wanted and recent ...", blocked)
if not domain_helper.is_wanted(blocked):
logger.debug("blocked='%s' is not wanted - SKIPPED!", blocked)
return False
cnt = cnt + 1
logger.debug("domain='%s',severity='%s',reject_media='%s',reject_reports='%s'", domain, severity, reject_media, reject_reports)
- if domain is None or domain == "":
+ if domain in [None, ""]:
logger.debug("domain='%s' is empty - SKIPPED!", domain)
continue
elif domain.endswith(".onion"):
logger.info("Checking %d instance(s) from domain='%s',software='%s',depth=%d ...", len(peerlist), domain, software, _DEPTH)
for instance in peerlist:
logger.debug("instance[%s]='%s'", type(instance), instance)
- if instance is None or instance == "":
+ if instance in [None, ""]:
logger.debug("instance[%s]='%s' is either None or empty - SKIPPED!", type(instance), instance)
continue
instance = tidyup.domain(instance) if isinstance(instance, str) and instance != "" else None
logger.debug("instance='%s' - AFTER!", instance)
- if instance is None or instance == "":
+ if instance in [None, ""]:
logger.warning("instance='%s' is empty after tidyup.domain(), domain='%s'", instance, domain)
continue
elif ".." in instance:
logger.debug("Generator for domain='%s' is: '%s'", domain, software)
logger.debug("software[%s]='%s'", type(software), software)
- if software is None or software == "":
+ if software in [None, ""]:
logger.debug("Returning None - EXIT!")
return None
logger.debug("Adding %d peer(s) to peers list ...", len(rows[key]))
for peer in rows[key]:
logger.debug("peer[%s]='%s' - BEFORE!", type(peer), peer)
- if peer is None or peer == "":
+ if peer in [None, ""]:
logger.debug("peer is empty - SKIPPED")
continue
elif isinstance(peer, dict) and "domain" in peer:
from fba import utils
+from fba.helpers import blacklist
from fba.helpers import config
from fba.helpers import cookies
from fba.helpers import domain as domain_helper
logger.debug("domain='%s',path='%s',data='%s',headers()=%d - CALLED!", domain, path, data, len(headers))
domain_helper.raise_on(domain)
- if not isinstance(path, str):
+ if blacklist.is_blacklisted(domain):
+ raise ValueError(f"domain='{domain}' is blacklisted but function was invoked")
+ elif not isinstance(path, str):
raise ValueError(f"path[]='{type(path)}' is not of type 'str'")
elif path == "":
raise ValueError("Parameter 'path' is empty")
logger.debug("domain='%s',path='%s',timeout()=%d - CALLED!", domain, path, len(timeout))
domain_helper.raise_on(domain)
- if not isinstance(path, str):
+ if blacklist.is_blacklisted(domain):
+ raise ValueError(f"domain='{domain}' is blacklisted but function was invoked")
+ elif not isinstance(path, str):
raise ValueError(f"path[]='{type(path)}' is not of type 'str'")
elif path == "":
raise ValueError("Parameter 'path' is empty")
logger.debug("domain='%s',blocklist()=%d - CALLED!", domain, len(blocklist))
domain_helper.raise_on(domain)
- if not isinstance(blocklist, list):
+ if blacklist.is_blacklisted(domain):
+ raise ValueError(f"domain='{domain}' is blacklisted but function was invoked")
+ elif not isinstance(blocklist, list):
raise ValueError(f"Parameter blocklist[]='{type(blocklist)}' is not of type 'list'")
elif len(blocklist) == 0:
raise ValueError("Parameter 'blocklist' is empty")
logger.debug("blocklist()=%d", len(blocklist))
for block in blocklist:
logger.debug("block[%s]='%s'", type(block), block)
- if block["reason"] is None or block["reason"] == '':
+ if block["reason"] in [None, ""]:
logger.debug("block[blocked]='%s' is being blocked with no reason specified", block["blocked"])
message = message + block["blocked"] + " with unspecified reason\n"
else:
logger.debug("domain='%s',path='%s',headers()=%d,timeout='%s',allow_redirects='%s' - CALLED!", domain, path, len(headers), timeout, allow_redirects)
domain_helper.raise_on(domain)
- if not isinstance(path, str):
+ if blacklist.is_blacklisted(domain):
+ raise ValueError(f"domain='{domain}' is blacklisted but function was invoked")
+ elif not isinstance(path, str):
raise ValueError(f"Parameter path[]='{type(path)}' is not of type 'str'")
elif path == "":
raise ValueError("Parameter 'path' is empty")
reason = tidyup.reason(line.find_all("td")[1].text)
logger.debug("blocked='%s',reason='%s' - AFTER!", blocked, reason)
- if blocked is None or blocked == "":
+ if blocked in [None, ""]:
logger.warning("line[]='%s' returned empty blocked domain - SKIPPED!", type(line))
continue
elif not domain_helper.is_wanted(blocked):
content = str(header.contents[0])
logger.debug("content[%s]='%s' - AFTER!", type(content), content)
- if content is None or content == "":
+ if content in [None, ""]:
logger.debug("domain='%s' has returned empty header='%s' - SKIPPED!", domain, header)
continue
elif not isinstance(content, str):
blocked = tidyup.domain(tag.contents[0]) if tag.contents[0] != "" else None
logger.debug("blocked='%s'", blocked)
- if blocked is None or blocked == "":
+ if blocked in [None, ""]:
logger.warning("blocked='%s' is empty after tidyup.domain() - SKIPPED!", tag.contents[0])
continue
elif not domain_helper.is_wanted(blocked):
peer = tidyup.domain(text) if text != "" else None
logger.debug("peer='%s' - AFTER", peer)
- if peer is None or peer == "":
+ if peer in [None, ""]:
logger.warning("peer='%s' is empty, text='%s' - SKIPPED!", peer, text)
continue
elif not domain_helper.is_wanted(peer):
peer = tidyup.domain(row["domain"])
logger.debug("peer='%s' - AFTER!", peer)
- if peer is None or peer == "":
+ if peer in [None, ""]:
logger.warning("peer='%s' is empty, row[domain]='%s' - SKIPPED!", peer, row["domain"])
continue
elif not domain_helper.is_wanted(peer):
reason = tidyup.reason(reason) if reason != "" else None
logger.debug("domain='%s',reason='%s' - AFTER!", domain, reason)
- if domain is None or domain == "":
+ if domain in [None, ""]:
logger.warning("domain='%s' is empty,line='%s' - SKIPPED!", domain, line)
continue
if "host" not in instance:
logger.warning("instance(%d)='%s' has no key 'host' - SKIPPED!", len(instance), instance)
continue
- elif instance["host"] is None or instance["host"] == "":
+ elif instance["host"] in [None, ""]:
logger.debug("instance[host]='%s' is None or empty - SKIPPED!", instance["host"])
continue
blocked = tidyup.domain(instance["host"])
logger.debug("blocked[%s]='%s' - AFTER!", type(blocked), blocked)
- if blocked is None or blocked == "":
+ if blocked in [None, ""]:
logger.warning("instance[host]='%s' is None or empty after tidyup.domain() - SKIPPED!", instance["host"])
continue
elif not domain_helper.is_wanted(blocked):
blocked = tidyup.domain(instance["host"])
logger.debug("blocked='%s'", blocked)
- if blocked is None or blocked == "":
+ if blocked in [None, ""]:
logger.warning("instance[host]='%s' is None or empty after tidyup.domain() - SKIPPED!", instance["host"])
continue
elif not domain_helper.is_wanted(blocked):
blocked = tidyup.domain(blocked) if blocked != "" else None
logger.debug("blocked='%s' - AFTER!", blocked)
- if blocked is None or blocked == "":
+ if blocked in [None, ""]:
logger.warning("blocked='%s' is empty after tidyup.domain(): domain='%s',block_level='%s' - SKIPPED!", blocked, domain, block_level)
continue
blocked = utils.deobfuscate(blocked, domain)
logger.debug("blocked='%s' - DEOBFUSCATED!", blocked)
- if blocked is None or blocked == "":
+ if blocked in [None, ""]:
logger.warning("instance[host]='%s' is None or empty after tidyup.domain() - SKIPPED!", instance["host"])
continue
elif not domain_helper.is_wanted(blocked):
blocked = tidyup.domain(blocked) if blocked != "" else None
logger.debug("blocked='%s' - AFTER!", blocked)
- if blocked is None or blocked == "":
+ if blocked in [None, ""]:
logger.warning("blocked is empty after tidyup.domain(): domain='%s',block_level='%s'", domain, block_level)
continue
elif not domain_helper.is_wanted(blocked):
block_level = tidyup.domain(block_level) if block_level != "" else None
logger.debug("block_level='%s' - AFTER!", block_level)
- if block_level is None or block_level == "":
+ if block_level in [None, ""]:
logger.warning("block_level='%s' is now empty!", block_level)
continue
elif block_level == "accept":