diff --git a/hyperglass/models/directive.py b/hyperglass/models/directive.py index 45e53416..d546563f 100644 --- a/hyperglass/models/directive.py +++ b/hyperglass/models/directive.py @@ -91,7 +91,7 @@ def validate_target(self, target: str, *, multiple: bool) -> bool: 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 @@ def validate_target(self, target: str, *, multiple: bool) -> bool: 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)