Merge remote-tracking branch 'origin/pr/151'

* origin/pr/151:
  Fixed inconsistent firewall address checking
This commit is contained in:
Marek Marczykowski-Górecki 2020-07-15 13:50:12 +02:00
commit 2bdeb7684a
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
2 changed files with 5 additions and 1 deletions

View File

@ -23,6 +23,8 @@
import datetime
import socket
import string
class RuleOption(object):
'''Base class for a single rule element'''
@ -120,6 +122,9 @@ class DstHost(RuleOption):
except socket.error:
self.type = 'dsthost'
self.prefixlen = 0
safe_set = string.ascii_lowercase + string.digits + '-._'
if not all(c in safe_set for c in value):
raise ValueError('Invalid hostname')
else:
host, prefixlen = value.split('/', 1)
prefixlen = int(prefixlen)

View File

@ -176,7 +176,6 @@ class TC_02_DstHost(qubesadmin.tests.QubesTestCase):
with self.assertRaises(ValueError):
qubesadmin.firewall.DstHost('2001:abcd:efab::3/64')
@unittest.expectedFailure
def test_020_invalid_hostname(self):
with self.assertRaises(ValueError):
qubesadmin.firewall.DstHost('www qubes-os.org')