Skip to content

Commit

Permalink
Validate CIDR addresses as well
Browse files Browse the repository at this point in the history
  • Loading branch information
johannaengland committed Sep 5, 2023
1 parent 6113814 commit e79c4c2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions python/nav/web/alertprofiles/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)),
Expand Down

0 comments on commit e79c4c2

Please sign in to comment.