From f8c19ca984a9c02a22dcf032f6c5dd73e99b215b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Marczykowska-G=C3=B3recka?= Date: Tue, 14 Jul 2020 19:57:34 +0200 Subject: [PATCH] Fixed overzealous firewall hostname checking Checking is now done only on the core-admin-client side; there's no reason to reject rules that would be valid from core-admin-client side. fixes QubesOS/qubes-issues#5943 --- qubesmanager/firewall.py | 47 ++-------------------------------------- 1 file changed, 2 insertions(+), 45 deletions(-) diff --git a/qubesmanager/firewall.py b/qubesmanager/firewall.py index c27947e..e935827 100644 --- a/qubesmanager/firewall.py +++ b/qubesmanager/firewall.py @@ -31,55 +31,12 @@ class FirewallModifiedOutsideError(ValueError): pass -class QIPAddressValidator(QtGui.QValidator): - # pylint: disable=too-few-public-methods - def __init__(self, parent=None): - super(QIPAddressValidator, self).__init__(parent) - - def validate(self, input_string, pos): - # pylint: disable=too-many-return-statements,no-self-use - hostname = str(input_string) - - if len(hostname) > 255 or not hostname: - return QtGui.QValidator.Intermediate, input_string, pos - - if hostname == "*": - return QtGui.QValidator.Acceptable, input_string, pos - - unmask = hostname.split("/", 1) - if len(unmask) == 2: - hostname = unmask[0] - mask = unmask[1] - if mask.isdigit() or mask == "": - if re.match(r"^([0-9]{1,3}\.){3}[0-9]{1,3}$", hostname) is None: - return QtGui.QValidator.Invalid, input_string, pos - if mask != "": - mask = int(unmask[1]) - if mask < 0 or mask > 32: - return QtGui.QValidator.Invalid, input_string, pos - else: - return QtGui.QValidator.Invalid, input_string, pos - - if hostname[-1:] == ".": - hostname = hostname[:-1] - - if hostname[-1:] == "-": - return QtGui.QValidator.Intermediate, input_string, pos - - allowed = re.compile(r"(?!-)[A-Z\d-]{1,63}(?