mirror of
https://github.com/thatmattlove/hyperglass.git
synced 2026-01-17 00:38:06 +00:00
Fixed validation of no condition rules
Previously, when processing rules with no condition, an extra RuleWithPattern rule was also added to the rule list causing a validation error. This has been corrected. Signed-off-by: Mattie Nickson <mnickson@sidingsmedia.com>
This commit is contained in:
parent
d653461b5d
commit
6d132e27b4
1 changed files with 9 additions and 8 deletions
|
|
@ -282,14 +282,15 @@ class Directive(HyperglassUniqueModel, unique_by=("id", "table_output")):
|
|||
condition = rule.get("condition")
|
||||
if condition is None:
|
||||
out_rules.append(RuleWithoutValidation(**rule))
|
||||
try:
|
||||
condition_net = ip_network(condition)
|
||||
if condition_net.version == 4:
|
||||
out_rules.append(RuleWithIPv4(**rule))
|
||||
if condition_net.version == 6:
|
||||
out_rules.append(RuleWithIPv6(**rule))
|
||||
except ValueError:
|
||||
out_rules.append(RuleWithPattern(**rule))
|
||||
else:
|
||||
try:
|
||||
condition_net = ip_network(condition)
|
||||
if condition_net.version == 4:
|
||||
out_rules.append(RuleWithIPv4(**rule))
|
||||
if condition_net.version == 6:
|
||||
out_rules.append(RuleWithIPv6(**rule))
|
||||
except ValueError:
|
||||
out_rules.append(RuleWithPattern(**rule))
|
||||
if isinstance(rule, Rule):
|
||||
out_rules.append(rule)
|
||||
return out_rules
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue