Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
allow single element without separator (#745)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbasan authored Jul 1, 2024
1 parent 72cd85d commit dae3db2
Showing 1 changed file with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
from catalystwan.models.policy.definition.ssl_decryption_utd_profile import SslDecryptionUtdProfilePolicy
from catalystwan.models.policy.definition.url_filtering import UrlFilteringPolicy
from catalystwan.models.policy.definition.zone_based_firewall import ZoneBasedFWPolicy
from catalystwan.utils.config_migration.converters.exceptions import CatalystwanConverterCantConvertException
from catalystwan.utils.config_migration.converters.utils import convert_varname

from .zone_based_firewall import convert_zone_based_fw
Expand Down Expand Up @@ -146,7 +145,7 @@ def conditional_split(s: str, seps: List[str]) -> List[str]:
for sep in seps:
if sep in s:
return s.split(sep)
raise CatalystwanConverterCantConvertException(f"None of the separators {seps} in {s}")
return [s]


def advanced_malware_protection(
Expand Down Expand Up @@ -429,17 +428,17 @@ def device_access_ipv6(
if in_entry.ref:
seq.match_destination_data_prefix_list(in_entry.ref[0])
elif in_entry.field == "destinationIpv6":
d_network_ipv6 = conditional_split(in_entry.value, [",", " "])
seq.match_destination_data_prefixes([IPv6Interface(v) for v in d_network_ipv6])
networks = conditional_split(in_entry.value, [",", " "])
seq.match_destination_data_prefixes([IPv6Interface(v) for v in networks])
elif in_entry.field == "destinationPort":
destination_port = cast(DeviceAccessProtocolPort, int(in_entry.value))
seq.match_destination_port(destination_port)
elif in_entry.field == "sourceDataIpv6PrefixList":
if in_entry.ref:
seq.match_source_data_prefix_list(in_entry.ref[0])
elif in_entry.field == "sourceIpv6":
s_network_ipv6 = conditional_split(in_entry.value, [",", " "])
seq.match_source_data_prefixes([IPv6Interface(v) for v in s_network_ipv6])
networks = conditional_split(in_entry.value, [",", " "])
seq.match_source_data_prefixes([IPv6Interface(v) for v in networks])
elif in_entry.field == "sourcePort":
seq.match_source_ports(as_num_list(as_num_ranges_list(in_entry.value)))
return ConvertResult[DeviceAccessIPv6Parcel](output=out)
Expand All @@ -465,17 +464,17 @@ def device_access_ipv4(
seq.match_destination_data_prefix_list(in_entry.ref[0])
elif in_entry.field == "destinationIp":
if in_entry.value is not None:
d_network_ipv6 = conditional_split(in_entry.value, [",", " "])
seq.match_destination_data_prefixes([IPv4Interface(v) for v in d_network_ipv6])
networks = conditional_split(in_entry.value, [",", " "])
seq.match_destination_data_prefixes([IPv4Interface(v) for v in networks])
elif in_entry.vip_variable_name is not None:
seq.match_destination_data_prefix_variable(convert_varname(in_entry.vip_variable_name))
elif in_entry.field == "sourceDataPrefixList":
if in_entry.ref:
seq.match_source_data_prefix_list(in_entry.ref[0])
elif in_entry.field == "sourceIp":
if in_entry.value is not None:
s_network_ipv6 = conditional_split(in_entry.value, [",", " "])
seq.match_source_data_prefixes([IPv4Interface(v) for v in s_network_ipv6])
networks = conditional_split(in_entry.value, [",", " "])
seq.match_source_data_prefixes([IPv4Interface(v) for v in networks])
elif in_entry.vip_variable_name is not None:
seq.match_source_data_prefix_variable(convert_varname(in_entry.vip_variable_name))
elif in_entry.field == "sourcePort":
Expand Down

0 comments on commit dae3db2

Please sign in to comment.