Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/pr/151'
Browse files Browse the repository at this point in the history
* origin/pr/151:
  Fixed inconsistent firewall address checking
  • Loading branch information
marmarek committed Jul 15, 2020
2 parents f9c5b61 + 9377add commit 2bdeb76
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 5 additions & 0 deletions qubesadmin/firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

import datetime
import socket
import string


class RuleOption(object):
'''Base class for a single rule element'''
Expand Down Expand Up @@ -120,6 +122,9 @@ def __init__(self, value, prefixlen=None):
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)
Expand Down
1 change: 0 additions & 1 deletion qubesadmin/tests/firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ def test_015_ipv6_invalid_network(self):
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')
Expand Down

0 comments on commit 2bdeb76

Please sign in to comment.