netutils
netutils copied to clipboard
[ACL] Expanded rules do not work for same networks
>>> input_rule = dict(
... name="Allow to internal web",
... src_ip=["192.0.2.0/24"],
... dst_ip=["192.0.2.0/24"],
... dst_port=["tcp/80", "tcp/433"],
... action="permit",
... )
>>>
>>>
>>> acl.ACLRule(input_rule).expanded_rules
[]
>>> input_rule = dict(
... name="Allow to internal web",
... src_ip=["192.0.2.1"],
... dst_ip=["192.0.2.10"],
... dst_port=["tcp/80", "tcp/433"],
... action="permit",
... )
>>>
>>> acl.ACLRule(input_rule).expanded_rules
[{'name': 'Allow to internal web', 'src_ip': '192.0.2.1', 'dst_ip': '192.0.2.10', 'dst_port': '6/80', 'action': 'permit'}, {'name': 'Allow to internal web', 'src_ip': '192.0.2.1', 'dst_ip': '192.0.2.10', 'dst_port': '6/433', 'action': 'permit'}]
>>>
This is a bit of unfortunate test case - only if src_ip matches dst_ip, however still applicable for 0.0.0.0/0 to .0.0.0.0/0 or in-vlan firewalls.
Can you look at self.filter_same_ip? I think this is to be expected as currently coded, but perhaps shouldn't be?
https://netutils.readthedocs.io/en/latest/user/lib_use_cases_acl/?h=self.filter_same_ip#initialization-loading-data