Fixed inconsistent firewall address checking
core-admin-client side had less strict rules for hostname than core-admin, leading to unexpected empty qubesd response. Fixed by copying the logic from core-admin.
This commit is contained in:
parent
1a4cdba7f7
commit
9377addd1e
@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import socket
|
import socket
|
||||||
|
import string
|
||||||
|
|
||||||
|
|
||||||
class RuleOption(object):
|
class RuleOption(object):
|
||||||
'''Base class for a single rule element'''
|
'''Base class for a single rule element'''
|
||||||
@ -120,6 +122,9 @@ class DstHost(RuleOption):
|
|||||||
except socket.error:
|
except socket.error:
|
||||||
self.type = 'dsthost'
|
self.type = 'dsthost'
|
||||||
self.prefixlen = 0
|
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:
|
else:
|
||||||
host, prefixlen = value.split('/', 1)
|
host, prefixlen = value.split('/', 1)
|
||||||
prefixlen = int(prefixlen)
|
prefixlen = int(prefixlen)
|
||||||
|
@ -176,7 +176,6 @@ class TC_02_DstHost(qubesadmin.tests.QubesTestCase):
|
|||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qubesadmin.firewall.DstHost('2001:abcd:efab::3/64')
|
qubesadmin.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):
|
||||||
qubesadmin.firewall.DstHost('www qubes-os.org')
|
qubesadmin.firewall.DstHost('www qubes-os.org')
|
||||||
|
Loading…
Reference in New Issue
Block a user