firewall: raise ValueError on invalid hostname in dsthost=
...instead of AssertionError
This commit is contained in:
parent
625c94d1f6
commit
214c646417
@ -123,7 +123,8 @@ class DstHost(RuleOption):
|
|||||||
self.type = 'dsthost'
|
self.type = 'dsthost'
|
||||||
self.prefixlen = 0
|
self.prefixlen = 0
|
||||||
safe_set = string.ascii_lowercase + string.digits + '-._'
|
safe_set = string.ascii_lowercase + string.digits + '-._'
|
||||||
assert all(c in safe_set for c in untrusted_value)
|
if not all(c in safe_set for c in untrusted_value):
|
||||||
|
raise ValueError('Invalid hostname')
|
||||||
value = untrusted_value
|
value = untrusted_value
|
||||||
else:
|
else:
|
||||||
untrusted_host, untrusted_prefixlen = untrusted_value.split('/', 1)
|
untrusted_host, untrusted_prefixlen = untrusted_value.split('/', 1)
|
||||||
|
@ -202,7 +202,6 @@ class TC_02_DstHost(qubes.tests.QubesTestCase):
|
|||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qubes.firewall.DstHost('2001:abcd:efab::3/64')
|
qubes.firewall.DstHost('2001:abcd:efab::3/64')
|
||||||
|
|
||||||
@unittest.expectedFailure
|
|
||||||
def test_020_invalid_hostname(self):
|
def test_020_invalid_hostname(self):
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qubes.firewall.DstHost('www qubes-os.org')
|
qubes.firewall.DstHost('www qubes-os.org')
|
||||||
|
Loading…
Reference in New Issue
Block a user