1
0
Fork 1
mirror of https://github.com/thatmattlove/hyperglass.git synced 2026-01-17 08:48:05 +00:00

fix ip validation rule when querying an IPv6 target

This commit is contained in:
thatmattlove 2024-03-19 23:27:38 -04:00
parent a8476f2ea9
commit 5d39ff054f

View file

@ -91,7 +91,7 @@ class Rule(HyperglassModel):
class RuleWithIP(Rule):
"""Base IP-based rule."""
condition: IPvAnyNetwork
condition: t.Union[IPv4Network, IPv6Network]
allow_reserved: bool = False
allow_unspecified: bool = False
allow_loopback: bool = False
@ -140,6 +140,10 @@ class RuleWithIP(Rule):
except ValueError as err:
raise InputValidationError(error=str(err), target=target) from err
if valid_target.version != self.condition.version:
log.debug("{!s} is not the same IP version as {!s}", target, self.condition)
return False
is_member = self.membership(valid_target, self.condition)
in_range = self.in_range(valid_target)