Skip to content

Commit 5118e24

Browse files
authored
[Firewall] create a Firewall Policy Network Rule with FQDNs (#3685)
* support fqdns parameters for 'az network firewall policy rule-collection-group collection' * add tests for fqdns update
1 parent facef11 commit 5118e24

File tree

6 files changed

+1769
-9
lines changed

6 files changed

+1769
-9
lines changed

src/azure-firewall/HISTORY.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
Release History
44
===============
55

6+
0.12.0
7+
++++++
8+
* `az network firewall policy rule-collection-group collection add-filter-collection`: Add parameter `--destination-fqdns`
9+
* `az network firewall policy rule-collection-group collection rule add`: Add parameters `--destination-fqdns` and `--translated-fqdn`
10+
* `az network firewall policy rule-collection-group collection rule update`: Add parameters `--destination-fqdns` and `--translated-fqdn`
11+
612
0.11.0
713
++++++
814
* Fix issue: `create_or_update` not found

src/azure-firewall/azext_firewall/_params.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ def load_arguments(self, _):
237237
with self.argument_context('network firewall policy rule-collection-group collection', arg_group='Network Rule') as c:
238238
c.argument('destination_ip_groups', options_list=['--destination-ip-groups', '--dest-ipg'], nargs='+', validator=validate_ip_groups,
239239
help='Space-separated list of name or resource id of destination IpGroups')
240+
c.argument('destination_fqdns')
240241

241242
with self.argument_context('network firewall policy rule-collection-group collection add-filter-collection') as c:
242243
c.argument('filter_action', options_list=['--action'], arg_type=get_enum_type(['Allow', 'Deny']), help='The action type of a rule collection.')

src/azure-firewall/azext_firewall/custom.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,7 @@ def add_azure_firewall_policy_filter_rule_collection(cmd, resource_group_name, f
810810
destination_ports=None,
811811
protocols=None, fqdn_tags=None, target_fqdns=None,
812812
source_ip_groups=None, destination_ip_groups=None,
813+
destination_fqdns=None,
813814
target_urls=None, enable_tls_inspection=False, web_categories=None):
814815
NetworkRule, FirewallPolicyRuleApplicationProtocol,\
815816
ApplicationRule, FirewallPolicyFilterRuleCollectionAction, FirewallPolicyFilterRuleCollection =\
@@ -828,7 +829,8 @@ def add_azure_firewall_policy_filter_rule_collection(cmd, resource_group_name, f
828829
destination_addresses=destination_addresses,
829830
destination_ports=destination_ports,
830831
source_ip_groups=source_ip_groups,
831-
destination_ip_groups=destination_ip_groups)
832+
destination_ip_groups=destination_ip_groups,
833+
destination_fqdns=destination_fqdns)
832834
else:
833835
def map_application_rule_protocol(item):
834836
return FirewallPolicyRuleApplicationProtocol(protocol_type=item['protocol_type'],
@@ -883,8 +885,8 @@ def add_azure_firewall_policy_filter_rule(cmd, resource_group_name, firewall_pol
883885
description=None, ip_protocols=None, source_addresses=None,
884886
destination_addresses=None, destination_ports=None,
885887
protocols=None, fqdn_tags=None, target_fqdns=None,
886-
source_ip_groups=None, destination_ip_groups=None,
887-
translated_address=None, translated_port=None,
888+
source_ip_groups=None, destination_ip_groups=None, destination_fqdns=None,
889+
translated_address=None, translated_port=None, translated_fqdn=None,
888890
target_urls=None, enable_tls_inspection=False, web_categories=None):
889891
(NetworkRule,
890892
FirewallPolicyRuleApplicationProtocol,
@@ -918,7 +920,8 @@ def add_azure_firewall_policy_filter_rule(cmd, resource_group_name, firewall_pol
918920
destination_addresses=destination_addresses,
919921
destination_ports=destination_ports,
920922
source_ip_groups=source_ip_groups,
921-
destination_ip_groups=destination_ip_groups)
923+
destination_ip_groups=destination_ip_groups,
924+
destination_fqdns=destination_fqdns)
922925
elif rule_type == 'ApplicationRule':
923926
def map_application_rule_protocol(item):
924927
return FirewallPolicyRuleApplicationProtocol(protocol_type=item['protocol_type'],
@@ -947,7 +950,8 @@ def map_application_rule_protocol(item):
947950
destination_ports=destination_ports,
948951
translated_address=translated_address,
949952
translated_port=translated_port,
950-
source_ip_groups=source_ip_groups)
953+
source_ip_groups=source_ip_groups,
954+
translated_fqdn=translated_fqdn)
951955
target_rule_collection.rules.append(rule)
952956
return client.begin_create_or_update(resource_group_name, firewall_policy_name,
953957
rule_collection_group_name, rule_collection_group)
@@ -979,8 +983,8 @@ def update_azure_firewall_policy_filter_rule(cmd, instance, rule_collection_name
979983
description=None, ip_protocols=None, source_addresses=None,
980984
destination_addresses=None, destination_ports=None,
981985
protocols=None, fqdn_tags=None, target_fqdns=None,
982-
source_ip_groups=None, destination_ip_groups=None,
983-
translated_address=None, translated_port=None,
986+
source_ip_groups=None, destination_ip_groups=None, destination_fqdns=None,
987+
translated_address=None, translated_port=None, translated_fqdn=None,
984988
target_urls=None, enable_tls_inspection=None, web_categories=None):
985989
(NetworkRule,
986990
FirewallPolicyRuleApplicationProtocol,
@@ -1008,7 +1012,8 @@ def update_azure_firewall_policy_filter_rule(cmd, instance, rule_collection_name
10081012
destination_addresses=(destination_addresses or rule.destination_addresses),
10091013
destination_ports=(destination_ports or rule.destination_ports),
10101014
source_ip_groups=(source_ip_groups or rule.source_ip_groups),
1011-
destination_ip_groups=(destination_ip_groups or rule.destination_ip_groups))
1015+
destination_ip_groups=(destination_ip_groups or rule.destination_ip_groups),
1016+
destination_fqdns=(destination_fqdns or rule.destination_fqdns))
10121017
elif rule.rule_type == 'ApplicationRule':
10131018
def map_application_rule_protocol(item):
10141019
return FirewallPolicyRuleApplicationProtocol(protocol_type=item['protocol_type'],
@@ -1037,6 +1042,7 @@ def map_application_rule_protocol(item):
10371042
destination_ports=(destination_ports or rule.destination_ports),
10381043
translated_address=(translated_address or rule.translated_address),
10391044
translated_port=(translated_port or rule.translated_port),
1045+
translated_fqdn=(translated_fqdn or rule.translated_fqdn),
10401046
source_ip_groups=(source_ip_groups or rule.source_ip_groups))
10411047
if new_rule:
10421048
target_rule_collection.rules[i] = copy.deepcopy(new_rule)

0 commit comments

Comments
 (0)