Skip to content

Commit

Permalink
fix ip validation rule when querying an IPv6 target
Browse files Browse the repository at this point in the history
  • Loading branch information
thatmattlove committed Mar 20, 2024
1 parent a8476f2 commit 5d39ff0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion hyperglass/models/directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 5d39ff0

Please sign in to comment.