added safe harbor for domains

One can now add a [safe harbor] section to the config file with an entry
"domains" that has a comma separated list of domains that shall never end
on the block list.
This commit is contained in:
Tobias Diekershoff 2023-01-07 22:20:50 +01:00
parent b333d0c989
commit bca141a120
3 changed files with 38 additions and 16 deletions

View File

@ -80,6 +80,18 @@ trust = 30
trust = -50
```
You can also add a list of protected nodes to the config file. To do so add a
section `[safe harbor]` to the config file. This section has only one entry
called `domains` and the value of this entry is a comma separated list of domains
that should never get on your blocklist.
For example
```
[safe harbor]
domain = friendica.example.com
```
### Running the script
You have to supply the file name of the configuration file on the command

View File

@ -1,6 +1,6 @@
[tool.poetry]
name = "brewserverblocklist"
version = "1.0.0"
version = "1.0.1"
description = "A python script to collect the server-wide blocklists from Friendica nodes to build a collection from trusted admin choice"
authors = ["Tobias Diekershoff"]
license = "GNU General Public License v3.0"

View File

@ -31,11 +31,20 @@ class BrewBlocklist():
self.sources = []
self.auto_accept = auto_accept
self.auto_accept_direction = auto_accept_direction
self.safe_harbor = []
config = configparser.RawConfigParser()
config.read(configfile)
for section in config.sections():
section_values = dict(config.items(section))
self.sources.append({'url': section, 'trust': int(section_values['trust'])})
if not section == 'safe harbor':
self.sources.append({
'url': section,
'trust': int(section_values['trust']),
})
else:
for item in section_values['domains'].split(','):
print(item)
self.safe_harbor.append(item)
self.outputfile = outputfile
self.confidence = confidence
self.blocklist = {}
@ -71,21 +80,22 @@ class BrewBlocklist():
c_blocklist = {}
c_reasons = {}
for key, value in self.blocklist.items():
if value < self.confidence:
if not self.auto_accept:
print('Domain: {} [total trust {}]'.format(key, value))
print('Reason: {}'.format(self.reasons[key]))
keep = input('Keep that entry? [Y/n] > ')
if keep not in ['n', 'N']:
c_blocklist[key] = value
c_reasons[key] = self.reasons[key]
if not key in self.safe_harbor:
if value < self.confidence:
if not self.auto_accept:
print('Domain: {} [total trust {}]'.format(key, value))
print('Reason: {}'.format(self.reasons[key]))
keep = input('Keep that entry? [Y/n] > ')
if keep not in ['n', 'N']:
c_blocklist[key] = value
c_reasons[key] = self.reasons[key]
else:
if self.auto_accept_direction:
c_blocklist[key] = value
c_reasons[key] = self.reasons[key]
else:
if self.auto_accept_direction:
c_blocklist[key] = value
c_reasons[key] = self.reasons[key]
else:
c_blocklist[key] = value
c_reasons[key] = self.reasons[key]
c_blocklist[key] = value
c_reasons[key] = self.reasons[key]
self.blocklist = c_blocklist
self.reasons = c_reasons