From e79c4c2220f2d8434cc72a1656f4098d1b83b2b2 Mon Sep 17 00:00:00 2001 From: Johanna England Date: Tue, 5 Sep 2023 11:08:13 +0200 Subject: [PATCH] Validate CIDR addresses as well --- python/nav/web/alertprofiles/forms.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/nav/web/alertprofiles/forms.py b/python/nav/web/alertprofiles/forms.py index c7dbe2ac34..9c35286be7 100644 --- a/python/nav/web/alertprofiles/forms.py +++ b/python/nav/web/alertprofiles/forms.py @@ -32,7 +32,7 @@ from nav.models.profiles import Expression, Filter, FilterGroup, MatchField, Operator from nav.models.profiles import AlertProfile, TimePeriod, AlertSubscription from nav.models.profiles import AlertAddress, AlertSender -from nav.util import is_valid_ip +from nav.util import is_valid_cidr, is_valid_ip from nav.web.crispyforms import HelpField _ = lambda a: a # gettext variable (for future implementations) @@ -656,7 +656,7 @@ def clean(self) -> Dict[str, Any]: ip_list = [value] validated_ip_addresses = [] for ip in ip_list: - if not is_valid_ip(ip=ip, strict=True): + if not is_valid_ip(ip=ip, strict=True) and not is_valid_cidr(cidr=ip): self.add_error( field="value", error=forms.ValidationError(("Invalid IP address: %s" % ip)),