Azure Firewall
Azure Firewall is a cloud-native and intelligent network firewall security service that provides breed threat protection for cloud workloads running in Azure. It's a fully stateful, firewall as a service, with built-in high availability and unrestricted cloud scalability.
IT Services · Azure Firewall
Details
| ID | Azure Firewall |
|---|---|
| Provider | Microsoft |
| Category | IT Services |
| From Version | 6.1.0 |
| Docker Image | demisto/crypto:1.0.0.10120494 |
| Supported Modules | Agentix XSIAM |
README
Azure Firewall is a cloud-native and intelligent network firewall security service that provides breed threat protection for cloud workloads running in Azure. It’s a fully stateful, firewall as a service, with built-in high availability and unrestricted cloud scalability.
This integration was integrated and tested with version 2021-03-01 of Azure Firewall.
Configure Azure Firewall in Cortex
| Parameter | Description | Required |
|---|---|---|
| Resource Group Name. | True | |
| Client ID. | True | |
| Subscription ID. | True | |
| Tenant ID. | False | |
| Client Secret. | False | |
| Certificate Thumbprint | Used for certificate authentication. As appears in the “Certificates & secrets” page of the app. | False |
| Private Key | Used for certificate authentication. The private key of the registered certificate. | False |
| Use Azure Managed Identities | Relevant only if the integration is running on Azure VM. If selected, authenticates based on the value provided for the Azure Managed Identities Client ID field. If no value is provided for the Azure Managed Identities Client ID field, authenticates based on the System Assigned Managed Identity. For additional information, see the Help tab. | False |
| Azure Managed Identities Client ID | The Managed Identities client ID for authentication - relevant only if the integration is running on Azure VM. | False |
| Use system proxy settings | False | |
| Trust any certificate (not secure) | False |
Commands
You can execute these commands from the CLI, as part of an automation, or in a playbook.
After you successfully execute a command, a DBot message appears in the War Room with the command details.
azure-firewall-auth-test
Tests the connectivity to Azure.
Base Command
azure-firewall-auth-test
Input
There are no input arguments for this command.
Context Output
There is no context output for this command.
azure-firewall-auth-start
Run this command to start the authorization process and follow the instructions in the command results.
Base Command
azure-firewall-auth-start
Input
There are no input arguments for this command.
Context Output
There is no context output for this command.
azure-firewall-auth-complete
Run this command to complete the authorization process. Should be used after running the azure-firewall-auth-start command.
Base Command
azure-firewall-auth-complete
Input
There are no input arguments for this command.
Context Output
There is no context output for this command.
azure-firewall-auth-reset
Run this command if for some reason you need to rerun the authentication process.
Base Command
azure-firewall-auth-reset
Input
There are no input arguments for this command.
Context Output
There is no context output for this command.
azure-firewall-list
List Azure firewalls in the specified resource group or subscription.
Base Command
azure-firewall-list
Input
| Argument Name | Description | Required |
|---|---|---|
| resource | The resource that contains the firewalls to list. Possible values are: resource_group, subscription. Default is resource_group. | Required |
| limit | The maximum number of results to retrieve. Minimum value is 1. Default is 50. | Optional |
| page | The page number of the results to retrieve. Minimum value is 1. Default is 1. | Optional |
| subscription_id | The subscription ID. Note: This argument will override the instance parameter ‘Default Subscription ID’. | Optional |
| resource_group_name | The name of the resource group. Note: This argument will override the instance parameter ‘Default Resource Group Name’. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| AzureFirewall.Firewall.id | String | Firewall resource ID. |
| AzureFirewall.Firewall.name | String | Firewall resource name. |
| AzureFirewall.Firewall.location | String | Firewall resource location. |
Command example
!azure-firewall-list resource=resource_group limit=1 page=1
Context Example
{
"AzureFirewall": {
"Firewall": {
"etag": "W/\"b4fb1688-7055-40e7-8a5e-d17d81b902ed\"",
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/azureFirewalls/test-ip",
"location": "eastus",
"name": "test-ip",
"properties": {
"additionalProperties": {},
"applicationRuleCollections": [],
"ipConfigurations": [
{
"etag": "W/\"b4fb1688-7055-40e7-8a5e-d17d81b902ed\"",
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/azureFirewalls/test-ip/azureFirewallIpConfigurations/test-ip",
"name": "test-ip",
"properties": {
"privateIPAddress": "189.160.40.11",
"privateIPAllocationMethod": "Dynamic",
"provisioningState": "Succeeded",
"publicIPAddress": {
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/publicIPAddresses/test-ip"
},
"subnet": {
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/virtualNetworks/test-v-n/subnets/AzureFirewallSubnet"
}
},
"type": "Microsoft.Network/azureFirewalls/azureFirewallIpConfigurations"
}
],
"natRuleCollections": [],
"networkRuleCollections": [],
"provisioningState": "Succeeded",
"sku": {
"name": "AZFW_VNet",
"tier": "Standard"
},
"threatIntelMode": "Alert"
},
"tags": {},
"type": "Microsoft.Network/azureFirewalls"
}
}
}
Human Readable Output
Firewall List
Current page size: 1
Showing page 1 out others that may exist.
Name Id Location Subnet Threat Intel Mode Private Ip Address Provisioning State test-ip /subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/azureFirewalls/test-ip eastus /subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/virtualNetworks/test-v-n/subnets/AzureFirewallSubnet Alert 189.160.40.11 Succeeded
azure-firewall-get
Retrieve Azure firewall information.
Base Command
azure-firewall-get
Input
| Argument Name | Description | Required |
|---|---|---|
| firewall_names | Comma-separated list of firewall names to retrieve. | Required |
| polling | Indicates if the command was scheduled. Possible values are: True, False. Default is True. | Optional |
| interval | Indicates how long to wait between command executions (in seconds) when the ‘polling’ argument is true. Minimum value is 10 seconds. Default is 30. | Optional |
| timeout | Indicates the time in seconds until the polling sequence times out. Default is 60. | Optional |
| subscription_id | The subscription ID. Note: This argument will override the instance parameter ‘Default Subscription ID’. | Optional |
| resource_group_name | The name of the resource group. Note: This argument will override the instance parameter ‘Default Resource Group Name’. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| AzureFirewall.Firewall.id | String | Firewall resource ID. |
| AzureFirewall.Firewall.name | String | Firewall resource name. |
| AzureFirewall.Firewall.location | String | Firewall resource location. |
Command example
!azure-firewall-get firewall_names=test-ip interval=10 timeout=600
Context Example
{
"AzureFirewall": {
"Firewall": {
"etag": "W/\"b4fb1688-7055-40e7-8a5e-d17d81b902ed\"",
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/azureFirewalls/test-ip",
"location": "eastus",
"name": "test-ip",
"properties": {
"additionalProperties": {},
"applicationRuleCollections": [],
"ipConfigurations": [
{
"etag": "W/\"b4fb1688-7055-40e7-8a5e-d17d81b902ed\"",
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/azureFirewalls/test-ip/azureFirewallIpConfigurations/test-ip",
"name": "test-ip",
"properties": {
"privateIPAddress": "189.160.40.11",
"privateIPAllocationMethod": "Dynamic",
"provisioningState": "Succeeded",
"publicIPAddress": {
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/publicIPAddresses/test-ip"
},
"subnet": {
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/virtualNetworks/test-v-n/subnets/AzureFirewallSubnet"
}
},
"type": "Microsoft.Network/azureFirewalls/azureFirewallIpConfigurations"
}
],
"natRuleCollections": [],
"networkRuleCollections": [],
"provisioningState": "Succeeded",
"sku": {
"name": "AZFW_VNet",
"tier": "Standard"
},
"threatIntelMode": "Alert"
},
"tags": {},
"type": "Microsoft.Network/azureFirewalls"
}
}
}
Human Readable Output
Firewall test-ip information
Name Id Location Subnet Threat Intel Mode Private Ip Address Provisioning State test-ip /subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/azureFirewalls/test-ip eastus /subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/virtualNetworks/test-v-n/subnets/AzureFirewallSubnet Alert 189.160.40.11 Succeeded
azure-firewall-rule-collection-list
List the collection rules in the firewall or policy. One of the arguments ‘firewall_name’ or ‘policy’ must be provided.
Base Command
azure-firewall-rule-collection-list
Input
| Argument Name | Description | Required |
|---|---|---|
| firewall_name | The name of the Azure firewall that contains the collections. | Optional |
| policy | The name of the Azure policy that contains the collections. | Optional |
| rule_type | The names of the rule collection type to retrieve. Possible values are: application_rule, network_rule, nat_rule. | Required |
| limit | The maximum number of results to retrieve. Minimum value is 1. Default is 50. | Optional |
| page | The page number of the results to retrieve. Minimum value is 1. Default is 1. | Optional |
| subscription_id | The subscription ID. Note: This argument will override the instance parameter ‘Default Subscription ID’. | Optional |
| resource_group_name | The name of the resource group. Note: This argument will override the instance parameter ‘Default Resource Group Name’. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| AzureFirewall.RuleCollection.name | String | Rule collection unique name. |
Command example
!azure-firewall-rule-collection-list policy=xsoar-policy rule_type=network_rule limit=1 page=1
Context Example
{
"AzureFirewall": {
"RuleCollection": {
"etag": "e09cf677-e019-43f0-98a6-eeee540a74ae",
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/firewallPolicies/xsoar-policy/ruleCollectionGroups/playbook-collection",
"location": "eastus",
"name": "playbook-collection",
"properties": {
"priority": 201,
"provisioningState": "Succeeded",
"ruleCollections": [
{
"action": {
"type": "Deny"
},
"name": "playbook-collection",
"priority": 201,
"ruleCollectionType": "FirewallPolicyFilterRuleCollection",
"rules": [
{
"description": "test-playbook-collection",
"destinationAddresses": [
"189.160.40.11",
"189.160.40.11"
],
"destinationFqdns": [],
"destinationIpGroups": [],
"destinationPorts": [
"8080"
],
"ipProtocols": [
"UDP",
"TCP"
],
"name": "playbook-rule",
"ruleType": "NetworkRule",
"sourceAddresses": [
"189.160.40.11",
"189.160.40.11"
],
"sourceIpGroups": []
}
]
}
]
},
"type": "Microsoft.Network/FirewallPolicies/RuleCollectionGroups"
}
}
}
Human Readable Output
xsoar-policy Rule Collections List
Current page size: 1
Showing page 1 out others that may exist.
Name Action Priority playbook-collection Deny 201
azure-firewall-rule-list
List rules in the firewall or in the policy. One of the arguments ‘firewall_name’ or ‘policy’ must be provided.
Base Command
azure-firewall-rule-list
Input
| Argument Name | Description | Required |
|---|---|---|
| firewall_name | The name of the Azure firewall that contains the rules. | Optional |
| policy | The name of the Azure policy that contains the rules. | Optional |
| rule_type | The names of the rule types to retrieve. Required when the “firewall_name” argument is provided. Possible values are: application_rule, network_rule, nat_rule. | Optional |
| collection_name | The name of the rule collection that contains the rules. | Required |
| limit | The maximum number of results to retrieve. Minimum value is 1. Default is 50. | Optional |
| page | The page number of the results to retrieve. Minimum value is 1. Default is 1. | Optional |
| subscription_id | The subscription ID. Note: This argument will override the instance parameter ‘Default Subscription ID’. | Optional |
| resource_group_name | The name of the resource group. Note: This argument will override the instance parameter ‘Default Resource Group Name’. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| AzureFirewall.Rule.name | String | Rule name. |
Command example
!azure-firewall-rule-list policy=xsoar-policy collection_name=playbook-collection rule_type=network_rule limit=1 page=1
Context Example
{
"AzureFirewall": {
"Rule": {
"description": "test-playbook-collection",
"destinationAddresses": [
"189.160.40.11",
"189.160.40.11"
],
"destinationFqdns": [],
"destinationIpGroups": [],
"destinationPorts": [
"8080"
],
"ipProtocols": [
"UDP",
"TCP"
],
"name": "playbook-rule",
"ruleType": "NetworkRule",
"sourceAddresses": [
"189.160.40.11",
"189.160.40.11"
],
"sourceIpGroups": []
}
}
}
Human Readable Output
Policy xsoar-policy network_rule Rules List
Current page size: 1
Showing page 1 out others that may exist.
Name playbook-rule
azure-firewall-rule-get
Retrieve rule information. One of the arguments ‘firewall_name’ or ‘policy’ must be provided.
Base Command
azure-firewall-rule-get
Input
| Argument Name | Description | Required |
|---|---|---|
| firewall_name | The name of the firewall that contains the rule. | Optional |
| policy | The name of the Azure policy that contains the rules. | Optional |
| rule_type | The name of the rule type collection that contains the rule. Required when the “firewall_name” argument is provided. Possible values are: application_rule, network_rule, nat_rule. | Optional |
| collection_name | The name of the rule collection that contains the rule. | Required |
| rule_name | The name of the rule to retrieve. | Required |
| subscription_id | The subscription ID. Note: This argument will override the instance parameter ‘Default Subscription ID’. | Optional |
| resource_group_name | The name of the resource group. Note: This argument will override the instance parameter ‘Default Resource Group Name’. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| AzureFirewall.Rule.name | String | Rule name. |
Command example
!azure-firewall-rule-get policy=xsoar-policy collection_name=playbook-collection rule_name=new-playbook-rule
Context Example
{
"AzureFirewall": {
"Rule": {
"description": "test-playbook-collection",
"destinationAddresses": [
"189.160.40.11",
"189.160.40.11"
],
"destinationFqdns": [],
"destinationIpGroups": [],
"destinationPorts": [
"8080"
],
"ipProtocols": [
"UDP"
],
"name": "new-playbook-rule",
"ruleType": "NetworkRule",
"sourceAddresses": [
"189.160.40.11",
"189.160.40.11"
],
"sourceIpGroups": []
}
}
}
Human Readable Output
Rule new-playbook-rule Information
Name new-playbook-rule
azure-firewall-policy-create
Create a firewall policy. This command only creates the policy resource. In order to attach the policy to a firewall, run the ‘azure-firewall-policy-attach’ command.
Base Command
azure-firewall-policy-create
Input
| Argument Name | Description | Required |
|---|---|---|
| policy_name | The name of the Azure policy to create. | Required |
| threat_intelligence_mode | The operation mode for threat intelligence. Possible values are: Alert, Deny, Turned-off. Default is Turned-off. | Required |
| ips | Comma-separated list of IP addresses for the threat intelligence whitelist. | Optional |
| domains | Comma-separated list of fully qualified domain names for the threat intelligence whitelist. For example : *.microsoft.com,email.college.edu . | Optional |
| location | Policy resource region location. Possible values are: northcentralus, eastus, northeurope, westeurope, eastasia, southeastasia, eastus2, centralus, southcentralus, westus, japaneast, japanwest, australiaeast, australiasoutheast, brazilsouth, centralindia, southindia, westindia, canadacentral, canadaeast, uksouth, ukwest, westcentralus, westus2, koreacentral, francecentral, australiacentral, uaenorth, southafricanorth, switzerlandnorth, germanywestcentral, norwayeast, westus3, jioindiawest. | Required |
| tier | Tier of an Azure policy. Possible values are: Standard, Premium. Default is Standard. | Required |
| base_policy_id | The ID of the parent firewall policy from which rules are inherited. | Optional |
| enable_proxy | Whether to enable the DNS proxy on firewalls attached to the firewall policy. Possible values are: True, False. Default is False. | Optional |
| dns_servers | Comma-separated list of custom DNS servers. | Optional |
| interval | Indicates how long to wait between command executions (in seconds) when the ‘polling’ argument is true. Minimum value is 10 seconds. Default is 30. | Optional |
| timeout | Indicates the time in seconds until the polling sequence times out. Default is 60. | Optional |
| subscription_id | The subscription ID. Note: This argument will override the instance parameter ‘Default Subscription ID’. | Optional |
| resource_group_name | The name of the resource group. Note: This argument will override the instance parameter ‘Default Resource Group Name’. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| AzureFirewall.Policy.id | String | Policy resource ID. |
| AzureFirewall.Policy.name | String | Policy resource name. |
Command example
!azure-firewall-policy-create policy_name=xsoar-policy threat_intelligence_mode=Alert location=eastus tier=Standard interval=10 timeout=600
Context Example
{
"AzureFirewall": {
"Policy": {
"etag": "b5074926-9b59-4ab8-ba44-7fb39a2879a3",
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/firewallPolicies/xsoar-policy",
"location": "eastus",
"name": "xsoar-policy",
"properties": {
"childPolicies": [],
"dnsSettings": {
"servers": []
},
"firewalls": [],
"provisioningState": "Updating",
"ruleCollectionGroups": [],
"sku": {
"tier": "Standard"
},
"threatIntelMode": "Alert"
},
"type": "Microsoft.Network/FirewallPolicies"
}
}
}
Human Readable Output
Successfully Created Policy “xsoar-policy”
Name Id Tier Location Firewalls Base Policy Child Policies Provisioning State xsoar-policy /subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/firewallPolicies/xsoar-policy Standard eastus Updating
azure-firewall-policy-update
Update the policy resource. The command will update the provided arguments.
Base Command
azure-firewall-policy-update
Input
| Argument Name | Description | Required |
|---|---|---|
| policy_name | The name of the Azure policy to update. | Required |
| threat_intelligence_mode | The operation mode for threat intelligence. Possible values are: Alert, Deny, Turned-off. | Optional |
| ips | Comma-separated list of IP addresses for the threat intelligence whitelist. | Optional |
| domains | Comma-separated list of fully qualified domain names for the threat intelligence whitelist. For example : *.microsoft.com,email.college.edu . | Optional |
| base_policy_id | The ID of the parent firewall policy from which rules are inherited. | Optional |
| enable_proxy | Whether to enable the DNS Proxy on Firewalls attached to the Firewall Policy. Possible values are: True, False. | Optional |
| dns_servers | Comma-separated list of custom DNS servers. | Optional |
| interval | Indicates how long to wait between command executions (in seconds) when the ‘polling’ argument is true. Minimum value is 10 seconds. Default is 30. | Optional |
| timeout | Indicates the time in seconds until the polling sequence times out. Default is 60. | Optional |
| subscription_id | The subscription ID. Note: This argument will override the instance parameter ‘Default Subscription ID’. | Optional |
| resource_group_name | The name of the resource group. Note: This argument will override the instance parameter ‘Default Resource Group Name’. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| AzureFirewall.Policy.id | String | Policy resource ID. |
| AzureFirewall.Policy.name | String | Policy resource name. |
Command example
!azure-firewall-policy-update policy_name=xsoar-policy threat_intelligence_mode=Deny interval=10 timeout=600
Context Example
{
"AzureFirewall": {
"Policy": {
"etag": "15f105aa-3059-4e9b-97e9-3b85a839ecf3",
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/firewallPolicies/xsoar-policy",
"location": "eastus",
"name": "xsoar-policy",
"properties": {
"childPolicies": [],
"dnsSettings": {
"servers": []
},
"firewalls": [],
"provisioningState": "Updating",
"ruleCollectionGroups": [],
"sku": {
"tier": "Standard"
},
"threatIntelMode": "Deny"
},
"type": "Microsoft.Network/FirewallPolicies"
}
}
}
Human Readable Output
Successfully Updated Policy “xsoar-policy”
Name Id Tier Location Firewalls Base Policy Child Policies Provisioning State xsoar-policy /subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/firewallPolicies/xsoar-policy Standard eastus Updating
azure-firewall-policy-get
Retrieve policy information.
Base Command
azure-firewall-policy-get
Input
| Argument Name | Description | Required |
|---|---|---|
| policy_names | Comma-separated list of policy names to retrieve. | Required |
| polling | Indicates if the command was scheduled. Possible values are: True, False. Default is True. | Optional |
| interval | Indicates how long to wait between command executions (in seconds) when the ‘polling’ argument is true. Minimum value is 10 seconds. Default is 30. | Optional |
| timeout | Indicates the time in seconds until the polling sequence times out. Default is 60. | Optional |
| subscription_id | The subscription ID. Note: This argument will override the instance parameter ‘Default Subscription ID’. | Optional |
| resource_group_name | The name of the resource group. Note: This argument will override the instance parameter ‘Default Resource Group Name’. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| AzureFirewall.Policy.id | String | Policy resource ID. |
| AzureFirewall.Policy.name | String | Policy resource name. |
Command example
!azure-firewall-policy-get policy_names=xsoar-policy interval=10 timeout=600
Context Example
{
"AzureFirewall": {
"Policy": {
"etag": "b5074926-9b59-4ab8-ba44-7fb39a2879a3",
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/firewallPolicies/xsoar-policy",
"location": "eastus",
"name": "xsoar-policy",
"properties": {
"childPolicies": [],
"dnsSettings": {
"servers": []
},
"firewalls": [],
"provisioningState": "Succeeded",
"ruleCollectionGroups": [],
"sku": {
"tier": "Standard"
},
"threatIntelMode": "Alert"
},
"type": "Microsoft.Network/FirewallPolicies"
}
}
}
Human Readable Output
Policy xsoar-policy information
Name Id Tier Location Firewalls Base Policy Child Policies Provisioning State xsoar-policy /subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/firewallPolicies/xsoar-policy Standard eastus Succeeded
azure-firewall-policy-delete
Delete policy resource.
Base Command
azure-firewall-policy-delete
Input
| Argument Name | Description | Required |
|---|---|---|
| policy_names | Comma-separated list of policy names to delete. | Required |
| subscription_id | The subscription ID. Note: This argument will override the instance parameter ‘Default Subscription ID’. | Optional |
| resource_group_name | The name of the resource group. Note: This argument will override the instance parameter ‘Default Resource Group Name’. | Optional |
Context Output
There is no context output for this command.
azure-firewall-policy-list
List the policy in the resource group or subscription.
Base Command
azure-firewall-policy-list
Input
| Argument Name | Description | Required |
|---|---|---|
| resource | The resource that contains the policies to list. Possible values are: resource_group, subscription. Default is resource_group. | Required |
| limit | The maximum number of results to retrieve. Minimum value is 1. Default is 50. | Optional |
| page | The page number of the results to retrieve. Minimum value is 1. Default is 1. | Optional |
| subscription_id | The subscription ID. Note: This argument will override the instance parameter ‘Default Subscription ID’. | Optional |
| resource_group_name | The name of the resource group. Note: This argument will override the instance parameter ‘Default Resource Group Name’. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| AzureFirewall.Policy.id | String | Policy resource ID. |
| AzureFirewall.Policy.name | String | Policy resource name. |
Command example
!azure-firewall-policy-list resource=resource_group limit=1 page=1
Context Example
{
"AzureFirewall": {
"Policy": {
"etag": "b5074926-9b59-4ab8-ba44-7fb39a2879a3",
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/firewallPolicies/xsoar-policy",
"location": "eastus",
"name": "xsoar-policy",
"properties": {
"childPolicies": [],
"dnsSettings": {
"servers": []
},
"firewalls": [],
"provisioningState": "Succeeded",
"ruleCollectionGroups": [],
"sku": {
"tier": "Standard"
},
"threatIntelMode": "Alert"
},
"type": "Microsoft.Network/FirewallPolicies"
}
}
}
Human Readable Output
Policy List
Current page size: 1
Showing page 1 out others that may exist.
Name Id Tier Location Firewalls Base Policy Child Policies Provisioning State xsoar-policy /subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/firewallPolicies/xsoar-policy Standard eastus Succeeded
azure-firewall-policy-attach
Attach a policy to a firewall. The policy and firewall have to belong to the same tier.
Base Command
azure-firewall-policy-attach
Input
| Argument Name | Description | Required |
|---|---|---|
| firewall_names | Comma-separated list of firewall names to which the policy will be attached. | Required |
| policy_id | The ID of the policy to attach. | Required |
| interval | Indicates how long to wait between command executions (in seconds) when the ‘polling’ argument is true. Minimum value is 10 seconds. Default is 30. | Optional |
| timeout | Indicates the time in seconds until the polling sequence times out. Default is 60. | Optional |
| subscription_id | The subscription ID. Note: This argument will override the instance parameter ‘Default Subscription ID’. | Optional |
| resource_group_name | The name of the resource group. Note: This argument will override the instance parameter ‘Default Resource Group Name’. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| AzureFirewall.Firewall.id | String | Firewall resource ID. |
| AzureFirewall.Firewall.name | String | Firewall resource name. |
| AzureFirewall.Firewall.location | String | Firewall resource location. |
Command example
!azure-firewall-policy-attach firewall_names=test-ip policy_id=/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/firewallPolicies/xsoar-policy interval=10 timeout=600
Context Example
{
"AzureFirewall": {
"Firewall": {
"etag": "W/\"03a287f1-5106-426c-b181-166258b1fc6a\"",
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/azureFirewalls/test-ip",
"location": "eastus",
"name": "test-ip",
"properties": {
"additionalProperties": {},
"applicationRuleCollections": [],
"firewallPolicy": {
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/firewallPolicies/xsoar-policy"
},
"ipConfigurations": [
{
"etag": "W/\"03a287f1-5106-426c-b181-166258b1fc6a\"",
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/azureFirewalls/test-ip/azureFirewallIpConfigurations/test-ip",
"name": "test-ip",
"properties": {
"privateIPAddress": "189.160.40.11",
"privateIPAllocationMethod": "Dynamic",
"provisioningState": "Succeeded",
"publicIPAddress": {
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/publicIPAddresses/test-ip"
},
"subnet": {
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/virtualNetworks/test-v-n/subnets/AzureFirewallSubnet"
}
},
"type": "Microsoft.Network/azureFirewalls/azureFirewallIpConfigurations"
}
],
"natRuleCollections": [],
"networkRuleCollections": [],
"provisioningState": "Updating",
"sku": {
"name": "AZFW_VNet",
"tier": "Standard"
},
"threatIntelMode": "Alert"
},
"tags": {},
"type": "Microsoft.Network/azureFirewalls"
}
}
}
Human Readable Output
Successfully Updated Firewall “test-ip”
Name Id Location Subnet Threat Intel Mode Private Ip Address Provisioning State test-ip /subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/azureFirewalls/test-ip eastus /subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/virtualNetworks/test-v-n/subnets/AzureFirewallSubnet Alert 189.160.40.11 Updating
azure-firewall-policy-detach
Remove a policy from the firewall. This command will detach the policy and firewall, but will not delete the policy.
Base Command
azure-firewall-policy-detach
Input
| Argument Name | Description | Required |
|---|---|---|
| firewall_names | Comma-separated list of firewall names from which the policy will be removed. | Required |
| interval | Indicates how long to wait between command executions (in seconds) when the ‘polling’ argument is true. Minimum value is 10 seconds. Default is 30. | Optional |
| timeout | Indicates the time in seconds until the polling sequence times out. Default is 60. | Optional |
| subscription_id | The subscription ID. Note: This argument will override the instance parameter ‘Default Subscription ID’. | Optional |
| resource_group_name | The name of the resource group. Note: This argument will override the instance parameter ‘Default Resource Group Name’. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| AzureFirewall.Firewall.id | String | Firewall resource ID. |
| AzureFirewall.Firewall.name | String | Firewall resource name. |
| AzureFirewall.Firewall.location | String | Firewall resource location. |
Command example
!azure-firewall-policy-detach firewall_names=test-ip interval=10 timeout=600
Context Example
{
"AzureFirewall": {
"Firewall": {
"etag": "W/\"f4e53250-f431-437b-a86f-7aa6a34d4616\"",
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/azureFirewalls/test-ip",
"location": "eastus",
"name": "test-ip",
"properties": {
"additionalProperties": {},
"applicationRuleCollections": [],
"ipConfigurations": [
{
"etag": "W/\"f4e53250-f431-437b-a86f-7aa6a34d4616\"",
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/azureFirewalls/test-ip/azureFirewallIpConfigurations/test-ip",
"name": "test-ip",
"properties": {
"privateIPAddress": "189.160.40.11",
"privateIPAllocationMethod": "Dynamic",
"provisioningState": "Succeeded",
"publicIPAddress": {
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/publicIPAddresses/test-ip"
},
"subnet": {
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/virtualNetworks/test-v-n/subnets/AzureFirewallSubnet"
}
},
"type": "Microsoft.Network/azureFirewalls/azureFirewallIpConfigurations"
}
],
"natRuleCollections": [],
"networkRuleCollections": [],
"provisioningState": "Updating",
"sku": {
"name": "AZFW_VNet",
"tier": "Standard"
},
"threatIntelMode": "Alert"
},
"tags": {},
"type": "Microsoft.Network/azureFirewalls"
}
}
}
Human Readable Output
Successfully Updated Firewall “test-ip”
Name Id Location Subnet Threat Intel Mode Private Ip Address Provisioning State test-ip /subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/azureFirewalls/test-ip eastus /subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/virtualNetworks/test-v-n/subnets/AzureFirewallSubnet Alert 189.160.40.11 Updating
azure-firewall-network-rule-collection-create
Create a network rule collection in a firewall or policy. The command will return firewall or policy rule collection resource information. One of the arguments ‘firewall_name’ or ‘policy’ must be provided.
Base Command
azure-firewall-network-rule-collection-create
Input
| Argument Name | Description | Required |
|---|---|---|
| firewall_name | The name of the firewall that contains the collection. | Optional |
| policy | The name of the policy that contains the collection. | Optional |
| collection_name | The name of the network rule collection to create. | Required |
| collection_priority | The priority of the network rule collection resource. Minimum value is 100, maximum value is 65000. | Required |
| action | The action type of a rule collection. Possible values are: Allow, Deny. | Required |
| rule_name | The name of the network rule to create. | Required |
| description | The description of the created rule. | Required |
| protocols | Comma-separated list of protocols for the created rule. Possible values are: TCP, UDP, ICMP, Any. | Required |
| source_type | Rule source type. Possible values are: ip_address, ip_group. | Required |
| source_ips | Comma-separated list of source IP addresses for the created rule. Must be provided when the ‘source_type’ argument is assigned to ‘ip_address’. | Optional |
| source_ip_group_ids | Comma-separated list of source IP group IDs for the created rule. Must be provided when the ‘source_type’ argument is assigned to ‘ip_group’. | Optional |
| destination_type | Rule destination type. Possible values are: ip_address, ip_group, service_tag, fqdn. | Required |
| destinations | Comma-separated list of destinations for the created rule. Must be consistent with the provided ‘destination_type’ argument. Supports IP addresses, service tag names, IP group IDs and FQDN addresses. | Required |
| destination_ports | Comma-separated list of destination ports. | Required |
| interval | Indicates how long to wait between command executions (in seconds) when the ‘polling’ argument is true. Minimum value is 10 seconds. Default is 30. | Optional |
| timeout | Indicates the time in seconds until the polling sequence times out. Default is 60. | Optional |
| subscription_id | The subscription ID. Note: This argument will override the instance parameter ‘Default Subscription ID’. | Optional |
| resource_group_name | The name of the resource group. Note: This argument will override the instance parameter ‘Default Resource Group Name’. | Optional |
Context Output
There is no context output for this command.
Command example
!azure-firewall-network-rule-collection-create policy=xsoar-policy collection_name=playbook-collection collection_priority=105 action=Allow rule_name=playbook-rule description=test-playbook-collection protocols=UDP,TCP source_type=ip_address source_ips=189.160.40.11,189.160.40.11 destination_type=ip_address destinations=189.160.40.11,189.160.40.11 destination_ports=8080 interval=10 timeout=600
Context Example
{
"AzureFirewall": {
"Policy": {
"etag": "23384541-d2ae-4922-95ed-9c70ffbe336e",
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/firewallPolicies/xsoar-policy",
"location": "eastus",
"name": "xsoar-policy",
"properties": {
"childPolicies": [],
"dnsSettings": {
"servers": []
},
"firewalls": [],
"provisioningState": "Updating",
"ruleCollectionGroups": [
{
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/firewallPolicies/xsoar-policy/ruleCollectionGroups/playbook-collection"
}
],
"sku": {
"tier": "Standard"
},
"threatIntelMode": "Deny"
},
"type": "Microsoft.Network/FirewallPolicies"
}
}
}
Human Readable Output
Successfully Updated Policy “xsoar-policy”
Name Id Tier Location Firewalls Base Policy Child Policies Provisioning State xsoar-policy /subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/firewallPolicies/xsoar-policy Standard eastus Updating
azure-firewall-network-rule-collection-delete
Delete a network rule collection from the firewall or policy. One of the arguments ‘firewall_name’ or ‘policy’ must be provided.
Base Command
azure-firewall-network-rule-collection-delete
Input
| Argument Name | Description | Required |
|---|---|---|
| firewall_name | The name of the firewall that contains the collection. | Optional |
| policy | The name of the policy the contains the collection. | Optional |
| collection_name | The name of the network rule collection to delete. | Required |
| interval | Indicates how long to wait between command executions (in seconds) when the ‘polling’ argument is true. Minimum value is 10 seconds. Default is 30. | Optional |
| timeout | Indicates the time in seconds until the polling sequence times out. Default is 60. | Optional |
| subscription_id | The subscription ID. Note: This argument will override the instance parameter ‘Default Subscription ID’. | Optional |
| resource_group_name | The name of the resource group. Note: This argument will override the instance parameter ‘Default Resource Group Name’. | Optional |
Context Output
There is no context output for this command.
Command example
!azure-firewall-network-rule-collection-delete policy=xsoar-policy collection_name=playbook-collection interval=10 timeout=600
Context Example
{
"AzureFirewall": {
"Policy": {
"etag": "5984cc1d-8e84-4385-adbe-e1d9293d7e97",
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/firewallPolicies/xsoar-policy",
"location": "eastus",
"name": "xsoar-policy",
"properties": {
"childPolicies": [],
"dnsSettings": {
"servers": []
},
"firewalls": [],
"provisioningState": "Updating",
"ruleCollectionGroups": [
{
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/firewallPolicies/xsoar-policy/ruleCollectionGroups/playbook-collection"
}
],
"sku": {
"tier": "Standard"
},
"threatIntelMode": "Deny"
},
"type": "Microsoft.Network/FirewallPolicies"
}
}
}
Human Readable Output
Successfully Updated Policy “xsoar-policy”
Name Id Tier Location Firewalls Base Policy Child Policies Provisioning State xsoar-policy /subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/firewallPolicies/xsoar-policy Standard eastus Updating
azure-firewall-network-rule-create
Create a network rule in the firewall or policy rule collection. One of the arguments ‘firewall_name’ or ‘policy’ must be provided.
Base Command
azure-firewall-network-rule-create
Input
| Argument Name | Description | Required |
|---|---|---|
| firewall_name | The name of the firewall that contains the collection. | Optional |
| policy | The name of the policy that contains the collection. | Optional |
| collection_name | The name of the network rule collection that contains the rule. | Required |
| rule_name | The name of the network rule to create. | Required |
| description | The description of the created rule. | Required |
| protocols | Comma-separated list of protocols for the created rule. Possible values are: TCP, UDP, ICMP, Any. | Required |
| source_type | Rule source type. Possible values are: ip_address, ip_group. | Required |
| source_ips | Comma-separated list of source IP addresses for the created rule. Must be provided when the ‘source_type’ argument is assigned to ‘ip_address’. | Optional |
| source_ip_group_ids | Comma-separated list of source IP group IDs for the created rule. Must be provided when the ‘source_type’ argument is assigned to ‘ip_group’. | Optional |
| destination_type | Rule destination type. Possible values are: ip_address, ip_group, service_tag, fqdn. | Required |
| destinations | Comma-separated list of destinations for the created rule. Must be consistent with the provided ‘destination_type’ argument. Supports IP addresses, service tag names, IP group IDs and FQDN addresses. | Required |
| destination_ports | Comma-separated list of destination ports. | Required |
| interval | Indicates how long to wait between command executions (in seconds) when the ‘polling’ argument is true. Minimum value is 10 seconds. Default is 30. | Optional |
| timeout | Indicates the time in seconds until the polling sequence times out. Default is 60. | Optional |
| subscription_id | The subscription ID. Note: This argument will override the instance parameter ‘Default Subscription ID’. | Optional |
| resource_group_name | The name of the resource group. Note: This argument will override the instance parameter ‘Default Resource Group Name’. | Optional |
Context Output
There is no context output for this command.
Command example
!azure-firewall-network-rule-create policy=xsoar-policy collection_name=playbook-collection rule_name=new-playbook-rule description=test-playbook-collection protocols=UDP,TCP source_type=ip_address source_ips=189.160.40.11,189.160.40.11 destination_type=ip_address destinations=189.160.40.11,189.160.40.11 destination_ports=8080 interval=10 timeout=600
Context Example
{
"AzureFirewall": {
"Policy": {
"etag": "e1950ec2-3ab1-43aa-9d84-a3c4053c2f52",
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/firewallPolicies/xsoar-policy",
"location": "eastus",
"name": "xsoar-policy",
"properties": {
"childPolicies": [],
"dnsSettings": {
"servers": []
},
"firewalls": [],
"provisioningState": "Updating",
"ruleCollectionGroups": [
{
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/firewallPolicies/xsoar-policy/ruleCollectionGroups/playbook-collection"
}
],
"sku": {
"tier": "Standard"
},
"threatIntelMode": "Deny"
},
"type": "Microsoft.Network/FirewallPolicies"
}
}
}
Human Readable Output
Successfully Updated Policy “xsoar-policy”
Name Id Tier Location Firewalls Base Policy Child Policies Provisioning State xsoar-policy /subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/firewallPolicies/xsoar-policy Standard eastus Updating
azure-firewall-network-rule-update
Update the network rule in the firewall. The provided arguments will replace the existing rule configuration. One of the arguments ‘firewall_name’ or ‘policy’ must be provided. The command will not replace the rule source or destination types.
Base Command
azure-firewall-network-rule-update
Input
| Argument Name | Description | Required |
|---|---|---|
| firewall_name | The name of the firewall that contains the collection. | Optional |
| policy | The name of the policy that contains the collection. | Optional |
| collection_name | The name of the network rule collection to update. | Required |
| rule_name | The name of the network rule to update. | Required |
| description | The new description of the rule. | Optional |
| protocols | Comma-separated list of protocols for the rule. Possible values are: TCP, UDP, ICMP, Any. | Optional |
| source_type | Rule source type. Possible values are: ip_address, ip_group. | Optional |
| source_ips | Comma-separated list of source IP addresses for the created rule. Must be provided when the ‘source_type’ argument is assigned to ‘ip_address’. | Optional |
| source_ip_group_ids | Comma-separated list of source IP group IDs for the created rule. Must be provided when the ‘source_type’ argument is assigned to ‘ip_group’. | Optional |
| destination_type | Rule destination type. Must be provided when the ‘destinations’ argument is provided. Possible values are: ip_address, ip_group, service_tag, fqdn. | Optional |
| destinations | Comma-separated list of destinations for the created rule. Must be consistent with the provided ‘destination_type’ argument. Supports IP addresses, service tag names, IP group IDs and FQDN addresses. | Optional |
| destination_ports | Comma-separated list of destination ports. | Optional |
| interval | Indicates how long to wait between command executions (in seconds) when the ‘polling’ argument is true. Minimum value is 10 seconds. Default is 30. | Optional |
| timeout | Indicates the time in seconds until the polling sequence times out. Default is 60. | Optional |
| subscription_id | The subscription ID. Note: This argument will override the instance parameter ‘Default Subscription ID’. | Optional |
| resource_group_name | The name of the resource group. Note: This argument will override the instance parameter ‘Default Resource Group Name’. | Optional |
Context Output
There is no context output for this command.
Command example
!azure-firewall-network-rule-update policy=xsoar-policy collection_name=playbook-collection rule_name=new-playbook-rule protocols=UDP interval=10 timeout=600
Context Example
{
"AzureFirewall": {
"Policy": {
"etag": "9e0bdc8a-99e9-4337-8778-2ec85d29d445",
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/firewallPolicies/xsoar-policy",
"location": "eastus",
"name": "xsoar-policy",
"properties": {
"childPolicies": [],
"dnsSettings": {
"servers": []
},
"firewalls": [],
"provisioningState": "Succeeded",
"ruleCollectionGroups": [
{
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/firewallPolicies/xsoar-policy/ruleCollectionGroups/playbook-collection"
}
],
"sku": {
"tier": "Standard"
},
"threatIntelMode": "Deny"
},
"type": "Microsoft.Network/FirewallPolicies"
}
}
}
Human Readable Output
Successfully Updated Policy “xsoar-policy”
Name Id Tier Location Firewalls Base Policy Child Policies Provisioning State xsoar-policy /subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/firewallPolicies/xsoar-policy Standard eastus Succeeded
azure-firewall-network-rule-delete
Delete a network rule from the collection. One of the arguments ‘firewall_name’ or ‘policy’ must be provided.
Base Command
azure-firewall-network-rule-delete
Input
| Argument Name | Description | Required |
|---|---|---|
| firewall_name | The name of the firewall that contains the collection. | Optional |
| policy | The name of the policy that contains the collection. | Optional |
| collection_name | The name of the network rule collection to update. | Required |
| rule_names | Comma-separated list of network rule names to delete from the collection. | Required |
| interval | Indicates how long to wait between command executions (in seconds) when the ‘polling’ argument is true. Minimum value is 10 seconds. Default is 30. | Optional |
| timeout | Indicates the time in seconds until the polling sequence times out. Default is 60. | Optional |
| subscription_id | The subscription ID. Note: This argument will override the instance parameter ‘Default Subscription ID’. | Optional |
| resource_group_name | The name of the resource group. Note: This argument will override the instance parameter ‘Default Resource Group Name’. | Optional |
Context Output
There is no context output for this command.
Command example
!azure-firewall-network-rule-delete policy=xsoar-policy collection_name=playbook-collection rule_names=new-playbook-rule interval=10 timeout=600
Context Example
{
"AzureFirewall": {
"Policy": {
"etag": "6b9e5bf4-3e11-4705-84c6-d5c14e45f13c",
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/firewallPolicies/xsoar-policy",
"location": "eastus",
"name": "xsoar-policy",
"properties": {
"childPolicies": [],
"dnsSettings": {
"servers": []
},
"firewalls": [],
"provisioningState": "Updating",
"ruleCollectionGroups": [
{
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/firewallPolicies/xsoar-policy/ruleCollectionGroups/playbook-collection"
}
],
"sku": {
"tier": "Standard"
},
"threatIntelMode": "Deny"
},
"type": "Microsoft.Network/FirewallPolicies"
}
}
}
Human Readable Output
Successfully Updated Policy “xsoar-policy”
Name Id Tier Location Firewalls Base Policy Child Policies Provisioning State xsoar-policy /subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/firewallPolicies/xsoar-policy Standard eastus Updating
azure-firewall-network-rule-collection-update
Update a network rule collection in a firewall or policy. The command will update the provided arguments. One of the arguments ‘firewall_name’ or ‘policy’ must be provided. The command will return firewall or policy rule collection resource information.
Base Command
azure-firewall-network-rule-collection-update
Input
| Argument Name | Description | Required |
|---|---|---|
| firewall_name | The name of the firewall that contains the collection. | Optional |
| policy | The name of the policy that contains the collection. | Optional |
| collection_name | The name of the network rule collection to update. | Required |
| priority | The priority of the network rule collection resource. Minimum value is 100, maximum value us 65000. | Optional |
| action | The action type of a rule collection. Possible values are: Allow, Deny. | Optional |
| interval | Indicates how long to wait between command executions (in seconds) when the ‘polling’ argument is true. Minimum value is 10 seconds. Default is 30. | Optional |
| timeout | Indicates the time in seconds until the polling sequence times out. Default is 60. | Optional |
| subscription_id | The subscription ID. Note: This argument will override the instance parameter ‘Default Subscription ID’. | Optional |
| resource_group_name | The name of the resource group. Note: This argument will override the instance parameter ‘Default Resource Group Name’. | Optional |
Context Output
There is no context output for this command.
Command example
!azure-firewall-network-rule-collection-update policy=xsoar-policy collection_name=playbook-collection priority=201 action=Deny interval=10 timeout=600
Context Example
{
"AzureFirewall": {
"Policy": {
"etag": "a4caa2e4-cc96-460b-9202-4914f74ce5e9",
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/firewallPolicies/xsoar-policy",
"location": "eastus",
"name": "xsoar-policy",
"properties": {
"childPolicies": [],
"dnsSettings": {
"servers": []
},
"firewalls": [],
"provisioningState": "Succeeded",
"ruleCollectionGroups": [
{
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/firewallPolicies/xsoar-policy/ruleCollectionGroups/playbook-collection"
}
],
"sku": {
"tier": "Standard"
},
"threatIntelMode": "Deny"
},
"type": "Microsoft.Network/FirewallPolicies"
}
}
}
Human Readable Output
Successfully Updated Policy “xsoar-policy”
Name Id Tier Location Firewalls Base Policy Child Policies Provisioning State xsoar-policy /subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/firewallPolicies/xsoar-policy Standard eastus Succeeded
azure-firewall-service-tag-list
Retrieve service tags information.
Base Command
azure-firewall-service-tag-list
Input
| Argument Name | Description | Required |
|---|---|---|
| location | The location that will be used as a reference for a version (not as a filter based on location, the command will retrieve the list of service tags with prefix details across all regions but limited to the cloud that your subscription belongs to). Possible values are: northcentralus, eastus, northeurope, westeurope, eastasia, southeastasia, eastus2, centralus, southcentralus, westus, japaneast, japanwest, australiaeast, australiasoutheast, brazilsouth, centralindia, southindia, westindia, canadacentral, canadaeast, uksouth, ukwest, westcentralus, westus2, koreacentral, francecentral, australiacentral, uaenorth, southafricanorth, switzerlandnorth, germanywestcentral, norwayeast, westus3, jioindiawest. | Required |
| limit | The maximum number of results to retrieve. Minimum value is 1. Default is 50. | Optional |
| page | The page number of the results to retrieve. Minimum value is 1. Default is 1. | Optional |
| subscription_id | The subscription ID. Note: This argument will override the instance parameter ‘Default Subscription ID’. | Optional |
| resource_group_name | The name of the resource group. Note: This argument will override the instance parameter ‘Default Resource Group Name’. | Optional |
Context Output
There is no context output for this command.
Command example
!azure-firewall-service-tag-list location=eastus limit=1 page=3
Context Example
{
"AzureFirewall": {
"ServiceTag": {
"id": "ApiManagement.AustraliaCentral",
"name": "ApiManagement.AustraliaCentral",
"properties": {
"addressPrefixes": [
"20.36.106.68/31",
"20.36.107.176/28",
"20.37.52.67/32",
"2603:1010:304:402::140/124"
],
"changeNumber": "2",
"networkFeatures": [
"API",
"NSG",
"UDR",
"FW"
],
"region": "australiacentral",
"state": "GA",
"systemService": "AzureApiManagement"
},
"serviceTagChangeNumber": "86"
}
}
}
Human Readable Output
Service Tag List
Current page size: 1
Showing page 3 out others that may exist.
Name Id ApiManagement.AustraliaCentral ApiManagement.AustraliaCentral
azure-firewall-ip-group-create
Create an IP group.
Base Command
azure-firewall-ip-group-create
Input
| Argument Name | Description | Required |
|---|---|---|
| ip_group_name | The name of the IP group resource to create. | Required |
| ips | Comma-separated list of IP addresses or IP address prefixes in the IP group resource. | Optional |
| location | The location of the IP group resource. Possible values are: northcentralus, eastus, northeurope, westeurope, eastasia, southeastasia, eastus2, centralus, southcentralus, westus, japaneast, japanwest, australiaeast, australiasoutheast, brazilsouth, centralindia, southindia, westindia, canadacentral, canadaeast, uksouth, ukwest, westcentralus, westus2, koreacentral, francecentral, australiacentral, uaenorth, southafricanorth, switzerlandnorth, germanywestcentral, norwayeast, westus3, jioindiawest. | Required |
| interval | Indicates how long to wait between command executions (in seconds) when the ‘polling’ argument is true. Minimum value is 10 seconds. Default is 30. | Optional |
| timeout | Indicates the time in seconds until the polling sequence times out. Default is 60. | Optional |
| subscription_id | The subscription ID. Note: This argument will override the instance parameter ‘Default Subscription ID’. | Optional |
| resource_group_name | The name of the resource group. Note: This argument will override the instance parameter ‘Default Resource Group Name’. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| AzureFirewall.IPGroup.id | String | IP group resource ID. |
| AzureFirewall.IPGroup.name | String | IP group resource name. |
| AzureFirewall.IPGroup.properties.ipAddresses | String | List of IP addresses or IP address prefixes in the IP groups resource. |
Command example
!azure-firewall-ip-group-create ip_group_name=xsoar-ip-group ips=189.160.40.11 location=eastus interval=10 timeout=600
Context Example
{
"AzureFirewall": {
"IPGroup": {
"etag": "8ea22ba3-4023-4c7f-a887-34f5f349d7c6",
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/ipGroups/xsoar-ip-group",
"location": "eastus",
"name": "xsoar-ip-group",
"properties": {
"firewallPolicies": [],
"firewalls": [],
"ipAddresses": [
"189.160.40.11"
],
"provisioningState": "Updating"
},
"type": "Microsoft.Network/IpGroups"
}
}
}
Human Readable Output
Successfully Created IP Group “xsoar-ip-group”
Name Id Ip Addresses Firewalls Firewall Policies Provisioning State xsoar-ip-group /subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/ipGroups/xsoar-ip-group 189.160.40.11 Updating
azure-firewall-ip-group-update
Update an IP group. Add or remove IP addresses from the group.
Base Command
azure-firewall-ip-group-update
Input
| Argument Name | Description | Required |
|---|---|---|
| ip_group_name | The name of the IP group resource to update. | Required |
| ips_to_add | Comma-separated list of IP addresses or IP address prefixes to add to the IP group resource. | Optional |
| ips_to_remove | Comma-separated list of IP addresses or IP address prefixes to remove from the IP group resource. | Optional |
| interval | Indicates how long to wait between command executions (in seconds) when the ‘polling’ argument is true. Minimum value is 10 seconds. Default is 30. | Optional |
| timeout | Indicates the time in seconds until the polling sequence times out. Default is 60. | Optional |
| subscription_id | The subscription ID. Note: This argument will override the instance parameter ‘Default Subscription ID’. | Optional |
| resource_group_name | The name of the resource group. Note: This argument will override the instance parameter ‘Default Resource Group Name’. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| AzureFirewall.IPGroup.id | String | IP group resource ID. |
| AzureFirewall.IPGroup.name | String | IP group resource name. |
| AzureFirewall.IPGroup.properties.ipAddresses | String | List of IP addresses or IP address prefixes in the IP groups resource. |
Command example
!azure-firewall-ip-group-update ip_group_name=xsoar-ip-group ips_to_add=189.160.40.11,189.160.40.11 ips_to_remove=189.160.40.11,1.1.1 interval=10 timeout=600
Context Example
{
"AzureFirewall": {
"IPGroup": {
"etag": "8f0e7d5d-6dfd-429c-ad07-e670f57e4dab",
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/ipGroups/xsoar-ip-group",
"location": "eastus",
"name": "xsoar-ip-group",
"properties": {
"firewallPolicies": [],
"firewalls": [],
"ipAddresses": [
"189.160.40.11",
"189.160.40.11"
],
"provisioningState": "Updating"
},
"type": "Microsoft.Network/IpGroups"
}
}
}
Human Readable Output
xsoar-ip-group IP Group Information
Name Id Ip Addresses Firewalls Firewall Policies Provisioning State xsoar-ip-group /subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/ipGroups/xsoar-ip-group 189.160.40.11,
189.160.40.11Updating
azure-firewall-ip-group-list
List IP groups in a resource group or subscription.
Base Command
azure-firewall-ip-group-list
Input
| Argument Name | Description | Required |
|---|---|---|
| resource | The resource that contains the IP groups to list. Possible values are: resource_group, subscription. Default is resource_group. | Required |
| limit | The maximum number of results to retrieve. Minimum value is 1. Default is 50. | Optional |
| page | The page number of the results to retrieve. Minimum value is 1. Default is 1. | Optional |
| subscription_id | The subscription ID. Note: This argument will override the instance parameter ‘Default Subscription ID’. | Optional |
| resource_group_name | The name of the resource group. Note: This argument will override the instance parameter ‘Default Resource Group Name’. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| AzureFirewall.IPGroup.id | String | IP group resource ID. |
| AzureFirewall.IPGroup.name | String | IP group resource name. |
| AzureFirewall.IPGroup.properties.ipAddresses | String | List of IP addresses or IP address prefixes in the IP groups resource. |
Command example
!azure-firewall-ip-group-list resource=resource_group limit=1 page=1
Context Example
{
"AzureFirewall": {
"IPGroup": {
"etag": "4c626477-c875-4392-9d7c-02464d2a82d9",
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/ipGroups/xsoar-ip-group",
"location": "eastus",
"name": "xsoar-ip-group",
"properties": {
"firewallPolicies": [],
"firewalls": [],
"ipAddresses": [
"189.160.40.11"
],
"provisioningState": "Succeeded"
},
"type": "Microsoft.Network/IpGroups"
}
}
}
Human Readable Output
IP Group List
Current page size: 1
Showing page 1 out others that may exist.
Name Id Ip Addresses Firewalls Firewall Policies Provisioning State xsoar-ip-group /subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/ipGroups/xsoar-ip-group 189.160.40.11 Succeeded
azure-firewall-ip-group-get
Retrieve IP group information.
Base Command
azure-firewall-ip-group-get
Input
| Argument Name | Description | Required |
|---|---|---|
| ip_group_names | Comma-separated list of IP group names resource to retrieve. | Required |
| polling | Indicates if the command was scheduled. Possible values are: True, False. Default is True. | Optional |
| interval | Indicates how long to wait between command executions (in seconds) when the ‘polling’ argument is true. Minimum value is 10 seconds. Default is 30. | Optional |
| timeout | Indicates the time in seconds until the polling sequence times out. Default is 60. | Optional |
| subscription_id | The subscription ID. Note: This argument will override the instance parameter ‘Default Subscription ID’. | Optional |
| resource_group_name | The name of the resource group. Note: This argument will override the instance parameter ‘Default Resource Group Name’. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| AzureFirewall.IPGroup.id | String | IP group resource ID. |
| AzureFirewall.IPGroup.name | String | IP group resource name. |
| AzureFirewall.IPGroup.properties.ipAddresses | String | List of IP addresses or IP address prefixes in the IP groups resource. |
Command example
!azure-firewall-ip-group-get ip_group_names=xsoar-ip-group interval=10 timeout=600
Context Example
{
"AzureFirewall": {
"IPGroup": {
"etag": "4c626477-c875-4392-9d7c-02464d2a82d9",
"id": "/subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/ipGroups/xsoar-ip-group",
"location": "eastus",
"name": "xsoar-ip-group",
"properties": {
"firewallPolicies": [],
"firewalls": [],
"ipAddresses": [
"189.160.40.11"
],
"provisioningState": "Succeeded"
},
"type": "Microsoft.Network/IpGroups"
}
},
"IP": {
"Address": "189.160.40.11"
}
}
Human Readable Output
xsoar-ip-group IP Group Information
Name Id Ip Addresses Firewalls Firewall Policies Provisioning State xsoar-ip-group /subscriptions/xsoar-subscription/resourceGroups/xsoar-resource-group/providers/Microsoft.Network/ipGroups/xsoar-ip-group 189.160.40.11 Succeeded
azure-firewall-ip-group-delete
Delete an IP group resource.
Base Command
azure-firewall-ip-group-delete
Input
| Argument Name | Description | Required |
|---|---|---|
| ip_group_names | Comma-separated list of IP group names resource to delete. | Required |
| subscription_id | The subscription ID. Note: This argument will override the instance parameter ‘Default Subscription ID’. | Optional |
| resource_group_name | The name of the resource group. Note: This argument will override the instance parameter ‘Default Resource Group Name’. | Optional |
Context Output
There is no context output for this command.
Command example
!azure-firewall-ip-group-delete ip_group_names=xsoar-ip-group
Human Readable Output
IP Group xsoar-ip-group deleted successfully.
azure-firewall-subscriptions-list
List all subscriptions for a tenant.
Base Command
azure-firewall-subscriptions-list
Input
There are no input arguments for this command.
Context Output
| Path | Type | Description |
|---|---|---|
| AzureFirewall.Subscription.authorizationSource | String | The authorization source of the request. |
| AzureFirewall.Subscription.displayName | String | The subscription display name. |
| AzureFirewall.Subscription.id | String | The fully qualified ID for the subscription. For example, /subscriptions/8d65815f-a5b6-402f-9298-045155da7d74. |
| AzureFirewall.Subscription.managedByTenants | Unknown | An array containing the tenants managing the subscription. |
| AzureFirewall.Subscription.state | Unknown | The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. |
| AzureFirewall.Subscription.subscriptionId | String | The subscription ID. |
| AzureFirewall.Subscription.subscriptionPolicies | Unknown | The subscription policies. |
| AzureFirewall.Subscription.tags | Object | The tags attached to the subscription. |
| AzureFirewall.Subscription.tenantId | String | The subscription tenant ID. |
azure-firewall-resource-group-list
List all resource groups for a subscription.
Base Command
azure-firewall-resource-group-list
Input
| Argument Name | Description | Required |
|---|---|---|
| subscription_id | The subscription ID. Note: This argument will override the instance parameter ‘Default Subscription ID’. | Optional |
| limit | Limit on the number of resource groups to return. Default is 50. | Optional |
| tag | A single tag in the form of ‘{“Tag Name”:”Tag Value”}’ to filter the list by. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| AzureFirewall.ResourceGroup.id | String | The ID of the resource group. |
| AzureFirewall.ResourceGroup.location | String | The location of the resource group. |
| AzureFirewall.ResourceGroup.managedBy | String | The ID of the resource that manages this resource group. |
| AzureFirewall.ResourceGroup.name | String | The name of the resource group. |
| AzureFirewall.ResourceGroup.properties.provisioningState | String | The provisioning state. |
| AzureFirewall.ResourceGroup.tags | Object | The tags attached to the resource group. |
| AzureFirewall.ResourceGroup.type | String | The type of the resource group. |
Configuration parameters
resource_group— Default Resource Group Name (required)client_id— Client IDsubscription_id— (required)tenant_id—client_secret—certificate_thumbprint— Certificate Thumbprintprivate_key— Private Keyuse_managed_identities— Use Azure Managed Identitiesmanaged_identities_client_id—proxy— Use system proxy settingsinsecure— Trust any certificate (not secure)
Commands (30)
-
azure-firewall-auth-completeRun this command to complete the authorization process. Should be used after running the azure-firewall-auth-start command.
-
azure-firewall-auth-resetRun this command if for some reason you need to rerun the authentication process.
-
azure-firewall-auth-startRun this command to start the authorization process and follow the instructions in the command results.
-
azure-firewall-auth-testTests the connectivity to Azure.
-
azure-firewall-getRetrieve Azure firewall information.
-
azure-firewall-ip-group-createCreate an IP group.
-
azure-firewall-ip-group-deleteDelete an IP group resource.
-
azure-firewall-ip-group-getRetrieve IP group information.
-
azure-firewall-ip-group-listList IP groups in a resource group or subscription.
-
azure-firewall-ip-group-updateUpdate an IP group. Add or remove IP addresses from the group.
-
azure-firewall-listList Azure firewalls in the specified resource group or subscription.
-
azure-firewall-network-rule-collection-createCreate a network rule collection in a firewall or policy. The command will return firewall or policy rule collection resource information. One of the arguments 'firewall_name' or 'policy' must be provided.
-
azure-firewall-network-rule-collection-deleteDelete a network rule collection from the firewall or policy. One of the arguments 'firewall_name' or 'policy' must be provided.
-
azure-firewall-network-rule-collection-updateUpdate a network rule collection in a firewall or policy. The command will update the provided arguments. One of the arguments 'firewall_name' or 'policy' must be provided. The command will return firewall or policy rule collection resource information.
-
azure-firewall-network-rule-createCreate a network rule in the firewall or policy rule collection. One of the arguments 'firewall_name' or 'policy' must be provided.
-
azure-firewall-network-rule-deleteDelete a network rule from the collection. One of the arguments 'firewall_name' or 'policy' must be provided.
-
azure-firewall-network-rule-updateUpdate the network rule in the firewall. The provided arguments will replace the existing rule configuration. One of the arguments 'firewall_name' or 'policy' must be provided. The command will not replace the rule source or destination types.
-
azure-firewall-policy-attachAttach a policy to a firewall. The policy and firewall have to belong to the same tier.
-
azure-firewall-policy-createCreate a firewall policy. This command only creates the policy resource. In order to attach the policy to a firewall, run the 'azure-firewall-policy-attach' command.
-
azure-firewall-policy-deleteDelete policy resource.
-
azure-firewall-policy-detachRemove a policy from the firewall. This command will detach the policy and firewall, but will not delete the policy.
-
azure-firewall-policy-getRetrieve policy information.
-
azure-firewall-policy-listList the policy in the resource group or subscription.
-
azure-firewall-policy-updateUpdate the policy resource. The command will update the provided arguments.
-
azure-firewall-resource-group-listList all resource groups for a subscription.
-
azure-firewall-rule-collection-listList the collection rules in the firewall or policy. One of the arguments 'firewall_name' or 'policy' must be provided.
-
azure-firewall-rule-getRetrieve rule information. One of the arguments 'firewall_name' or 'policy' must be provided.
-
azure-firewall-rule-listList rules in the firewall or in the policy. One of the arguments 'firewall_name' or 'policy' must be provided.
-
azure-firewall-service-tag-listRetrieve service tags information.
-
azure-firewall-subscriptions-listList all subscriptions for a tenant.
import copy from unittest.mock import Mock import pytest from CommonServerPython import * SUBSCRIPTION_ID = "sub_id" RESOURCE_GROUP_NAME = "group_name" BASE_URL = ( f"https://management.azure.com/subscriptions/{SUBSCRIPTION_ID}" f"/resourceGroups/{RESOURCE_GROUP_NAME}/providers/Microsoft.Network" ) CLIENT_ID = "XXXX" ScheduledCommand.raise_error_if_not_supported = Mock() def load_mock_response(file_path: str) -> str: """ Load mock file that simulates an API response. Args: file_path (str): Path of the mock response JSON file to return. Returns: str: Mock file content. """ with open(file_path, encoding="utf-8") as mock_file: return mock_file.read() def get_azure_access_token_mock() -> dict: """ Mock Azure access token object. Returns: dict: Azure access token mock. """ return { "access_token": "my-access-token", "expires_in": 3595, "refresh_token": "my-refresh-token", } def get_client_mock(): """ Get API Client mock. Returns: AzureFirewallClient: API Client """ from AzureFirewall import AzureFirewallClient return AzureFirewallClient( subscription_id=SUBSCRIPTION_ID, resource_group=RESOURCE_GROUP_NAME, client_id=CLIENT_ID, verify=False, proxy=False ) def authorization_mock(requests_mock): """ Azure authorization API request mock. """ authorization_url = "https://login.microsoftonline.com/organizations/oauth2/v2.0/token" requests_mock.post(authorization_url, json=get_azure_access_token_mock()) def test_azure_firewall_list_command(requests_mock): """ Scenario: List azure firewalls in resource group or subscription. Given: - User has provided valid credentials. When: - azure-firewall-list called. Then: - Ensure 1 result is returned. - Ensure outputs prefix is correct. -Ensure the firewall name expected is the same as in the context returned. """ from AzureFirewall import azure_firewall_list_command authorization_mock(requests_mock) client = get_client_mock() url = f"{BASE_URL}/azureFirewalls" mock_response = json.loads(load_mock_response("test_data/firewall/firewall_list.json")) requests_mock.get(url, json=mock_response) result = azure_firewall_list_command(client, {"resource": "resource_group"}) assert len(result.outputs) == 1 assert result.outputs_prefix == "AzureFirewall.Firewall" assert result.outputs[0].get("name") == "xsoar-firewall" def test_azure_firewall_get_command(requests_mock): """ Scenario: Retrieve azure firewall information. Given: - User has provided valid credentials. When: - azure-firewall-get called. Then: - Ensure 1 result is returned. - Ensure outputs prefix is correct. - Ensure the firewall name searched is the same as in the context returned. """ from AzureFirewall import azure_firewall_get_command authorization_mock(requests_mock) client = get_client_mock() firewall_name = "xsoar-firewall" url = f"{BASE_URL}/azureFirewalls/{firewall_name}" mock_response = json.loads(load_mock_response("test_data/firewall/firewall_get.json")) requests_mock.get(url, json=mock_response) command_arguments = {"firewall_names": firewall_name} result = azure_firewall_get_command(client, command_arguments) assert len(result[0].outputs) == 1 assert result[0].outputs_prefix == "AzureFirewall.Firewall" assert result[0].outputs[0].get("name") == firewall_name def test_azure_firewall_rules_collection_list_command_for_firewall(requests_mock): """ Scenario: List collection rules in firewall. Given: - User has provided valid credentials. When: - azure-firewall-rule-collection-list called. Then: - Ensure 1 result is returned. - Ensure outputs prefix is correct. - Ensure the firewall name updated is the same as in the context returned. """ from AzureFirewall import azure_firewall_rules_collection_list_command authorization_mock(requests_mock) client = get_client_mock() firewall_name = "xsoar-firewall" url = f"{BASE_URL}/azureFirewalls/{firewall_name}" mock_response = json.loads(load_mock_response("test_data/firewall/firewall_get.json")) requests_mock.get(url, json=mock_response) command_arguments = {"firewall_name": firewall_name, "rule_type": "application_rule"} result = azure_firewall_rules_collection_list_command(client, command_arguments) assert len(result.outputs) == 1 assert result.outputs_key_field == "id" assert result.outputs_prefix == "AzureFirewall.RuleCollection" assert result.outputs[0].get("name") == "my-app-collection" assert dict_safe_get(result.outputs[0], ["properties", "rules"])[0].get("name") == "my-app-rule-1" def test_azure_firewall_rules_collection_list_command_for_policy(requests_mock): """ Scenario: List collection rules in policy. Given: - User has provided valid credentials. When: - azure-firewall-rule-collection-list called. Then: - Ensure 1 result is returned. - Ensure outputs prefix is correct. - Ensure the rule collection name searched is the same as in the context returned. - Ensure the rule collection key (type) searched is the same as in the context returned. - Ensure the rule type (type) searched is the same as in the context returned. """ from AzureFirewall import azure_firewall_rules_collection_list_command, get_policy_rule_collection_name, get_policy_rule_name authorization_mock(requests_mock) client = get_client_mock() policy_name = "xsoar-firewall" url = f"{BASE_URL}/firewallPolicies/{policy_name}/ruleCollectionGroups" mock_response = json.loads(load_mock_response("test_data/policy/policy_rule_collection_list.json")) requests_mock.get(url, json=mock_response) rule_type = "application_rule" command_arguments = {"policy": policy_name, "rule_type": rule_type} result = azure_firewall_rules_collection_list_command(client, command_arguments) collection_key = get_policy_rule_collection_name(rule_type=rule_type) rule_key = get_policy_rule_name(rule_type=rule_type) assert len(result.outputs) == 1 assert result.outputs_key_field == "id" assert result.outputs_prefix == "AzureFirewall.RuleCollection" assert result.outputs[0].get("name") == "DefaultApplicationRuleCollectionGroup" assert dict_safe_get(result.outputs[0], ["properties", "ruleCollections"])[0].get("rules")[0].get("ruleType") == rule_key assert dict_safe_get(result.outputs[0], ["properties", "ruleCollections"])[0].get("ruleCollectionType") == collection_key def test_azure_firewall_rules_list_command_for_policy(requests_mock): """ Scenario: List rules in policy. Given: - User has provided valid credentials. When: - azure-firewall-rule-list called. Then: - Ensure 1 result is returned. - Ensure outputs prefix is correct. - Ensure the rule name searched is the same as in the context returned. """ from AzureFirewall import azure_firewall_rules_list_command authorization_mock(requests_mock) client = get_client_mock() policy_name = "xsoar-firewall" collection_name = "DefaultApplicationRuleCollectionGroup" url = f"{BASE_URL}/firewallPolicies/{policy_name}/ruleCollectionGroups/{collection_name}" mock_response = json.loads(load_mock_response("test_data/policy/policy_rule_list.json")) requests_mock.get(url, json=mock_response) command_arguments = {"policy": policy_name, "collection_name": collection_name} result = azure_firewall_rules_list_command(client, command_arguments) assert len(result.outputs) == 1 assert result.outputs_key_field == "name" assert result.outputs_prefix == "AzureFirewall.Rule" assert result.outputs[0].get("name") == "my-app-rule-1" def test_azure_firewall_rules_list_command_for_firewall(requests_mock): """ Scenario: List rules in firewall. Given: - User has provided valid credentials. When: - azure-firewall-rule-list called. Then: - Ensure 1 result is returned. - Ensure outputs prefix is correct. - Ensure the rule name searched is the same as in the context returned. """ from AzureFirewall import azure_firewall_rules_list_command authorization_mock(requests_mock) client = get_client_mock() firewall_name = "xsoar-firewall" collection_name = "my-app-collection" url = f"{BASE_URL}/azureFirewalls/{firewall_name}" mock_response = json.loads(load_mock_response("test_data/firewall/firewall_get.json")) requests_mock.get(url, json=mock_response) command_arguments = {"firewall_name": firewall_name, "collection_name": collection_name, "rule_type": "application_rule"} result = azure_firewall_rules_list_command(client, command_arguments) assert len(result.outputs) == 1 assert result.outputs_key_field == "name" assert result.outputs_prefix == "AzureFirewall.Rule" assert result.outputs[0].get("name") == "my-app-rule-1" def test_azure_firewall_rules_get_command_for_firewall(requests_mock): """ Scenario: Retrieve rule information in firewall. Given: - User has provided valid credentials. When: - azure-firewall-rule-get called. Then: - Ensure outputs prefix is correct. - Ensure the rule name searched is the same as in the context returned. """ from AzureFirewall import azure_firewall_rule_get_command authorization_mock(requests_mock) client = get_client_mock() firewall_name = "xsoar-firewall" collection_name = "my-app-collection" rule_name = "my-app-rule-1" url = f"{BASE_URL}/azureFirewalls/{firewall_name}" mock_response = json.loads(load_mock_response("test_data/firewall/firewall_get.json")) requests_mock.get(url, json=mock_response) command_arguments = { "firewall_name": firewall_name, "collection_name": collection_name, "rule_type": "application_rule", "rule_name": rule_name, } result = azure_firewall_rule_get_command(client, command_arguments) assert result.outputs_key_field == "name" assert result.outputs_prefix == "AzureFirewall.Rule" assert result.outputs.get("name") == rule_name def test_azure_firewall_rule_get_command_for_policy(requests_mock): """ Scenario: Retrieve rule information in policy. Given: - User has provided valid credentials. When: - azure-firewall-rule-get called. Then: - Ensure outputs prefix is correct. - Ensure the rule name searched is the same as in the context returned. """ from AzureFirewall import azure_firewall_rule_get_command authorization_mock(requests_mock) client = get_client_mock() policy_name = "xsoar-firewall" collection_name = "DefaultApplicationRuleCollectionGroup" rule_name = "my-app-rule-1" url = f"{BASE_URL}/firewallPolicies/{policy_name}/ruleCollectionGroups/{collection_name}" mock_response = json.loads(load_mock_response("test_data/policy/policy_rule_list.json")) requests_mock.get(url, json=mock_response) command_arguments = {"policy": policy_name, "collection_name": collection_name, "rule_name": rule_name} result = azure_firewall_rule_get_command(client, command_arguments) assert result.outputs_key_field == "name" assert result.outputs_prefix == "AzureFirewall.Rule" assert result.outputs.get("name") == "my-app-rule-1" def test_azure_firewall_policy_create_command(requests_mock): """ Scenario: Create firewall policy. Given: - User has provided valid credentials. When: - azure-firewall-policy-create called. Then: - Ensure 1 result is returned. - Ensure outputs prefix is correct. - Ensure the policy name searched is the same as in the context returned. """ from AzureFirewall import azure_firewall_policy_create_command authorization_mock(requests_mock) client = get_client_mock() policy_name = "xsoar-policy" url = f"{BASE_URL}/firewallPolicies/{policy_name}" mock_response = json.loads(load_mock_response("test_data/policy/policy_create.json")) requests_mock.put(url, json=mock_response) command_arguments = { "policy_name": policy_name, "threat_intelligence_mode": "Turned-off", "location": "eastus", "tier": "Standard", "enable_proxy": "False", } result = azure_firewall_policy_create_command(client, command_arguments) assert len(result.outputs) == 1 assert result.outputs_prefix == "AzureFirewall.Policy" assert result.outputs[0].get("name") == policy_name def test_azure_firewall_policy_update_command(requests_mock): """ Scenario: Update firewall policy. Given: - User has provided valid credentials. When: - azure-firewall-policy-update called. Then: - Ensure 1 result is returned. - Ensure outputs prefix is correct. - Ensure the policy name searched is the same as in the context returned. """ from AzureFirewall import azure_firewall_policy_update_command authorization_mock(requests_mock) client = get_client_mock() policy_name = "xsoar-policy" url = f"{BASE_URL}/firewallPolicies/{policy_name}" mock_response = json.loads(load_mock_response("test_data/policy/policy_get.json")) requests_mock.get(url, json=mock_response) mock_response = json.loads(load_mock_response("test_data/policy/policy_update.json")) requests_mock.put(url, json=mock_response) command_arguments = { "base_policy_id": "/firewallPolicies/my-policy", "domains": "microsoft.com", "enable_proxy": "True", "ips": "189.160.40.11", "policy_name": policy_name, "threat_intelligence_mode": "Alert", } result = azure_firewall_policy_update_command(client, command_arguments) assert len(result.outputs) == 1 assert result.outputs_prefix == "AzureFirewall.Policy" assert result.outputs[0].get("name") == policy_name def test_azure_firewall_policy_list_command(requests_mock): """ Scenario: List policy in resource group or subscription. Given: - User has provided valid credentials. When: - azure-firewall-policy-list called. Then: - Ensure 1 result is returned. - Ensure outputs prefix is correct. - Ensure the policy name searched is the same as in the context returned. """ from AzureFirewall import azure_firewall_policy_list_command authorization_mock(requests_mock) client = get_client_mock() url = f"{BASE_URL}/firewallPolicies" mock_response = json.loads(load_mock_response("test_data/policy/policy_list.json")) requests_mock.get(url, json=mock_response) result = azure_firewall_policy_list_command(client, {}) assert len(result.outputs) == 1 assert result.outputs_prefix == "AzureFirewall.Policy" assert result.outputs[0].get("name") == "xsoar-policy" def test_azure_firewall_policy_get_command(requests_mock): """ Scenario: Retrieve policy information. Given: - User has provided valid credentials. When: - azure-firewall-policy-get called. Then: - Ensure 1 result is returned. - Ensure outputs prefix is correct. - Ensure the policy name searched is the same as in the context returned. """ from AzureFirewall import azure_firewall_policy_get_command authorization_mock(requests_mock) client = get_client_mock() policy_name = "xsoar-policy" url = f"{BASE_URL}/firewallPolicies/{policy_name}" mock_response = json.loads(load_mock_response("test_data/policy/policy_get.json")) requests_mock.get(url, json=mock_response) command_arguments = {"policy_names": policy_name} result = azure_firewall_policy_get_command(client, command_arguments) assert len(result) == 1 assert len(result[0].outputs) == 1 assert result[0].outputs_prefix == "AzureFirewall.Policy" assert result[0].outputs[0].get("name") == policy_name def test_azure_firewall_policy_delete_command(requests_mock): """ Scenario: Delete policy resource. Given: - User has provided valid credentials. When: - azure-firewall-policy-delete called. Then: - Ensure that the output is empty (None). - Ensure readable output message content. """ from AzureFirewall import azure_firewall_policy_delete_command authorization_mock(requests_mock) client = get_client_mock() policy_name = "xsoar-policy" url = f"{BASE_URL}/firewallPolicies/{policy_name}" requests_mock.delete(url, status_code=202) command_arguments = {"policy_names": policy_name} result = azure_firewall_policy_delete_command(client, command_arguments) assert len(result) == 1 assert result[0].outputs is None assert result[0].outputs_prefix is None assert result[0].readable_output == f"Policy {policy_name} delete operation accepted and will complete asynchronously." def test_azure_firewall_policy_attach_command(requests_mock): """ Scenario: Attach policy to firewall. Given: - User has provided valid credentials. When: - azure-firewall-policy-attach called. Then: - Ensure 1 result is returned. - Ensure outputs prefix is correct. - Ensure the firewall name updated is the same as in the context returned. """ from AzureFirewall import azure_firewall_policy_attach_command authorization_mock(requests_mock) client = get_client_mock() firewall_name = "xsoar-firewall" url = f"{BASE_URL}/azureFirewalls/{firewall_name}" mock_response = json.loads(load_mock_response("test_data/firewall/firewall_get.json")) requests_mock.get(url, json=mock_response) mock_response = json.loads(load_mock_response("test_data/firewall/firewall_subnet_public_ip_attach.json")) requests_mock.put(url, json=mock_response) command_arguments = {"firewall_names": firewall_name, "policy_id": "/firewallPolicies/xsoar-platform-policy"} result = azure_firewall_policy_attach_command(client, command_arguments) assert len(result) == 1 assert len(result[0].outputs) == 1 assert result[0].outputs_prefix == "AzureFirewall.Firewall" assert result[0].outputs[0].get("name") == firewall_name def test_azure_firewall_policy_remove_command(requests_mock): """ Scenario: Remove policy from firewall. Given: - User has provided valid credentials. When: - azure-firewall-policy-remove called. Then: - Ensure 1 result is returned. - Ensure outputs prefix is correct. - Ensure the firewall name updated is the same as in the context returned. """ from AzureFirewall import azure_firewall_policy_remove_command authorization_mock(requests_mock) client = get_client_mock() firewall_name = "xsoar-firewall" url = f"{BASE_URL}/azureFirewalls/{firewall_name}" mock_response = json.loads(load_mock_response("test_data/firewall/firewall_get.json")) requests_mock.get(url, json=mock_response) mock_response = json.loads(load_mock_response("test_data/firewall/firewall_subnet_public_ip_remove.json")) requests_mock.put(url, json=mock_response) command_arguments = {"firewall_names": firewall_name} result = azure_firewall_policy_remove_command(client, command_arguments) assert len(result) == 1 assert len(result[0].outputs) == 1 assert result[0].outputs_prefix == "AzureFirewall.Firewall" assert result[0].outputs[0].get("name") == firewall_name def test_azure_firewall_ip_group_create_command(requests_mock): """ Scenario: Create IP group resource. Given: - User has provided valid credentials. When: - azure-firewall-ip-group-create called. Then: - Ensure 1 result is returned. - Ensure outputs prefix is correct. - Ensure the ip-group name created is the same as in the context returned. """ from AzureFirewall import azure_firewall_ip_group_create_command authorization_mock(requests_mock) client = get_client_mock() ip_group_name = "xsoar-ip-group" url = f"{BASE_URL}/ipGroups/{ip_group_name}" mock_response = json.loads(load_mock_response("test_data/ip_group/ip_group_create.json")) requests_mock.put(url, json=mock_response) command_arguments = {"ip_group_name": ip_group_name, "location": "eastus", "ips": "189.160.40.11,189.160.40.11"} result = azure_firewall_ip_group_create_command(client, command_arguments) assert len(result.outputs) == 1 assert result.outputs_prefix == "AzureFirewall.IPGroup" assert result.outputs[0].get("name") == ip_group_name def test_azure_firewall_ip_group_update_command(requests_mock): """ Scenario: Update IP group. Add or remove IPs from the group. Given: - User has provided valid credentials. When: - azure-firewall-ip-group-update called. Then: - Ensure 1 result is returned. - Ensure outputs prefix is correct. - Ensure the ip-group name updated is the same as in the context returned. """ from AzureFirewall import azure_firewall_ip_group_update_command authorization_mock(requests_mock) client = get_client_mock() ip_group_name = "xsoar-ip-group" url = f"{BASE_URL}/ipGroups/{ip_group_name}" mock_response = json.loads(load_mock_response("test_data/ip_group/ip_group_get.json")) requests_mock.get(url, json=mock_response) mock_response = json.loads(load_mock_response("test_data/ip_group/ip_group_update.json")) requests_mock.put(url, json=mock_response) ips_to_add = "189.160.40.11,189.160.40.11" ips_to_remove = "189.160.40.11" command_arguments = {"ip_group_name": ip_group_name, "ips_to_add": ips_to_add, "ips_to_remove": ips_to_remove} result = azure_firewall_ip_group_update_command(client, command_arguments) assert len(result.outputs) == 1 assert result.outputs_prefix == "AzureFirewall.IPGroup" assert result.outputs[0].get("name") == ip_group_name def test_azure_firewall_ip_group_list_command(requests_mock): """ Scenario: List IP groups in resource group or subscription. Given: - User has provided valid credentials. When: - azure-firewall-ip-group-list called. Then: - Ensure 1 result is returned. - Ensure outputs prefix is correct. - Ensure the ip-group name searched is the same as in the context returned. """ from AzureFirewall import azure_firewall_ip_group_list_command authorization_mock(requests_mock) client = get_client_mock() ip_group_name = "xsoar-ip-group" url = f"{BASE_URL}/ipGroups" mock_response = json.loads(load_mock_response("test_data/ip_group/ip_group_list.json")) requests_mock.get(url, json=mock_response) command_arguments = {"resource": "resource_group"} result = azure_firewall_ip_group_list_command(client, command_arguments) assert len(result.outputs) == 1 assert result.outputs_prefix == "AzureFirewall.IPGroup" assert result.outputs[0].get("name") == ip_group_name def test_azure_firewall_ip_group_get_command(requests_mock): """ Scenario: List IP groups in resource group or subscription. Given: - User has provided valid credentials. When: - azure-firewall-ip-group-get called. Then: - Ensure 1 result is returned. - Ensure outputs prefix is correct. - Ensure the ip-group name searched is the same as in the context returned. """ from AzureFirewall import azure_firewall_ip_group_get_command authorization_mock(requests_mock) client = get_client_mock() ip_group_name = "xsoar-ip-group" url = f"{BASE_URL}/ipGroups/{ip_group_name}" mock_response = json.loads(load_mock_response("test_data/ip_group/ip_group_get.json")) requests_mock.get(url, json=mock_response) command_arguments = {"ip_group_names": ip_group_name} result = azure_firewall_ip_group_get_command(client, command_arguments) assert len(result) == 1 assert len(result[0].outputs) == 1 assert result[0].outputs_prefix == "AzureFirewall.IPGroup" assert result[0].outputs[0].get("name") == ip_group_name def test_azure_firewall_ip_group_delete_command(requests_mock): """ Scenario: Delete IP group resource. Given: - User has provided valid credentials. When: - azure-firewall-policy-delete called. Then: - Ensure that the output is empty (None). - Ensure readable output message content. """ from AzureFirewall import azure_firewall_ip_group_delete_command authorization_mock(requests_mock) client = get_client_mock() ip_group_name = "xsoar-ip-group" url = f"{BASE_URL}/ipGroups/{ip_group_name}" requests_mock.delete(url, status_code=202) command_arguments = {"ip_group_names": ip_group_name} result = azure_firewall_ip_group_delete_command(client, command_arguments) assert len(result) == 1 assert result[0].outputs is None assert result[0].outputs_prefix is None assert result[0].readable_output == f"IP Group {ip_group_name} delete operation accepted and will complete asynchronously." def test_azure_firewall_network_rule_collection_create_command_for_firewall(requests_mock): """ Scenario: Create network rule collection in firewall. Given: - User has provided valid credentials. When: - azure-firewall-network-rule-collection-create called. Then: - Ensure outputs prefix is correct. - Ensure the firewall name updated is the same as in the context returned. """ from AzureFirewall import azure_firewall_network_rule_collection_create_command authorization_mock(requests_mock) client = get_client_mock() firewall_name = "xsoar-firewall" url = f"{BASE_URL}/azureFirewalls/{firewall_name}" mock_response = json.loads(load_mock_response("test_data/network_rule/firewall_network_rule_collection_create.json")) requests_mock.put(url, json=mock_response) mock_response = json.loads(load_mock_response("test_data/firewall/firewall_get.json")) requests_mock.get(url, json=mock_response) command_arguments = { "action": "Allow", "collection_name": "my-collection", "collection_priority": "105", "description": "my-poc-collection", "destination_ports": "8080", "destination_type": "ip_address", "destinations": "189.160.40.11,189.160.40.11", "firewall_name": firewall_name, "protocols": "UDP,TCP", "rule_name": "my-ip-rule", "source_ips": "189.160.40.11,189.160.40.11", "source_type": "ip_address", } result = azure_firewall_network_rule_collection_create_command(client, command_arguments) assert result.outputs_prefix == "AzureFirewall.Firewall" assert result.outputs[0].get("name") == firewall_name def test_azure_firewall_network_rule_collection_create_command_for_policy(requests_mock): """ Scenario: Create network rule collection in policy. Given: - User has provided valid credentials. When: - azure-firewall-network-rule-collection-create called. Then: - Ensure outputs prefix is correct. - Ensure the policy name updated is the same as in the context returned. """ from AzureFirewall import azure_firewall_network_rule_collection_create_command authorization_mock(requests_mock) client = get_client_mock() policy_name = "xsoar-policy" collection_name = "xsoar-collection" url = f"{BASE_URL}/firewallPolicies/{policy_name}/ruleCollectionGroups/{collection_name}" mock_response = json.loads(load_mock_response("test_data/network_rule/policy_network_rule_collection_create.json")) requests_mock.put(url, json=mock_response) requests_mock.get(url, status_code=404) url = f"{BASE_URL}/firewallPolicies/{policy_name}" mock_response = json.loads(load_mock_response("test_data/policy/policy_get.json")) requests_mock.get(url, json=mock_response) command_arguments = { "action": "Allow", "collection_name": collection_name, "collection_priority": "109", "description": "my-poc-collection", "destination_ports": "8080", "destination_type": "ip_address", "destinations": "189.160.40.11,189.160.40.11", "policy": policy_name, "protocols": "UDP,TCP", "rule_name": "my-ip-rule", "source_ips": "189.160.40.11,189.160.40.11", "source_type": "ip_address", } result = azure_firewall_network_rule_collection_create_command(client, command_arguments) assert result.outputs_prefix == "AzureFirewall.Policy" assert result.outputs[0].get("name") == policy_name def test_azure_firewall_network_rule_collection_create_command_invalid_arguments(requests_mock): """ Scenario: Create network rule collection in firewall. The user provided invalid or missing arguments. Given: - User has provided valid credentials. When: - azure-firewall-network-rule-collection-create called. Then: - Ensure that exception is raised. """ from AzureFirewall import azure_firewall_network_rule_collection_create_command authorization_mock(requests_mock) client = get_client_mock() firewall_name = "xsoar-firewall" command_arguments = { "action": "Allow", "collection_priority": "105", "description": "my-poc-collection", "destination_ports": "8080", "destination_type": "ip_address", "firewall_name": firewall_name, "protocols": "UDP,TCP", "source_ips": "189.160.40.11,189.160.40.11", "source_type": "ip_address", } with pytest.raises(Exception): invalid_arguments = copy.deepcopy(command_arguments) invalid_arguments["protocols"] = "test" azure_firewall_network_rule_collection_create_command(client, invalid_arguments) with pytest.raises(Exception): invalid_arguments = copy.deepcopy(command_arguments) invalid_arguments["source_type"] = "test" azure_firewall_network_rule_collection_create_command(client, invalid_arguments) with pytest.raises(Exception): invalid_arguments = copy.deepcopy(command_arguments) invalid_arguments["destination_type"] = "test" azure_firewall_network_rule_collection_create_command(client, invalid_arguments) with pytest.raises(Exception): invalid_arguments = copy.deepcopy(command_arguments) invalid_arguments["source_type"] = "ip_address" del invalid_arguments["source_ips"] azure_firewall_network_rule_collection_create_command(client, invalid_arguments) with pytest.raises(Exception): invalid_arguments = copy.deepcopy(command_arguments) invalid_arguments["source_type"] = "ip_group" del invalid_arguments["source_ips"] azure_firewall_network_rule_collection_create_command(client, invalid_arguments) def test_azure_firewall_network_rule_create_command_for_firewall(requests_mock): """ Scenario: Create network rule in firewall rule collection. Given: - User has provided valid credentials. When: - azure-firewall-network-rule-create called. Then: - Ensure outputs prefix is correct. - Ensure the firewall name updated is the same as in the context returned. """ from AzureFirewall import azure_firewall_network_rule_create_command authorization_mock(requests_mock) client = get_client_mock() firewall_name = "xsoar-firewall" url = f"{BASE_URL}/azureFirewalls/{firewall_name}" mock_response = json.loads(load_mock_response("test_data/network_rule/firewall_network_rule_collection_create.json")) requests_mock.put(url, json=mock_response) mock_response = json.loads(load_mock_response("test_data/firewall/firewall_get.json")) requests_mock.get(url, json=mock_response) command_arguments = { "collection_name": "my-network-rule-collection", "description": "my-poc-collection", "destination_ports": "8080", "destination_type": "ip_address", "destinations": "189.160.40.11,189.160.40.11", "firewall_name": firewall_name, "protocols": "UDP,TCP", "rule_name": "my-ip-rule", "source_ips": "189.160.40.11,189.160.40.11", "source_type": "ip_address", } result = azure_firewall_network_rule_create_command(client, command_arguments) assert result.outputs_prefix == "AzureFirewall.Firewall" assert result.outputs[0].get("name") == firewall_name def test_azure_firewall_network_rule_create_command_for_policy(requests_mock): """ Scenario: Create network rule in policy rule collection. Given: - User has provided valid credentials. When: - azure-firewall-network-rule-create called. Then: - Ensure outputs prefix is correct. - Ensure the policy name updated is the same as in the context returned. """ from AzureFirewall import azure_firewall_network_rule_create_command authorization_mock(requests_mock) client = get_client_mock() policy_name = "xsoar-policy" collection_name = "xsoar-collection" url = f"{BASE_URL}/firewallPolicies/{policy_name}/ruleCollectionGroups/{collection_name}" mock_response = json.loads(load_mock_response("test_data/network_rule/policy_network_rule_collection_create.json")) requests_mock.put(url, json=mock_response) mock_response = json.loads(load_mock_response("test_data/policy/policy_rule_collection_get.json")) requests_mock.get(url, json=mock_response) url = f"{BASE_URL}/firewallPolicies/{policy_name}" mock_response = json.loads(load_mock_response("test_data/policy/policy_get.json")) requests_mock.get(url, json=mock_response) command_arguments = { "collection_name": collection_name, "description": "my-poc-collection", "destination_ports": "8080", "destination_type": "ip_address", "destinations": "189.160.40.11,189.160.40.11", "policy": policy_name, "protocols": "UDP,TCP", "rule_name": "my-rule", "source_ips": "189.160.40.11,189.160.40.11", "source_type": "ip_address", } result = azure_firewall_network_rule_create_command(client, command_arguments) assert result.outputs_prefix == "AzureFirewall.Policy" assert result.outputs[0].get("name") == policy_name def test_azure_firewall_network_rule_collection_update_command_for_firewall(requests_mock): """ Scenario: Update network rule collection in firewall. Given: - User has provided valid credentials. When: - azure-firewall-network-rule-collection-update called. Then: - Ensure outputs prefix is correct. - Ensure the firewall name updated is the same as in the context returned. """ from AzureFirewall import azure_firewall_network_rule_collection_update_command authorization_mock(requests_mock) client = get_client_mock() firewall_name = "xsoar-firewall" url = f"{BASE_URL}/azureFirewalls/{firewall_name}" mock_response = json.loads(load_mock_response("test_data/network_rule/firewall_network_rule_collection_create.json")) requests_mock.put(url, json=mock_response) mock_response = json.loads(load_mock_response("test_data/firewall/firewall_get.json")) requests_mock.get(url, json=mock_response) command_arguments = { "action": "Deny", "collection_name": "my-network-rule-collection", "firewall_name": firewall_name, "priority": "201", } result = azure_firewall_network_rule_collection_update_command(client, command_arguments) assert result.outputs_prefix == "AzureFirewall.Firewall" assert result.outputs[0].get("name") == firewall_name def test_azure_firewall_network_rule_collection_update_command_for_policy(requests_mock): """ Scenario: Update network rule collection in policy. Given: - User has provided valid credentials. When: - azure-firewall-network-rule-collection-update called. Then: - Ensure outputs prefix is correct. - Ensure the policy name updated is the same as in the context returned. """ from AzureFirewall import azure_firewall_network_rule_collection_update_command authorization_mock(requests_mock) client = get_client_mock() policy_name = "xsoar-policy" collection_name = "xsoar-collection" url = f"{BASE_URL}/firewallPolicies/{policy_name}/ruleCollectionGroups/{collection_name}" mock_response = json.loads(load_mock_response("test_data/network_rule/policy_network_rule_collection_create.json")) requests_mock.put(url, json=mock_response) mock_response = json.loads(load_mock_response("test_data/policy/policy_rule_collection_get.json")) requests_mock.get(url, json=mock_response) url = f"{BASE_URL}/firewallPolicies/{policy_name}" mock_response = json.loads(load_mock_response("test_data/policy/policy_get.json")) requests_mock.get(url, json=mock_response) command_arguments = {"action": "Deny", "collection_name": collection_name, "policy": policy_name, "priority": "201"} result = azure_firewall_network_rule_collection_update_command(client, command_arguments) assert result.outputs_prefix == "AzureFirewall.Policy" assert result.outputs[0].get("name") == policy_name def test_azure_firewall_network_rule_collection_delete_command_for_firewall(requests_mock): """ Scenario: Delete network rule collection from firewall. Given: - User has provided valid credentials. When: - azure-firewall-network-rule-collection-delete called. Then: - Ensure outputs prefix is correct. - Ensure the firewall name updated is the same as in the context returned. """ from AzureFirewall import azure_firewall_network_rule_collection_delete_command authorization_mock(requests_mock) client = get_client_mock() firewall_name = "xsoar-firewall" collection_name = "my-network-rule-collection" url = f"{BASE_URL}/azureFirewalls/{firewall_name}" mock_response = json.loads(load_mock_response("test_data/firewall/firewall_update.json")) requests_mock.put(url, json=mock_response) mock_response = json.loads(load_mock_response("test_data/firewall/firewall_get.json")) requests_mock.get(url, json=mock_response) command_arguments = {"collection_name": collection_name, "firewall_name": firewall_name} result = azure_firewall_network_rule_collection_delete_command(client, command_arguments) assert result.outputs_prefix == "AzureFirewall.Firewall" assert result.outputs[0].get("name") == firewall_name def test_azure_firewall_network_rule_collection_delete_command_for_policy(requests_mock): """ Scenario: Delete network rule collection from policy. Given: - User has provided valid credentials. When: - azure-firewall-network-rule-collection-delete called. Then: - Ensure outputs prefix is correct. - Ensure the policy name updated is the same as in the context returned. """ from AzureFirewall import azure_firewall_network_rule_collection_delete_command authorization_mock(requests_mock) client = get_client_mock() policy_name = "xsoar-policy" collection_name = "xsoar-collection" url = f"{BASE_URL}/firewallPolicies/{policy_name}/ruleCollectionGroups/{collection_name}" requests_mock.delete(url, status_code=200) url = f"{BASE_URL}/firewallPolicies/{policy_name}" mock_response = json.loads(load_mock_response("test_data/policy/policy_get.json")) requests_mock.get(url, json=mock_response) command_arguments = {"action": "Deny", "collection_name": collection_name, "policy": policy_name, "priority": "201"} result = azure_firewall_network_rule_collection_delete_command(client, command_arguments) assert result.outputs_prefix == "AzureFirewall.Policy" assert result.outputs[0].get("name") == policy_name def test_azure_firewall_network_rule_remove_command_for_firewall(requests_mock): """ Scenario: Remove network rule from rules collection in firewall. Given: - User has provided valid credentials. When: - azure-firewall-network-rule-delete called. Then: - Ensure outputs prefix is correct. - Ensure the firewall name updated is the same as in the context returned. - Ensure that the output is empty (None) for non-exists rules. """ from AzureFirewall import azure_firewall_network_rule_remove_command authorization_mock(requests_mock) client = get_client_mock() firewall_name = "xsoar-firewall" collection_name = "my-network-rule-collection" url = f"{BASE_URL}/azureFirewalls/{firewall_name}" mock_response = json.loads(load_mock_response("test_data/firewall/firewall_update.json")) requests_mock.put(url, json=mock_response) mock_response = json.loads(load_mock_response("test_data/firewall/firewall_get.json")) requests_mock.get(url, json=mock_response) command_arguments = { "collection_name": collection_name, "firewall_name": firewall_name, "rule_names": "my-network-rule,not-exists-rule", } result = azure_firewall_network_rule_remove_command(client, command_arguments) assert result[0].outputs is None assert result[0].outputs_prefix is None assert result[0].readable_output == "Rule not-exists-rule is not exists." assert result[1].outputs[0].get("name") == firewall_name assert result[1].outputs_prefix == "AzureFirewall.Firewall" def test_azure_firewall_network_rule_remove_command_for_policy(requests_mock): """ Scenario: Remove network rule from rules collection in policy. Given: - User has provided valid credentials. When: - azure-firewall-network-rule-delete called. Then: - Ensure outputs prefix is correct. - Ensure the policy name updated is the same as in the context returned. - Ensure that the output is empty (None) for non-exists rules. """ from AzureFirewall import azure_firewall_network_rule_remove_command authorization_mock(requests_mock) client = get_client_mock() policy_name = "xsoar-policy" collection_name = "xsoar-collection" url = f"{BASE_URL}/firewallPolicies/{policy_name}/ruleCollectionGroups/{collection_name}" mock_response = json.loads(load_mock_response("test_data/network_rule/policy_network_rule_collection_create.json")) requests_mock.put(url, json=mock_response) mock_response = json.loads(load_mock_response("test_data/policy/policy_rule_collection_get.json")) requests_mock.get(url, json=mock_response) url = f"{BASE_URL}/firewallPolicies/{policy_name}" mock_response = json.loads(load_mock_response("test_data/policy/policy_get.json")) requests_mock.get(url, json=mock_response) command_arguments = {"collection_name": collection_name, "policy": policy_name, "rule_names": "my-ip-rule,not-exists-rule"} result = azure_firewall_network_rule_remove_command(client, command_arguments) assert result[0].outputs is None assert result[0].outputs_prefix is None assert result[0].readable_output == "Rule not-exists-rule is not exists." assert result[1].outputs[0].get("name") == policy_name assert result[1].outputs_prefix == "AzureFirewall.Policy" def test_azure_firewall_network_rule_update_command_policy(requests_mock): """ Scenario: Update network rule in policy rule collection. Given: - User has provided valid credentials. When: - azure-firewall-network-rule-update called. Then: - Ensure outputs prefix is correct. - Ensure the policy name updated is the same as in the context returned. """ from AzureFirewall import azure_firewall_network_rule_update_command authorization_mock(requests_mock) client = get_client_mock() policy_name = "xsoar-policy" collection_name = "xsoar-collection" url = f"{BASE_URL}/firewallPolicies/{policy_name}/ruleCollectionGroups/{collection_name}" mock_response = json.loads(load_mock_response("test_data/network_rule/policy_network_rule_collection_create.json")) requests_mock.put(url, json=mock_response) mock_response = json.loads(load_mock_response("test_data/policy/policy_rule_collection_get.json")) requests_mock.get(url, json=mock_response) url = f"{BASE_URL}/firewallPolicies/{policy_name}" mock_response = json.loads(load_mock_response("test_data/policy/policy_get.json")) requests_mock.get(url, json=mock_response) command_arguments = { "collection_name": collection_name, "description": "new-description", "destination_ports": "8085", "destination_type": "ip_address", "destinations": "189.160.40.11", "new_rule_name": "new-name", "policy": policy_name, "protocols": "UDP", "rule_name": "my-ip-rule", "source_ips": "189.160.40.11", "source_type": "ip_address", } result = azure_firewall_network_rule_update_command(client, command_arguments) assert result.outputs_prefix == "AzureFirewall.Policy" assert result.outputs[0].get("name") == policy_name def test_azure_firewall_network_rule_update_command_for_firewall(requests_mock): """ Scenario: Update network rule in firewall rule collection. Given: - User has provided valid credentials. When: - azure-firewall-network-rule-update called. Then: - Ensure outputs prefix is correct. - Ensure the firewall name updated is the same as in the context returned. """ from AzureFirewall import azure_firewall_network_rule_update_command authorization_mock(requests_mock) client = get_client_mock() firewall_name = "xsoar-firewall" collection_name = "my-network-rule-collection" url = f"{BASE_URL}/azureFirewalls/{firewall_name}" mock_response = json.loads(load_mock_response("test_data/firewall/firewall_update.json")) requests_mock.put(url, json=mock_response) mock_response = json.loads(load_mock_response("test_data/firewall/firewall_get.json")) requests_mock.get(url, json=mock_response) command_arguments = { "collection_name": collection_name, "description": "new-description", "destination_ports": "8085", "firewall_name": firewall_name, "destination_type": "ip_address", "destinations": "189.160.40.11", "new_rule_name": "new-name", "protocols": "UDP", "rule_name": "my-network-rule", "source_ips": "189.160.40.11", "source_type": "ip_address", } result = azure_firewall_network_rule_update_command(client, command_arguments) assert result.outputs_prefix == "AzureFirewall.Firewall" assert result.outputs[0].get("name") == firewall_name def test_azure_firewall_service_tag_list_command(requests_mock): """ Scenario: Retrieve service tags information. Given: - User has provided valid credentials. When: - azure-service-tag-list called. Then: - Ensure 1 result is returned. - Ensure outputs prefix is correct. - Ensure the service tag name searched is the same as in the context returned. """ from AzureFirewall import azure_firewall_service_tag_list_command authorization_mock(requests_mock) client = get_client_mock() location = "eastus" url = ( f"https://management.azure.com/subscriptions/{SUBSCRIPTION_ID}/providers" f"/Microsoft.Network/locations/{location}/serviceTagDetails" ) mock_response = json.loads(load_mock_response("test_data/network_rule/service_tag_list.json")) requests_mock.get(url, json=mock_response) result = azure_firewall_service_tag_list_command(client, {"location": location, "limit": 1}) assert len(result.outputs) == 1 assert result.outputs_prefix == "AzureFirewall.ServiceTag" assert result.outputs[0].get("name") == "ActionGroup" @pytest.mark.parametrize(argnames="client_id", argvalues=["test_client_id", None]) def test_test_module_command_with_managed_identities(mocker, requests_mock, client_id): """ Given: - User has provided managed identities client oid. When: - test-module called. Then: - Ensure the out[ut are as expected """ import AzureFirewall from AzureFirewall import MANAGED_IDENTITIES_TOKEN_URL, Resources, main mock_token = {"access_token": "test_token", "expires_in": "86400"} get_mock = requests_mock.get(MANAGED_IDENTITIES_TOKEN_URL, json=mock_token) params = { "managed_identities_client_id": {"password": client_id}, "use_managed_identities": "True", "subscription_id": {"password": "test"}, "resource_group": "test_resource_group", } mocker.patch.object(demisto, "params", return_value=params) mocker.patch.object(demisto, "command", return_value="test-module") mocker.patch.object(AzureFirewall, "return_results") mocker.patch("MicrosoftApiModule.get_integration_context", return_value={}) main() assert "ok" in AzureFirewall.return_results.call_args[0][0] qs = get_mock.last_request.qs assert qs["resource"] == [Resources.management_azure] assert (client_id and qs["client_id"] == [client_id]) or "client_id" not in qs def test_azure_firewall_resource_group_list_command(requests_mock): """ Given: - limit argument - Mock response from API client When: - Calling azure_firewall_resource_group_list_command Then: - Validate expected outputs returned """ from AzureFirewall import azure_firewall_resource_group_list_command authorization_mock(requests_mock) client = get_client_mock() url = f"https://management.azure.com/subscriptions/{SUBSCRIPTION_ID}/resourcegroups" mock_response = json.loads(load_mock_response("test_data/resource_group_list.json")) requests_mock.get(url, json=mock_response) result = azure_firewall_resource_group_list_command(client, {"limit": 50}) assert len(result.outputs) == 1 assert result.outputs_prefix == "AzureFirewall.ResourceGroup" assert result.outputs[0].get("name") == "name" def test_azure_firewall_subscriptions_list_command(requests_mock): """ Given: - Nothing When: - Calling azure_firewall_subscriptions_list_command Then: - Validate expected outputs returned """ from AzureFirewall import azure_firewall_subscriptions_list_command authorization_mock(requests_mock) client = get_client_mock() url = "https://management.azure.com/subscriptions" mock_response = json.loads(load_mock_response("test_data/subscriptions_list.json")) requests_mock.get(url, json=mock_response) result = azure_firewall_subscriptions_list_command(client) assert len(result.outputs) == 2 assert result.outputs_prefix == "AzureFirewall.Subscription" assert result.outputs[0].get("id") == "/subscriptions/1234"