feat: support Zone-Based Firewalls (#33)

* feat: support Zone-Based Firewalls

* chore: add usage example of zone-based firewall

* chore: add note to readme to support unifi controller v2

* fix: invalid path for reordering firewall zone policies
This commit is contained in:
Mateusz Filipowicz
2025-02-20 18:48:04 +01:00
committed by GitHub
parent 16f71e7fe9
commit 637809c663
13 changed files with 703 additions and 0 deletions
+20
View File
@@ -3,6 +3,7 @@ customizations:
client:
excludeResources:
- "Dpi*"
- "FirewallZoneMatrix"
functions:
- name: "Login"
comment: "Login logs in to the controller. Useful only for user/password authentication."
@@ -285,6 +286,16 @@ customizations:
type: "int"
returns:
- "error"
- name: "ListFirewallZoneMatrix"
resourceName: "FirewallZoneMatrix"
params:
- name: "ctx"
type: "context.Context"
- name: "site"
type: "string"
returns:
- "[]FirewallZoneMatrix"
- "error"
resources:
Account:
fields:
@@ -335,6 +346,15 @@ customizations:
customUnmarshalType: "booleanishString"
PortOverrides:
omitEmpty: false
FirewallZone:
resourcePath: "firewall/zone"
fields:
NetworkIDs:
omitEmpty: false
FirewallZoneMatrix:
resourcePath: "firewall/zone-matrix"
FirewallZonePolicy:
resourcePath: "firewall-policies"
Network:
fields:
InternetAccessEnabled:
+4
View File
@@ -0,0 +1,4 @@
{
"name": "",
"network_ids": [""]
}
+8
View File
@@ -0,0 +1,8 @@
{
"data": [{
"action": "",
"policy_count": "\\d+"
}],
"name": "",
"zone_key": ""
}
+58
View File
@@ -0,0 +1,58 @@
{
"action": "ALLOW|BLOCK|REJECT",
"connection_state_type": "ALL|RESPOND_ONLY|CUSTOM",
"connection_states": ["ESTABLISHED|NEW|RELATED|INVALID"],
"enabled": "true|false",
"predefined": "true|false",
"name": "",
"description": "",
"destination": {
"app_category_ids": [""],
"app_ids": [""],
"ips": ["^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^$"],
"match_mac": "true|false",
"match_opposite_ips": "true|false",
"match_opposite_ports": "true|false",
"matching_target": "ANY|APP|APP_CATEGORY|IP|REGION|WEB",
"matching_target_type": "ANY|OBJECT|SPECIFIC",
"port": "^[0-9][0-9]?$|^",
"port_group_id": "",
"port_matching_type": "ANY|SPECIFIC|OBJECT",
"regions": [""],
"web_domains": [""],
"zone_id": ""
},
"index": "^[0-9][0-9]?$|^",
"ip_version": "BOTH|IPV4|IPV6",
"logging": "true|false",
"match_ip_sec": "true|false",
"match_ip_sec_type": "MATCH_IP_SEC|MATCH_NON_IP_SEC",
"match_opposite_protocol": "true|false",
"protocol": "all|tcp_udp|tcp|udp|ah|dccp|eigrp|esp|gre|icmp|icmpv6|igmp|igp|ip|ipcomp|ipip|ipv6|isis|l2tp|manet|mobility-header|mpls-in-ip|number|ospf|pim|pup|rdp|rohc|rspf|rcvp|sctp|shim6|skip|st|vmtp|vrrp|wesp|xtp",
"schedule": {
"mode": "ALWAYS|EVERY_DAY|EVERY_WEEK|ONE_TIME_ONLY|CUSTOM",
"date": "^$|^(20[0-9]{2})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$",
"date_end": "^$|^(20[0-9]{2})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$",
"date_start": "^$|^(20[0-9]{2})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$",
"repeat_on_days": ["mon|tue|wed|thu|fri|sat|sun"],
"time_range_end": "^[0-9][0-9]:[0-9][0-9]$",
"time_range_start": "^[0-9][0-9]:[0-9][0-9]$",
"time_all_day": "true|false"
},
"source": {
"client_macs": ["^([0-9A-Fa-f]{2}:){5}([0-9A-Fa-f]{2})$"],
"ips": ["^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^$"],
"mac": "^([0-9A-Fa-f]{2}:){5}([0-9A-Fa-f]{2})$",
"match_mac": "true|false",
"match_opposite_ports": "true|false",
"match_opposite_ips": "true|false",
"match_opposite_networks": "true|false",
"matching_target": "ANY|CLIENT|NETWORK|IP|MAC",
"matching_target_type": "OBJECT|SPECIFIC",
"network_ids": [""],
"port": "^[0-9][0-9]?$|^",
"port_group_id": "",
"port_matching_type": "ANY|SPECIFIC|OBJECT",
"zone_id": ""
}
}