ajout doc + correction

This commit is contained in:
Chevallier
2026-06-01 09:51:24 +02:00
parent 2a357d4d90
commit ee160fc06c
17 changed files with 684 additions and 60 deletions

View File

@@ -46,13 +46,17 @@ class StormshieldParser(ParserMixin):
current_section = line.strip("[]")
continue
inline_comment = ""
if "#" in line:
inline_comment = line.split("#", 1)[1].strip()
if current_section in ("Host", "Network", "Fqdn"):
match = re.match(r"([^=]+)=([^,#]+)", line)
if match:
name = match.group(1).strip()
ip = match.group(2).strip()
self.config["address_objects"].append(
AddressObject(name=name, ip_netmask=ip)
AddressObject(name=name, ip_netmask=ip, description=inline_comment)
)
elif current_section == "Service":
@@ -62,7 +66,7 @@ class StormshieldParser(ParserMixin):
port = match.group(2)
proto = match.group(3).lower()
self.config["service_objects"].append(
ServiceObject(name=name, protocol=proto, port=port)
ServiceObject(name=name, protocol=proto, port=port, description=inline_comment)
)
def _parse_address_groups(self):
@@ -156,18 +160,7 @@ class StormshieldParser(ParserMixin):
def _add_interface(self, section_name, data):
"""Crée un objet Interface à partir dune section complète"""
if section_name.lower().startswith("vlan"):
iface_type = "vlan"
elif section_name.lower().startswith("bridge"):
iface_type = "bridge"
elif section_name.lower().startswith("wifi"):
iface_type = "wifi"
elif section_name.lower().startswith("loopback"):
iface_type = "loopback"
elif section_name.lower().startswith("agg"):
iface_type = "aggregate"
else:
iface_type = "ethernet"
iface_type = section_name.rstrip("0123456789")
enabled = data.get("State", "0") == "1"
name = data.get("Name", section_name)
@@ -187,6 +180,7 @@ class StormshieldParser(ParserMixin):
comment=comment,
interface_type=iface_type,
enabled=enabled,
vlan=data.get("Tag") if data.get("Tag") and iface_type == "vlan" else None
)
self.config["interfaces"].append(interface)