-
Notifications
You must be signed in to change notification settings - Fork 789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replaces 'Whitelist' with 'Allowlist' #8305
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,7 +60,7 @@ public function updateBlocklistAction() | |
|
||
// strip off any trailing dot | ||
$value = rtrim($domain, '.'); | ||
$wl = explode(',', (string)$mdl->dnsbl->whitelists); | ||
$wl = explode(',', (string)$mdl->dnsbl->allowlists); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. $wl could have been changed to $al too, I guess. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here is the thing I was afraid of: changing model field names forces data loss for everyone using the feature There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good catch. |
||
$bl = explode(',', (string)$mdl->dnsbl->blocklists); | ||
|
||
$existing_domains = explode(',', (string)$item); | ||
|
@@ -71,10 +71,10 @@ public function updateBlocklistAction() | |
} | ||
|
||
// Check if domains should be switched around in the model | ||
if ($type == 'whitelists' && in_array($value, $bl)) { | ||
if ($type == 'allowlists' && in_array($value, $bl)) { | ||
$mdl->dnsbl->blocklists = $remove($bl, $value); | ||
} elseif ($type == 'blocklists' && in_array($value, $wl)) { | ||
$mdl->dnsbl->whitelists = $remove($wl, $value); | ||
$mdl->dnsbl->allowlists = $remove($wl, $value); | ||
} | ||
|
||
// update the model | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,12 +28,12 @@ | |
<help>List of domains from where blocklist will be downloaded.</help> | ||
</field> | ||
<field> | ||
<id>unbound.dnsbl.whitelists</id> | ||
<label>Whitelist Domains</label> | ||
<id>unbound.dnsbl.allowlists</id> | ||
<label>Allowlist Domains</label> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. start with the label only... |
||
<type>select_multiple</type> | ||
<style>tokenize</style> | ||
<allownew>true</allownew> | ||
<help>List of domains to whitelist. You can use regular expressions.</help> | ||
<help>List of domains to allowlist. You can use regular expressions.</help> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ... and the help text. |
||
</field> | ||
<field> | ||
<id>unbound.dnsbl.blocklists</id> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,7 @@ class DefaultBlocklistHandler(BaseBlocklistHandler): | |
def __init__(self): | ||
super().__init__('/usr/local/etc/unbound/unbound-blocklists.conf') | ||
self.priority = 100 | ||
self._whitelist_pattern = self._get_excludes() | ||
self._allowlist_pattern = self._get_excludes() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the changes in this script are likely ok |
||
|
||
def get_config(self): | ||
cfg = {} | ||
|
@@ -53,7 +53,7 @@ def get_blocklist(self): | |
for blocklist, bl_shortcode in self._blocklists_in_config(): | ||
per_file_stats = {'uri': blocklist, 'skip': 0, 'blocklist': 0, 'wildcard': 0} | ||
for domain in self._domains_in_blocklist(blocklist): | ||
if self._whitelist_pattern.match(domain): | ||
if self._allowlist_pattern.match(domain): | ||
per_file_stats['skip'] += 1 | ||
else: | ||
if self.domain_pattern.match(domain): | ||
|
@@ -81,13 +81,13 @@ def get_blocklist(self): | |
for key, value in self.cnf['include'].items(): | ||
if key.startswith('custom'): | ||
entry = value.rstrip().lower() | ||
if not self._whitelist_pattern.match(entry): | ||
if not self._allowlist_pattern.match(entry): | ||
if self.domain_pattern.match(entry): | ||
result[entry] = {'bl': 'Manual', 'wildcard': False} | ||
elif key.startswith('wildcard'): | ||
entry = value.rstrip().lower() | ||
if self.domain_pattern.match(entry): | ||
# do not apply whitelist to wildcard domains | ||
# do not apply allowlist to wildcard domains | ||
result[entry] = {'bl': 'Manual', 'wildcard': True} | ||
|
||
return result | ||
|
@@ -142,7 +142,7 @@ def _blocklist_reader(self, uri): | |
|
||
|
||
def _get_excludes(self): | ||
whitelist_pattern = re.compile('$^') # match nothing | ||
allowlist_pattern = re.compile('$^') # match nothing | ||
if self.cnf.has_section('exclude'): | ||
exclude_list = set() | ||
for exclude_item in self.cnf['exclude']: | ||
|
@@ -152,15 +152,15 @@ def _get_excludes(self): | |
exclude_list.add(pattern) | ||
except re.error: | ||
syslog.syslog(syslog.LOG_ERR, | ||
'blocklist download : skip invalid whitelist exclude pattern "%s" (%s)' % ( | ||
'blocklist download : skip invalid allowlist exclude pattern "%s" (%s)' % ( | ||
exclude_item, pattern | ||
) | ||
) | ||
if not exclude_list: | ||
exclude_list.add('$^') | ||
|
||
wp = '|'.join(exclude_list) | ||
whitelist_pattern = re.compile(wp, re.IGNORECASE) | ||
allowlist_pattern = re.compile(wp, re.IGNORECASE) | ||
syslog.syslog(syslog.LOG_NOTICE, 'blocklist download : exclude domains matching %s' % wp) | ||
|
||
return whitelist_pattern | ||
return allowlist_pattern |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,9 +85,9 @@ custom_{{loop.index}}={{uri}} | |
[exclude] | ||
# exclude localhost entries | ||
default_pattern_1=.*localhost$ | ||
{% if not helpers.empty('OPNsense.unboundplus.dnsbl.whitelists')%} | ||
{% if not helpers.empty('OPNsense.unboundplus.dnsbl.allowlists')%} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. model changes again here and below There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ack, will remove. |
||
# user defined | ||
{% for pattern in OPNsense.unboundplus.dnsbl.whitelists.split(',') %} | ||
{% for pattern in OPNsense.unboundplus.dnsbl.allowlists.split(',') %} | ||
custom_pattern_{{loop.index}}={{ pattern }} | ||
{% endfor %} | ||
{% endif %} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return key is ok access key is difficult, GUI changes are probably ok either way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack, I'll remove.