correction parsing route Forcepoint
This commit is contained in:
@@ -103,12 +103,43 @@ class ForcepointParser(ParserMixin):
|
||||
self.config['interfaces'].append(Interface(name=name, ip=ip_addr, netmask=netmask, comment=comment))
|
||||
|
||||
def _parse_virtual_routers(self):
|
||||
"""Parse routeurs simples"""
|
||||
for router in self.root.findall(".//router"):
|
||||
name = router.get("name")
|
||||
ip = router.find("mvia_address")
|
||||
ip_addr = ip.get("address") if ip is not None else None
|
||||
self.config['virtual_routers'].append(VirtualRouter(name=name, interfaces=[ip_addr] if ip_addr else [], static_routes=[]))
|
||||
"""Parse les virtual routers avec interfaces et routes statiques"""
|
||||
for router in self.root.findall(".//routing_node"):
|
||||
vr_name = router.get("name")
|
||||
interfaces = []
|
||||
static_routes = []
|
||||
|
||||
for iface in router.findall(".//interface_rn_level"):
|
||||
iface_name = iface.get("name", None)
|
||||
|
||||
for network in iface.findall(".//network_rn_level"):
|
||||
for gw in network.findall(".//gateway_rn_level"):
|
||||
|
||||
for ip_entry in gw.findall(".//ipaddress_behind_router"):
|
||||
gw_ip = ip_entry.get("gateway")
|
||||
ip_cidr = ip_entry.get("ipaddress")
|
||||
static_routes.append(
|
||||
StaticRoute(
|
||||
name=f"{vr_name}_{ip_cidr}",
|
||||
destination=ip_cidr,
|
||||
metric=0,
|
||||
next_hop_ip=gw_ip,
|
||||
interface=iface_name
|
||||
)
|
||||
)
|
||||
|
||||
if gw_ip:
|
||||
interfaces.append(gw_ip)
|
||||
|
||||
interfaces = list(set(interfaces))
|
||||
|
||||
self.config['virtual_routers'].append(
|
||||
VirtualRouter(
|
||||
name=vr_name,
|
||||
interfaces=interfaces,
|
||||
static_routes=static_routes
|
||||
)
|
||||
)
|
||||
|
||||
def _parse_security_rules(self):
|
||||
"""Parse règles FW Forcepoint"""
|
||||
|
||||
Reference in New Issue
Block a user