FortiGate
FortiGate provides flawless convergence that can scale to any location: remote office, branch, campus, data center, and cloud. FortiGate always delivered on the concept of hybrid mesh firewalls with FortiManager for unified management and consistent security across complex hybrid environments. The Fortinet FortiOS operating system provides deep visibility and security across a variety of form factors.
Network Security · FortiGate
Details
| ID | FortiGate |
|---|---|
| Provider | Fortinet |
| Category | Network Security |
| From Version | 5.0.0 |
| Docker Image | demisto/python3:3.12.13.10116658 |
| Supported Modules | Agentix XSIAM EDR Cortex Cloud Cloud Runtime Security |
README
FortiGate provides flawless convergence that can scale to any location: remote office, branch, campus, data center, and cloud. FortiGate always delivered on the concept of hybrid mesh firewalls with FortiManager for unified management and consistent security across complex hybrid environments. The Fortinet FortiOS operating system provides deep visibility and security across a variety of form factors.
This integration was integrated and tested with version 7.2.5 of FortiGate.
Configure FortiGate in Cortex
| Parameter | Required |
|---|---|
| Server URL (e.g. https://192.168.0.1) | True |
| Account username | False |
| Password | False |
| API Key | False |
| API Key | False |
| Trust any certificate (not secure) | False |
| Use system proxy settings | 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.
fortigate-list-firewall-address-ipv4s
Retrieve firewall IPv4 addresses. Addresses define sources and destinations of network traffic and can be used in many functions such as firewall policies, ZTNA, etc.
Base Command
fortigate-list-firewall-address-ipv4s
Input
| Argument Name | Description | Required |
|---|---|---|
| name | Name of a specific address to return. | Optional |
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
| filter_field | Specifies the field to be searched, such as name or comment, to narrow down the search criteria within the objects. Fields must be written as they are in the raw_response. Reference to possible fields: https://docs.fortinet.com/document/fortigate/7.2.5/cli-reference/220620/config-firewall-address. |
Optional |
| filter_value | Indicates the value or partial value, for example Sales, that the API should look for within the specified field to find matching objects. |
Optional |
| format_fields | Comma-separated fields to format the API call to display certain information. Fields must be written as they are in the raw_response, for example: name or comment. Reference to possible fields: https://docs.fortinet.com/document/fortigate/7.2.5/cli-reference/220620/config-firewall-address. |
Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Fortigate.Address.Name | String | Address name. |
| Fortigate.Address.Subnet | String | IP address and subnet mask of address. |
| Fortigate.Address.StartIP | String | First IP address (inclusive) in the range for the address. |
| Fortigate.Address.EndIP | String | Final IP address (inclusive) in the range for the address. |
| Fortigate.Address.FQDN | String | Fully Qualified Domain Name address. |
| Fortigate.Address.MACAddresses | String | Multiple MAC address ranges <start>[-<end>] separated by a space. |
| Fortigate.Address.Type | String | Type of the address. Can be: `ipmask`, `iprange`, `fqdn`, `geography`, `wildcard`, `dynamic`, `interface-subnet` or `mac`. |
| Fortigate.Address.FabricObject | String | Security Fabric global object setting. Can be `enable` or `disable`. If `enable`, the object is set as a security fabric-wide global object, otherwise the object is local to this security fabric member. |
| Fortigate.Address.AllowRouting | String | Enable/disable use of this address in the static route configuration. |
| Fortigate.Address.Tagging | String | List of tags associated to the object. |
| Fortigate.Address.IPs | String | List of IP addresses. |
| Fortigate.Address.SDNAddressType | String | Type of addresses to collect. Can be: `private`, `public`, or `all`. |
| Fortigate.Address.AssociatedInterface | String | Network interface associated with the address. |
| Fortigate.Address.Comment | String | The object`s comment. |
| Fortigate.Address.Dirty | String | Whether the object is clean. |
| Fortigate.Address.TagType | String | Tag type of dynamic address object. |
| Fortigate.Address.TagDetectionLevel | String | Tag detection level of dynamic address object. |
| Fortigate.Address.ObjectType | String | IP or MAC address. |
| Fortigate.Address.Interface | String | Name of the interface whose IP address is to be used. |
| Fortigate.Address.FSSOGroup | String | Fortinet Single Sign-On group name. |
| Fortigate.Address.SDN | String | Software-defined networking. |
| Fortigate.Address.SDNTag | String | Software-defined networking tag. |
| Fortigate.Address.CacheTTL | Number | Defines the minimal TTL of individual IP addresses in FQDN cache measured in seconds. |
| Fortigate.Address.Country | String | IP addresses associated to a specific country. |
| Fortigate.Address.ClearpassSPT | String | System Posture Token value. Can be: `unknown`, `healthy`, `quarantine`, `checkup`, `transient` or `infected`. |
| Fortigate.Address.SubType | String | Sub-type of address. Can be: `sdn`, `clearpass-spt`, `fsso`, `ems-tag`, `fortivoice-tag`, `fortinac-tag`, `fortipolicy-tag` or `swc-tag`. |
| Fortigate.Address.UUID | String | Universally Unique Identifier. |
| Fortigate.Address.ObjectTag | String | Tag of dynamic address object. |
| Fortigate.Address.VDOM | String | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. |
Command example
!fortigate-list-firewall-address-ipv4s name=playbook-address-ipv4
Context Example
{
"Fortigate": {
"Address": {
"AllowRouting": "disable",
"AssociatedInterface": "",
"CacheTTL": 0,
"ClearpassSPT": "unknown",
"Comment": "",
"Country": "IL",
"Dirty": "dirty",
"FabricObject": "disable",
"Interface": "",
"Name": "playbook-address-ipv4",
"ObjectType": "ip",
"SDN": "",
"SDNAddressType": "private",
"SubType": "sdn",
"TagDetectionLevel": "",
"TagType": "",
"Type": "geography",
"UUID": "d30118b0-aa22-51ee-8e1b-bd78f7129431",
"VDOM": "root"
}
}
}
Human Readable Output
Firewall Address IPv4s
Name Details Type Routable playbook-address-ipv4 IL geography disable
fortigate-create-firewall-address-ipv4
Create firewall IPv4 addresses. Addresses define sources and destinations of network traffic and can be used in many functions such as firewall policies, ZTNA, etc. The command parameters can be used only in the following combinations: All-[vdom,name,comment,associated_interface], Subnet-[address,mask,allow_routing], IP Range-[start_ip,end_ip], FQDN-[fqdn,allow_routing], Geography-[country], Device (Mac Address)-[mac_addresses].
Base Command
fortigate-create-firewall-address-ipv4
Input
| Argument Name | Description | Required |
|---|---|---|
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
| name | The name of the address to create. | Required |
| address | The IP address. | Optional |
| mask | The subnet mask as an IP address. Default value: 255.255.255.255. |
Optional |
| fqdn | Fully Qualified Domain Name address. | Optional |
| start_ip | First IP address (inclusive) in the range for the address. | Optional |
| end_ip | Final IP address (inclusive) in the range for the address. | Optional |
| country | IP addresses associated to a specific country. Input must be according to the two-letter counter codes, for example: IL. |
Optional |
| mac_addresses | Comma-separated list of MAC addresses. Can be single or range. Range must be separated by -, for examlpe: 00:00:00:00:00:00 or 00:00:00:00:00:00-FF:FF:FF:FF:FF:FF. |
Optional |
| associated_interface | Network interface associated with address. | Optional |
| allow_routing | Enable/disable use of this address in the static route configuration. Possible values are: enable, disable. | Optional |
| comment | A comment for the address. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Frotigate.Address.Name | String | The name of the updated address. |
| Frotigate.Address.IPAddress | String | The IP address. |
| Frotigate.Address.Mask | String | The subnet mask of the address. |
| Frotigate.Address.FQDN | String | The Fully Qualified Domain Name address. |
| Frotigate.Address.StartIP | String | First IP address (inclusive) in the range for the address. |
| Frotigate.Address.EndIP | String | Final IP address (inclusive) in the range for the address. |
| Frotigate.Address.Country | String | IP addresses associated to a specific country. |
| Frotigate.Address.MAC | String | MAC addresses. |
Command example
!fortigate-create-firewall-address-ipv4 name=playbook-address-ipv4 country=IL
Context Example
{
"Fortigate": {
"Address": {
"Country": "IL",
"Name": "playbook-address-ipv4"
}
}
}
Human Readable Output
The firewall address ‘playbook-address-ipv4’ was successfully created
fortigate-update-firewall-address-ipv4
Update firewall IPv4 addresses. Addresses define sources and destinations of network traffic and can be used in many functions such as firewall policies, ZTNA, etc. The command parameters can be used only in the following combinations: All-[vdom,name,comment,associated_interface,type], Subnet-[address,mask,allow_routing], IP Range-[start_ip,end_ip], FQDN-[fqdn,allow_routing], Geography-[country], Device (Mac Address)-[mac_addresses].
Base Command
fortigate-update-firewall-address-ipv4
Input
| Argument Name | Description | Required |
|---|---|---|
| name | The name of the address to update. Names can be retrieved with the command fortigate-list-firewall-address-ipv4s. |
Required |
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
| address | The IP address. | Optional |
| mask | The subnet mask of the address. | Optional |
| fqdn | Fully Qualified Domain Name address. | Optional |
| start_ip | First IP address (inclusive) in the range for the address. | Optional |
| end_ip | Final IP address (inclusive) in the range for the address. | Optional |
| country | IP addresses associated to a specific country. Input must be according to the two-letter counter codes, for example: IL. |
Optional |
| mac_addresses | Comma-separated list of MAC addresses. Can be single or range. Range must be separated by -, for example: 00:00:00:00:00:00 or 00:00:00:00:00:00-FF:FF:FF:FF:FF:FF. |
Optional |
| associated_interface | Network interface associated with address. | Optional |
| allow_routing | Enable/disable use of this address in the static route configuration. Possible values are: enable, disable. | Optional |
| comment | A comment for the address. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Frotigate.Address.Name | String | The name of the created address. |
| Frotigate.Address.IPAddress | String | The IP address. |
| Frotigate.Address.Mask | String | The subnet mask of the address. |
| Frotigate.Address.FQDN | String | The Fully Qualified Domain Name address. |
| Frotigate.Address.StartIP | String | First IP address (inclusive) in the range for the address. |
| Frotigate.Address.EndIP | String | Final IP address (inclusive) in the range for the address. |
| Frotigate.Address.Country | String | IP addresses associated to a specific country. |
| Frotigate.Address.MAC | String | MAC addresses. |
Command example
!fortigate-update-firewall-address-ipv4 name=playbook-address-ipv4 comment=helloworld
Context Example
{
"Fortigate": {
"Address": {
"Name": "playbook-address-ipv4"
}
}
}
Human Readable Output
The firewall address ‘playbook-address-ipv4’ was successfully updated
fortigate-delete-firewall-address-ipv4
Delete firewall IPv4 addresses. Addresses define sources and destinations of network traffic and can be used in many functions such as firewall policies, ZTNA, etc.
Base Command
fortigate-delete-firewall-address-ipv4
Input
| Argument Name | Description | Required |
|---|---|---|
| name | Name of the address to delete. Names can be retrieved with the command fortigate-list-firewall-address-ipv4s. |
Required |
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Frotigate.Address.Name | String | The name of the deleted address. |
| Frotigate.Address.Deleted | Boolean | Whether the address was deleted. |
Command example
!fortigate-delete-firewall-address-ipv4 name=playbook-address-ipv4
Context Example
{
"Fortigate": {
"Address": {
"Deleted": true,
"Name": "playbook-address-ipv4"
}
}
}
Human Readable Output
The firewall address ‘playbook-address-ipv4’ was successfully deleted
fortigate-list-firewall-address-ipv6s
Retrieve firewall IPv6 addresses. Addresses define sources and destinations of network traffic and can be used in many functions such as firewall policies, ZTNA, etc.
Base Command
fortigate-list-firewall-address-ipv6s
Input
| Argument Name | Description | Required |
|---|---|---|
| name | Name of a specific address to return. | Optional |
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
| filter_field | Specifies the field to be searched, such as name or comment, to narrow down the search criteria within the objects. Fields must be written as they are in the raw_response. Reference to possible fields: https://docs.fortinet.com/document/fortigate/7.2.5/cli-reference/223620/config-firewall-address6. |
Optional |
| filter_value | Indicates the value or partial value, for example Sales, that the API should look for within the specified field to find matching objects. |
Optional |
| format_fields | Comma-separated fields to format the API call to display certain information. Fields must be written as they are in the raw_response, for example: name or comment. Reference to possible fields: https://docs.fortinet.com/document/fortigate/7.2.5/cli-reference/223620/config-firewall-address6. |
Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Fortigate.Address6.FabricObject | String | Security Fabric global object setting. Can be `enable` or `disable`. If `enable`, the object is set as a security fabric-wide global object, otherwise the object is local to this security fabric member. |
| Fortigate.Address6.SDNTag | String | Software-defined networking tag. |
| Fortigate.Address6.Tenant | String | Specifies the instance or environment in a multi-tenancy setup for configuring address objects. |
| Fortigate.Address6.HostType | String | Can be a wildcard or a specific host address. |
| Fortigate.Address6.SubnetSegment.Name | String | The subnet segment name. |
| Fortigate.Address6.SubnetSegment.Type | String | The subnet segment type. Can be a wildcard or a specific address. |
| Fortigate.Address6.SubnetSegment.Value | String | The subnet segment value. |
| Fortigate.Address6.Template | String | IPv6 address template. |
| Fortigate.Address6.Comment | String | The object`s comment. |
| Fortigate.Address6.Tagging | String | List of tags associated to the object. |
| Fortigate.Address6.IPs | String | List of IP addresses. |
| Fortigate.Address6.Country | String | IP addresses associated to a specific country. |
| Fortigate.Address6.FQDN | String | Fully Qualified Domain Name address. |
| Fortigate.Address6.StartIP | String | First IP address (inclusive) in the range for the address. |
| Fortigate.Address6.EndIP | String | Final IP address (inclusive) in the range for the address. |
| Fortigate.Address6.IPv6 | String | IPv6 address prefix. |
| Fortigate.Address6.SDN | String | Software-defined networking. |
| Fortigate.Address6.MACAddresses | Unknown | Multiple MAC address ranges <start>[-<end>] separated by a space. |
| Fortigate.Address6.Type | String | Type of IPv6 address object. Can be: `ipprefix`, `iprange`, `fqdn`, `geography`, `dynamic`, `template`, `mac`. |
| Fortigate.Address6.UUID | String | Universally Unique Identifier. |
| Fortigate.Address6.Name | String | Address name. |
| Fortigate.Address6.Host | String | Host address. |
| Fortigate.Address6.CacheTTL | Number | Defines the minimal TTL of individual IP addresses in FQDN cache measured in seconds. |
| Fortigate.Address6.VDOM | String | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. |
Command example
!fortigate-list-firewall-address-ipv6s name=playbook-address-ipv6 comment=helloworld
Context Example
{
"Fortigate": {
"Address6": {
"CacheTTL": 0,
"Comment": "",
"Country": "IL",
"EndIP": "::",
"FQDN": "",
"FabricObject": "disable",
"HostType": "any",
"Name": "playbook-address-ipv6",
"SDN": "",
"SDNTag": "",
"Template": "",
"Tenant": "",
"Type": "geography",
"UUID": "d827aafc-aa22-51ee-2088-2123aa731857",
"VDOM": "root"
}
}
}
Human Readable Output
Firewall Address IPv6s
Name Details Type playbook-address-ipv6 IL geography
fortigate-create-firewall-address-ipv6
Create firewall IPv6 addresses. Addresses define sources and destinations of network traffic and can be used in many functions such as firewall policies, ZTNA, etc. The command parameters can be used only in the following combinations: All-[vdom,name,comment], Subnet-[address,mask], IP Range-[start_ip,end_ip], FQDN-[fqdn], Geography-[country], Fabric Connector Address-[sdn_connector], Device (Mac Address)-[mac_addresses].
Base Command
fortigate-create-firewall-address-ipv6
Input
| Argument Name | Description | Required |
|---|---|---|
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
| name | Name of the address to create. | Required |
| address | IPv6 address prefix. Can be in short form (e.g., 2001:db8::) or long form (e.g., 0000:0000:0000:0000:0000:0000:0000:0000). | Optional |
| mask | Subnet mask indicating the prefix length (format: xxx, range: 0-128). | Optional |
| fqdn | Fully Qualified Domain Name address. | Optional |
| start_ip | First IP address (inclusive) in the range for the address. | Optional |
| end_ip | Final IP address (inclusive) in the range for the address. | Optional |
| country | IP addresses associated to a specific country. Input must be according to the two-letter counter codes, for example: IL. |
Optional |
| mac_addresses | Comma-separated list of MAC addresses. Can be single or range. Range must be separated by -, for example: 00:00:00:00:00:00 or 00:00:00:00:00:00-FF:FF:FF:FF:FF:FF. |
Optional |
| sdn_connector | Software-defined networking connector enables to interact with SDN controllers. For more information, go to: https://docs.fortinet.com/document/fortigate/7.2.5/administration-guide/753961/public-and-private-sdn-connectors. | Optional |
| comment | A comment for the address. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Frotigate.Address6.Name | String | The name of the updated address. |
| Frotigate.Address6.IPAddress | String | The IP address. |
| Frotigate.Address6.Mask | String | The subnet mask of the address. |
| Frotigate.Address6.FQDN | String | The Fully Qualified Domain Name address. |
| Frotigate.Address6.StartIP | String | First IP address (inclusive) in the range for the address. |
| Frotigate.Address6.EndIP | String | Final IP address (inclusive) in the range for the address. |
| Frotigate.Address6.Country | String | IP addresses associated to a specific country. |
| Frotigate.Address6.MAC | String | MAC addresses. |
| Frotigate.Address6.SDN | String | Software-defined networking. |
Command example
!fortigate-create-firewall-address-ipv6 name=playbook-address-ipv6 country=IL
Context Example
{
"Fortigate": {
"Address6": {
"Country": "IL",
"Name": "playbook-address-ipv6"
}
}
}
Human Readable Output
The firewall address ‘playbook-address-ipv6’ was successfully created
fortigate-update-firewall-address-ipv6
Update firewall IPv6 addresses. Addresses define sources and destinations of network traffic and can be used in many functions such as firewall policies, ZTNA, etc. The command parameters can be used only in the following combinations: All-[vdom,name,comment,associated_interface], Subnet-[address,mask], IP Range-[start_ip,end_ip], FQDN-[fqdn], Geography-[country], Fabric Connector Address-[sdn_connector], Device (Mac Address)-[mac_addresses].
Base Command
fortigate-update-firewall-address-ipv6
Input
| Argument Name | Description | Required |
|---|---|---|
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
| name | Name of the address to update. Names can be retrieved with the command fortigate-list-firewall-address-ipv6s. |
Required |
| type | The type of the address to update. Possible values are: Subnet, IP Range, FQDN, Geography, Device (Mac Address), Fabric Connector Address. | Optional |
| address | The IP address. | Optional |
| mask | The subnet mask of the address. | Optional |
| fqdn | Fully Qualified Domain Name address. | Optional |
| start_ip | First IP address (inclusive) in the range for the address. | Optional |
| end_ip | Final IP address (inclusive) in the range for the address. | Optional |
| country | IP addresses associated to a specific country. Input must be according to the two-letter counter codes, for example: IL. |
Optional |
| mac_addresses | Comma-separated list of MAC addresses. Can be single or range. Range must be separated by -, for example: 00:00:00:00:00:00 or 00:00:00:00:00:00-FF:FF:FF:FF:FF:FF. |
Optional |
| sdn_connector | Software-defined networking connector enables to interact with SDN controllers. For more information, go to: https://docs.fortinet.com/document/fortigate/7.2.5/administration-guide/753961/public-and-private-sdn-connectors. | Optional |
| comment | A comment for the address. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Frotigate.Address6.Name | String | The name of the updated address. |
| Frotigate.Address6.IPAddress | String | The IP address. |
| Frotigate.Address6.Mask | String | The subnet mask of the address. |
| Frotigate.Address6.FQDN | String | The Fully Qualified Domain Name address. |
| Frotigate.Address6.StartIP | String | First IP address (inclusive) in the range for the address. |
| Frotigate.Address6.EndIP | String | Final IP address (inclusive) in the range for the address. |
| Frotigate.Address6.Country | String | IP addresses associated to a specific country. |
| Frotigate.Address6.MAC | String | MAC addresses. |
| Frotigate.Address6.SDN | String | Software-defined networking. |
Command example
!fortigate-update-firewall-address-ipv6 name=playbook-address-ipv6
Context Example
{
"Fortigate": {
"Address6": {
"Name": "playbook-address-ipv6"
}
}
}
Human Readable Output
The firewall address ‘playbook-address-ipv6’ was successfully updated
fortigate-delete-firewall-address-ipv6
Delete firewall IPv6 addresses. Addresses define sources and destinations of network traffic and can be used in many functions such as firewall policies, ZTNA, etc.
Base Command
fortigate-delete-firewall-address-ipv6
Input
| Argument Name | Description | Required |
|---|---|---|
| name | Name of the address to delete. Names can be retrieved with the command fortigate-list-firewall-address-ipv6s. |
Required |
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Fortigate.Address6.Name | String | The name of the address. |
| Fortigate.Address6.Deleted | Boolean | Whether the address was deleted. |
Command example
!fortigate-delete-firewall-address-ipv6 name=playbook-address-ipv6
Context Example
{
"Fortigate": {
"Address6": {
"Deleted": true,
"Name": "playbook-address-ipv6"
}
}
}
Human Readable Output
The firewall address ‘playbook-address-ipv6’ was successfully deleted
fortigate-list-firewall-address-ipv4-multicasts
Retrieve firewall IPv4 multicast addresses. Multicasting allows a single source to send data to multiple receivers efficiently, conserving bandwidth and minimizing network traffic. It is suitable for media streaming, news feeds, financial updates, and certain dynamic routing protocols like RIPv2, OSPF, and EIGRP.
Base Command
fortigate-list-firewall-address-ipv4-multicasts
Input
| Argument Name | Description | Required |
|---|---|---|
| name | Name of a specific address to return. | Optional |
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
| filter_field | Specifies the field to be searched, such as name or comment, to narrow down the search criteria within the objects. Fields must be written as they are in the raw_response. Reference to possible fields: https://docs.fortinet.com/document/fortigate/7.2.5/cli-reference/221620/config-firewall-multicast-address. |
Optional |
| filter_value | Indicates the value or partial value, for example Sales, that the API should look for within the specified field to find matching objects. |
Optional |
| format_fields | Comma-separated fields to format the API call to display certain information. Fields must be written as they are in the raw_response, for example: name or comment. Reference to possible fields: https://docs.fortinet.com/document/fortigate/7.2.5/cli-reference/221620/config-firewall-multicast-address. |
Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Fortigate.AddressMulticast.Tagging | String | List of tags associated to the object. |
| Fortigate.AddressMulticast.AssociatedInterface | String | Network interface associated with address. |
| Fortigate.AddressMulticast.Comment | String | The object`s comment. |
| Fortigate.AddressMulticast.EndIP | String | Final IP address (inclusive) in the range for the address. |
| Fortigate.AddressMulticast.StartIP | String | First IP address (inclusive) in the range for the address. |
| Fortigate.AddressMulticast.Subnet | String | Broadcast address and subnet. |
| Fortigate.AddressMulticast.Type | String | Type of the address multicast. Can be: `multicastrange` or `broadcastmask`. |
| Fortigate.AddressMulticast.Name | String | Address multicast name. |
| Fortigate.AddressMulticast.VDOM | String | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. |
Command example
!fortigate-list-firewall-address-ipv4-multicasts name=playbook-address-ipv4-multicast
Context Example
{
"Fortigate": {
"AddressMulticast": {
"AssociatedInterface": "",
"Comment": "",
"Name": "playbook-address-ipv4-multicast",
"Subnet": "0.0.0.0-0.0.0.0",
"Type": "broadcastmask",
"VDOM": "root"
}
}
}
Human Readable Output
Firewall Address IPv4 Multicasts
Name Details Type playbook-address-ipv4-multicast 0.0.0.0-0.0.0.0 broadcastmask
fortigate-create-firewall-address-ipv4-multicast
Create firewall IPv4 multicast addresses. Multicasting allows a single source to send data to multiple receivers efficiently, conserving bandwidth and minimizing network traffic. It`s suitable for media streaming, news feeds, financial updates, and certain dynamic routing protocols like RIPv2, OSPF, and EIGRP.
Base Command
fortigate-create-firewall-address-ipv4-multicast
Input
| Argument Name | Description | Required |
|---|---|---|
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
| name | Name of the address multicast to create. | Required |
| comment | A comment for the address. | Optional |
| associated_interface | Network interface associated with address. | Optional |
| type | Specifies the format of the multicast address. Possible values are: Broadcast Subnet, Multicast IP Range. | Required |
| first_ip | For Broadcast Subnet, this is the network address. For Multicast IP Range, (inclusive) this is the beginning of the IP range. |
Required |
| final_ip | For Broadcast Subnet this should be the network mask as an IP address. For Multicast IP Range, (inclusive) this is the end of the IP range. |
Required |
Context Output
| Path | Type | Description |
|---|---|---|
| Frotigate.AddressMulticast.Name | String | The name of the updated address multicast. |
| Frotigate.AddressMulticast.Type | String | Specifies the format of the multicast address. |
| Frotigate.AddressMulticast.FirstIP | String | First input IP address. |
| Frotigate.AddressMulticast.FinalIP | String | Final input IP address. |
Command example
!fortigate-create-firewall-address-ipv4-multicast name=playbook-address-ipv4-multicast type="Broadcast Subnet" first_ip=0.0.0.0 final_ip=0.0.0.0
Context Example
{
"Fortigate": {
"AddressMulticast": {
"FinalIP": "0.0.0.0",
"FirstIP": "0.0.0.0",
"Name": "playbook-address-ipv4-multicast",
"Type": "Broadcast Subnet"
}
}
}
Human Readable Output
The firewall address multicast IPv4 ‘playbook-address-ipv4-multicast’ was successfully created
fortigate-update-firewall-address-ipv4-multicast
Update firewall IPv4 multicast addresses. Multicasting allows a single source to send data to multiple receivers efficiently, conserving bandwidth and minimizing network traffic. It`s suitable for media streaming, news feeds, financial updates, and certain dynamic routing protocols like RIPv2, OSPF, and EIGRP.
Base Command
fortigate-update-firewall-address-ipv4-multicast
Input
| Argument Name | Description | Required |
|---|---|---|
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
| name | Name of the address multicast to update. Names can be retrieved with the command fortigate-list-firewall-address-ipv4-multicasts. |
Required |
| comment | A comment for the address. | Optional |
| associated_interface | Network interface associated with address. | Optional |
| type | Specifies the format of the multicast address. Possible values are: Broadcast Subnet, Multicast IP Range. | Optional |
| first_ip | For ‘Broadcast Subnet’, this is the network address. For ‘Multicast IP Range’, (inclusive) this is the beginning of the IP range. | Optional |
| final_ip | For ‘Broadcast Subnet’ this should be the network mask as an IP address. For Multicast IP Range, (inclusive) this is the end of the IP range. |
Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Frotigate.AddressMulticast.Name | String | The name of the updated address multicast. |
| Frotigate.AddressMulticast.Type | String | Specifies the format of the multicast address. |
| Frotigate.AddressMulticast.FirstIP | String | First input IP address. |
| Frotigate.AddressMulticast.FinalIP | String | Final input IP address. |
Command example
!fortigate-update-firewall-address-ipv4-multicast name=playbook-address-ipv4-multicast comment=helloworld
Context Example
{
"Fortigate": {
"AddressMulticast": {
"Name": "playbook-address-ipv4-multicast"
}
}
}
Human Readable Output
The firewall address multicast IPv4 ‘playbook-address-ipv4-multicast’ was successfully updated
fortigate-delete-firewall-address-ipv4-multicast
Delete firewall IPv4 multicast addresses. Multicasting allows a single source to send data to multiple receivers efficiently, conserving bandwidth and minimizing network traffic. It is suitable for media streaming, news feeds, financial updates, and certain dynamic routing protocols like RIPv2, OSPF, and EIGRP.
Base Command
fortigate-delete-firewall-address-ipv4-multicast
Input
| Argument Name | Description | Required |
|---|---|---|
| name | Name of the address multicast to delete. Names can be retrieved with the command fortigate-list-firewall-address-ipv4-multicasts. |
Required |
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Fortigate.AddressMulticast.Name | String | The name of the address multicast. |
| Fortigate.AddressMulticast.Deleted | Boolean | Whether the address multicast was deleted. |
Command example
!fortigate-delete-firewall-address-ipv4-multicast name=playbook-address-ipv4-multicast
Context Example
{
"Fortigate": {
"AddressMulticast": {
"Deleted": true,
"Name": "playbook-address-ipv4-multicast"
}
}
}
Human Readable Output
The firewall address multicast IPv4 ‘playbook-address-ipv4-multicast’ was successfully deleted
fortigate-list-firewall-address-ipv6-multicasts
Retrieve firewall IPv6 multicast addresses. Multicasting allows a single source to send data to multiple receivers efficiently, conserving bandwidth and minimizing network traffic. It is suitable for media streaming, news feeds, financial updates, and certain dynamic routing protocols like RIPv2, OSPF, and EIGRP.
Base Command
fortigate-list-firewall-address-ipv6-multicasts
Input
| Argument Name | Description | Required |
|---|---|---|
| name | Name of a specific address multicast to return. | Optional |
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
| filter_field | Specifies the field to be searched, such as name or comment, to narrow down the search criteria within the objects. Fields must be written as they are in the raw_response. Reference to possible fields: https://docs.fortinet.com/document/fortigate/7.2.5/cli-reference/224620/config-firewall-multicast-address6. |
Optional |
| filter_value | Indicates the value or partial value, for example Sales, that the API should look for within the specified field to find matching objects. |
Optional |
| format_fields | Comma-separated fields to format the API call to display certain information. Fields must be written as they are in the raw_response, for example: name or comment. Reference to possible fields: https://docs.fortinet.com/document/fortigate/7.2.5/cli-reference/224620/config-firewall-multicast-address6. |
Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Fortigate.Address6Multicast.Tagging | String | List of tags associated to the object. |
| Fortigate.Address6Multicast.Comment | String | The object`s comment. |
| Fortigate.Address6Multicast.IPv6 | String | Broadcast address and subnet. |
| Fortigate.Address6Multicast.Name | String | Address multicast name. |
| Fortigate.Address6Multicast.VDOM | String | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. |
Command example
!fortigate-list-firewall-address-ipv6-multicasts name=playbook-address-ipv6-multicast
Context Example
{
"Fortigate": {
"Address6Multicast": {
"Comment": "",
"IPv6": "ff00::/8",
"Name": "playbook-address-ipv6-multicast",
"VDOM": "root"
}
}
}
Human Readable Output
Firewall Address IPv6 Multicasts
Name Details playbook-address-ipv6-multicast ff00::/8
fortigate-create-firewall-address-ipv6-multicast
Create firewall IPv6 multicast addresses. Multicasting allows a single source to send data to multiple receivers efficiently, conserving bandwidth and minimizing network traffic. It is suitable for media streaming, news feeds, financial updates, and certain dynamic routing protocols like RIPv2, OSPF, and EIGRP.
Base Command
fortigate-create-firewall-address-ipv6-multicast
Input
| Argument Name | Description | Required |
|---|---|---|
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
| name | Name of the address multicast to create. | Required |
| comment | A comment for the address. | Optional |
| address | IPv6 address prefix. Can be in short form (e.g., 2001:db8::) or long form (e.g., 0000:0000:0000:0000:0000:0000:0000:0000). | Required |
| mask | Subnet mask indicating the prefix length (format: xxx, range: 0-128). | Required |
Context Output
| Path | Type | Description |
|---|---|---|
| Frotigate.Address6Multicast.Name | String | The name of the updated address multicast. |
| Frotigate.Address6Multicast.IPAddress | String | The IP address. |
| Frotigate.Address6Multicast.Mask | String | The subnet mask of the address. |
Command example
!fortigate-create-firewall-address-ipv6-multicast name=playbook-address-ipv6-multicast address=ff00:: mask=8
Context Example
{
"Fortigate": {
"Address6Multicast": {
"IPAddress": "ff00::",
"Mask": "8",
"Name": "playbook-address-ipv6-multicast"
}
}
}
Human Readable Output
The firewall address multicast IPv6 ‘playbook-address-ipv6-multicast’ was successfully created
fortigate-update-firewall-address-ipv6-multicast
Update firewall IPv6 multicast addresses. Multicasting allows a single source to send data to multiple receivers efficiently, conserving bandwidth and minimizing network traffic. It is suitable for media streaming, news feeds, financial updates, and certain dynamic routing protocols like RIPv2, OSPF, and EIGRP.
Base Command
fortigate-update-firewall-address-ipv6-multicast
Input
| Argument Name | Description | Required |
|---|---|---|
| name | Name of the address multicast to update. Names can be retrieved with the command fortigate-list-firewall-address-ipv6-multicasts. |
Required |
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
| comment | A comment for the address. | Optional |
| address | IPv6 address prefix. Can be in short form (e.g., 2001:db8::) or long form (e.g., 0000:0000:0000:0000:0000:0000:0000:0000). | Optional |
| mask | Subnet mask indicating the prefix length (format: xxx, range: 0-128). | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Frotigate.Address6Multicast.Name | String | The name of the updated address multicast. |
| Frotigate.Address6Multicast.IPAddress | String | The IP address. |
| Frotigate.Address6Multicast.Mask | String | The subnet mask of the address. |
Command example
!fortigate-update-firewall-address-ipv6-multicast name=playbook-address-ipv6-multicast comment=helloworld
Context Example
{
"Fortigate": {
"Address6Multicast": {
"Name": "playbook-address-ipv6-multicast"
}
}
}
Human Readable Output
The firewall address multicast IPv6 ‘playbook-address-ipv6-multicast’ was successfully updated
fortigate-delete-firewall-address-ipv6-multicast
Delete firewall IPv6 multicast addresses. Multicasting allows a single source to send data to multiple receivers efficiently, conserving bandwidth and minimizing network traffic. It is suitable for media streaming, news feeds, financial updates, and certain dynamic routing protocols like RIPv2, OSPF, and EIGRP.
Base Command
fortigate-delete-firewall-address-ipv6-multicast
Input
| Argument Name | Description | Required |
|---|---|---|
| name | Name of the address multicast to delete. Names can be retrieved with the command fortigate-list-firewall-address-ipv6-multicasts. |
Required |
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Fortigate.Address6Multicast.Name | String | The name of the address multicast. |
| Fortigate.Address6Multicast.Deleted | Boolean | Whether the address multicast was deleted. |
Command example
!fortigate-delete-firewall-address-ipv6-multicast name=playbook-address-ipv6-multicast
Context Example
{
"Fortigate": {
"Address6Multicast": {
"Deleted": true,
"Name": "playbook-address-ipv6-multicast"
}
}
}
Human Readable Output
The firewall address multicast IPv6 ‘playbook-address-ipv6-multicast’ was successfully deleted
fortigate-list-firewall-address-ipv4-groups
Retrieve firewall IPv4 address groups. Address groups are designed for ease of use in the administration of the device.
Base Command
fortigate-list-firewall-address-ipv4-groups
Input
| Argument Name | Description | Required |
|---|---|---|
| groupName | Name of a specific address group to return. | Optional |
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
| filter_field | Specifies the field to be searched, such as name or comment, to narrow down the search criteria within the objects. Fields must be written as they are in the raw_response. Reference to possible fields: https://docs.fortinet.com/document/fortigate/7.2.5/cli-reference/225620/config-firewall-addrgrp. |
Optional |
| filter_value | Indicates the value or partial value, for example Sales, that the API should look for within the specified field to find matching objects. |
Optional |
| format_fields | Comma-separated fields to format the API call to display certain information. Fields must be written as they are in the raw_response, for example: name or comment. Reference to possible fields: https://docs.fortinet.com/document/fortigate/7.2.5/cli-reference/225620/config-firewall-addrgrp. |
Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Frotigate.AddressGroup.FabricObject | String | Security Fabric global object setting. Can be `enable` or `disable`. If `enable`, the object is set as a security fabric-wide global object, otherwise the object is local to this security fabric member. |
| Frotigate.AddressGroup.AllowRouting | String | Enable/disable use of this address in the static route configuration. |
| Frotigate.AddressGroup.Tagging | String | List of tags associated to the object. |
| Frotigate.AddressGroup.ExcludeMember | String | Address name exclusion member. |
| Frotigate.AddressGroup.Exclude | String | Enable/disable address exclusion. |
| Frotigate.AddressGroup.Comment | String | The object`s comment. |
| Frotigate.AddressGroup.Member.Name | String | Address objects contained within the group. |
| Frotigate.AddressGroup.UUID | String | Universally Unique Identifier. |
| Frotigate.AddressGroup.Category | String | Address group category. `default`: Default address group category (cannot be used as ztna-ems-tag/ztna-geo-tag in policy). `ztna-ems-tag`: Members must be ztna-ems-tag group or ems-tag address. Can be used as ztna-ems-tag in policy. `ztna-geo-tag`: Members must be ztna-geo-tag group or geographic address. Can be used as ztna-geo-tag in policy. |
| Frotigate.AddressGroup.Type | String | Address group type. Default address group type (address may belong to multiple groups). Address folder group (members may not belong to any other group). |
| Frotigate.AddressGroup.Name | String | Address group name. |
| Fortigate.AddressGroup.VDOM | String | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. |
Command example
!fortigate-list-firewall-address-ipv4-groups groupName=playbook-address-ipv4-group
Context Example
{
"Fortigate": {
"AddressGroup": {
"AllowRouting": "disable",
"Category": "default",
"Comment": "",
"Exclude": "disable",
"FabricObject": "disable",
"Member": {
"Name": [
"playbook-address-ipv4-1"
]
},
"Name": "playbook-address-ipv4-group",
"Type": "default",
"UUID": "e7adb0ca-aa22-51ee-b304-c7fc8ce5e274",
"VDOM": "root"
}
}
}
Human Readable Output
Firewall Address IPv4 Groups
Name Details Type Routable playbook-address-ipv4-group playbook-address-ipv4-1 default disable
fortigate-create-firewall-address-ipv4-group
Create firewall IPv4 address groups. Address groups are designed for ease of use in the administration of the device.
Base Command
fortigate-create-firewall-address-ipv4-group
Input
| Argument Name | Description | Required |
|---|---|---|
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
| groupName | Name of the address group to create. | Required |
| type | Address group type. group: Default address group type (address may belong to multiple groups). folder: Address folder group (members may not belong to any other group). Possible values are: group, folder. Default is group. |
Optional |
| address | Comma-separated list of address names. Names can be retrieved with the commands fortigate-list-firewall-address-ipv4s, fortigate-list-firewall-address-ipv4-multicasts and fortigate-list-firewall-address-ipv4-groups. |
Optional |
| excluded_addresses | Comma-separated list of address names to exclude. Names can be retrieved with the commands fortigate-list-firewall-address-ipv4s, fortigate-list-firewall-address-ipv4-multicasts and fortigate-list-firewall-address-ipv4-groups. |
Optional |
| allow_routing | Enable/disable use of this address in the static route configuration. Possible values are: enable, disable. | Optional |
| comment | A comment for the address group. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Fortigate.AddressGroup.Name | String | The address group name. |
| Fortigate.AddressGroup.Address | String | The address group members. |
Command example
!fortigate-create-firewall-address-ipv4-group groupName=playbook-address-ipv4-group address=playbook-address-ipv4-1
Context Example
{
"Fortigate": {
"AddressGroup": {
"Address": "playbook-address-ipv4-1",
"Name": "playbook-address-ipv4-group"
}
}
}
Human Readable Output
The firewall address IPv4 group ‘playbook-address-ipv4-group’ was successfully created
fortigate-update-firewall-address-ipv4-group
Update firewall IPv4 address groups. Address groups are designed for ease of use in the administration of the device. New members will override the existing members within the group incase of a conflict.
Base Command
fortigate-update-firewall-address-ipv4-group
Input
| Argument Name | Description | Required |
|---|---|---|
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
| groupName | Name of the address group to update. Names can be retrieved with the command fortigate-list-firewall-address-ipv4-groups. |
Required |
| address | Comma-separated list of address names. Names can be retrieved with the commands fortigate-list-firewall-address-ipv4s, fortigate-list-firewall-address-ipv4-multicasts and fortigate-list-firewall-address-ipv4-groups. |
Optional |
| excluded_addresses | Comma-separated list of address names to exclude. Names can be retrieved with the commands fortigate-list-firewall-address-ipv4s, fortigate-list-firewall-address-ipv4-multicasts and fortigate-list-firewall-address-ipv4-groups. |
Optional |
| allow_routing | Enable/disable use of this address in the static route configuration. Possible values are: enable, disable. | Optional |
| comment | A comment for the address group. | Optional |
| action | Whether to add or remove members or excluded_members from address group. Possible values are: add, remove. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Fortigate.AddressGroup.Name | String | The address group name. |
| Fortigate.AddressGroup.Address.Name | String | The address group members. |
| Frotigate.AddressGroup.UUID | String | Universally Unique Identifier. |
Command example
!fortigate-update-firewall-address-ipv4-group groupName=playbook-address-ipv4-group address=playbook-address-ipv4-2 action=add
Context Example
{
"Fortigate": {
"AddressGroup": {
"Address": {
"Name": [
"playbook-address-ipv4-1",
"playbook-address-ipv4-2"
]
},
"Name": "playbook-address-ipv4-group",
"UUID": "e7adb0ca-aa22-51ee-b304-c7fc8ce5e274"
}
}
}
Human Readable Output
The firewall address IPv4 group ‘playbook-address-ipv4-group’ was successfully updated
fortigate-delete-firewall-address-ipv4-group
Delete firewall IPv4 address groups. Address groups are designed for ease of use in the administration of the device.
Base Command
fortigate-delete-firewall-address-ipv4-group
Input
| Argument Name | Description | Required |
|---|---|---|
| name | Name of the address group to delete. Names can be retrieved with the command fortigate-list-firewall-address-ipv4-groups. |
Required |
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Fortigate.AddressGroup.Name | String | The name of the address group. |
| Fortigate.AddressGroup.Deleted | Boolean | Whether the address group was deleted. |
Command example
!fortigate-delete-firewall-address-ipv4-group name=playbook-address-ipv4-group
Context Example
{
"Fortigate": {
"AddressGroup": {
"Deleted": true,
"Name": "playbook-address-ipv4-group"
}
}
}
Human Readable Output
The firewall address IPv4 group ‘playbook-address-ipv4-group’ was successfully deleted
fortigate-list-firewall-address-ipv6-groups
Retrieve firewall IPv6 address groups. Address groups are designed for ease of use in the administration of the device.
Base Command
fortigate-list-firewall-address-ipv6-groups
Input
| Argument Name | Description | Required |
|---|---|---|
| name | Name of a specific address group to return. | Optional |
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
| filter_field | Specifies the field to be searched, such as name or comment, to narrow down the search criteria within the objects. Fields must be written as they are in the raw_response. Reference to possible fields: https://docs.fortinet.com/document/fortigate/7.2.5/cli-reference/226620/config-firewall-addrgrp6. |
Optional |
| filter_value | Indicates the value or partial value, for example Sales, that the API should look for within the specified field to find matching objects. |
Optional |
| format_fields | Comma-separated fields to format the API call to display certain information. Fields must be written as they are in the raw_response, for example: name or comment. Reference to possible fields: https://docs.fortinet.com/document/fortigate/7.2.5/cli-reference/226620/config-firewall-addrgrp6. |
Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Frotigate.Address6Group.FabricObject | String | Security Fabric global object setting. Can be `enable` or `disable`. If `enable`, the object is set as a security fabric-wide global object, otherwise the object is local to this security fabric member. |
| Frotigate.Address6Group.Tagging | String | List of tags associated to the object. |
| Frotigate.Address6Group.Member.Name | String | Address objects contained within the group. |
| Frotigate.Address6Group.Comment | String | The object`s comment. |
| Frotigate.Address6Group.UUID | String | Universally Unique Identifier. |
| Frotigate.Address6Group.Name | String | Address group name. |
| Fortigate.Address6Group.VDOM | String | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. |
Command example
!fortigate-list-firewall-address-ipv6-groups name=playbook-address-ipv6-group
Context Example
{
"Fortigate": {
"Address6Group": {
"Comment": "",
"FabricObject": "disable",
"Name": "playbook-address-ipv6-group",
"UUID": "ecd06d9a-aa22-51ee-a0a1-29b8ccdf7714",
"VDOM": "root"
}
}
}
Human Readable Output
Firewall Address IPv6 Groups
Name playbook-address-ipv6-group
fortigate-create-firewall-address-ipv6-group
Create firewall IPv6 address groups. Address groups are designed for ease of use in the administration of the device.
Base Command
fortigate-create-firewall-address-ipv6-group
Input
| Argument Name | Description | Required |
|---|---|---|
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
| name | Name of the address group to create. | Required |
| members | Comma-separated list of address names. Names can be retrieved with the commands fortigate-list-firewall-address-ipv6s, fortigate-list-firewall-address-ipv6-multicasts and fortigate-list-firewall-address-ipv6-groups. |
Optional |
| comment | A comment for the address group. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Fortigate.Address6Group.Name | String | The address group name. |
| Fortigate.Address6Group.Address | String | The address group members. |
Command example
!fortigate-create-firewall-address-ipv6-group name=playbook-address-ipv6-group
Context Example
{
"Fortigate": {
"Address6Group": {
"Address": null,
"Name": "playbook-address-ipv6-group"
}
}
}
Human Readable Output
The firewall address IPv6 group ‘playbook-address-ipv6-group’ was successfully created
fortigate-update-firewall-address-ipv6-group
Update firewall IPv6 address groups. Address groups are designed for ease of use in the administration of the device. New members will override the existing members within the group incase of a conflict.
Base Command
fortigate-update-firewall-address-ipv6-group
Input
| Argument Name | Description | Required |
|---|---|---|
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
| name | Name of the address group to update. Names can be retrieved with the command fortigate-list-firewall-address-ipv6-groups. |
Required |
| members | Comma-separated list of address names. Names can be retrieved with the commands fortigate-list-firewall-address-ipv6s, fortigate-list-firewall-address-ipv6-multicasts and fortigate-list-firewall-address-ipv6-groups. |
Optional |
| comment | A comment for the address group. | Optional |
| action | Whether to add or remove members from address group. Possible values are: add, remove. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Fortigate.Address6Group.Name | String | The address group name. |
| Fortigate.Address6Group.Address | String | The address group members. |
Command example
!fortigate-update-firewall-address-ipv6-group name=playbook-address-ipv6-group members=playbook-address-ipv6-1 action=add
Context Example
{
"Fortigate": {
"Address6Group": {
"Address": {
"Name": [
"playbook-address-ipv6-1"
]
},
"Name": "playbook-address-ipv6-group"
}
}
}
Human Readable Output
The firewall address IPv6 group ‘playbook-address-ipv6-group’ was successfully updated
fortigate-delete-firewall-address-ipv6-group
Delete firewall IPv6 address groups. Address groups are designed for ease of use in the administration of the device.
Base Command
fortigate-delete-firewall-address-ipv6-group
Input
| Argument Name | Description | Required |
|---|---|---|
| name | Name of the address group to delete. Names can be retrieved with the command fortigate-list-firewall-address-ipv6-groups. |
Required |
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Fortigate.Address6Group.Name | String | The name of the deleted address group. |
| Fortigate.Address6Group.Deleted | Boolean | Whether the address group was deleted. |
Command example
!fortigate-delete-firewall-address-ipv6-group name=playbook-address-ipv6-group
Context Example
{
"Fortigate": {
"Address6Group": {
"Deleted": true,
"Name": "playbook-address-ipv6-group"
}
}
}
Human Readable Output
The firewall address IPv6 group ‘playbook-address-ipv6-group’ was successfully deleted
fortigate-list-firewall-services
Retrieve firewall services. A service is the combination of network protocols and port numbers that define traffic sources or destinations.
Base Command
fortigate-list-firewall-services
Input
| Argument Name | Description | Required |
|---|---|---|
| serviceName | Name of a specific service to return. | Optional |
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
| filter_field | Specifies the field to be searched, such as name or comment, to narrow down the search criteria within the objects. Fields must be written as they are in the raw_response. Reference to possible fields: https://docs.fortinet.com/document/fortigate/7.2.5/cli-reference/231620/config-firewall-service-custom. |
Optional |
| filter_value | Indicates the value or partial value, for example Sales, that the API should look for within the specified field to find matching objects. |
Optional |
| format_fields | Comma-separated fields to format the API call to display certain information. Fields must be written as they are in the raw_response, for example: name or comment. Reference to possible fields: https://docs.fortinet.com/document/fortigate/7.2.5/cli-reference/231620/config-firewall-service-custom. |
Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Fortigate.Service.FabricObject | String | Security Fabric global object setting. Can be `enable` or `disable`. If `enable`, the object is set as a security fabric-wide global object, otherwise the object is local to this security fabric member. |
| Fortigate.Service.Application | Number | The application ID. |
| Fortigate.Service.AppCategory | Number | Application category ID. |
| Fortigate.Service.AppServiceType | String | Application service type. Can be: `disable`, `app-id` or `app-category`. |
| Fortigate.Service.Comment | String | The object`s comment. |
| Fortigate.Service.CheckResetRange | String | The configuration type of ICMP error message verification. |
| Fortigate.Service.SessionTTL | String | Session time to live. |
| Fortigate.Service.UDPIdleTimer | Number | Number of seconds before an idle UDP connection times out. |
| Fortigate.Service.TCPRSTTimer | Number | Set the length of the TCP CLOSE state in seconds. |
| Fortigate.Service.TCPTimewaitTimer | Number | Set the length of the TCP TIME-WAIT state in seconds. |
| Fortigate.Service.TCPHalfopenTimer | Number | Wait time to close a TCP session waiting for an unanswered open session packet. |
| Fortigate.Service.TCPHalfcloseTimer | Number | Wait time to close a TCP session waiting for an unanswered open session packet. |
| Fortigate.Service.Ports.SCTP | String | Multiple SCTP port ranges. |
| Fortigate.Service.Ports.UDP | String | Multiple UDP port ranges. |
| Fortigate.Service.Ports.TCP | String | Multiple TCP port ranges. |
| Fortigate.Service.FQDN | String | Fully Qualified Domain Name address. |
| Fortigate.Service.IPRange | String | Start and end of the IP range associated with the service. |
| Fortigate.Service.Helper | String | Helper protocol name. |
| Fortigate.Service.Protocol | String | Protocol type based on IANA numbers. |
| Fortigate.Service.Category | String | The service category. |
| Fortigate.Service.Proxy | String | Enable/disable web proxy service. |
| Fortigate.Service.Name | String | The service name. |
| Fortigate.Service.ICMPCode | Number | ICMP code. |
| Fortigate.Service.ICMPType | Number | ICMP type. |
| Fortigate.Service.ProtocolNumber | Number | IP protocol number. |
| Fortigate.Service.VDOM | String | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. |
Command example
!fortigate-list-firewall-services serviceName=playbook-service
Context Example
{
"Fortigate": {
"Service": {
"AppServiceType": "disable",
"Category": "",
"CheckResetRange": "default",
"Comment": "",
"FQDN": "",
"FabricObject": "disable",
"Helper": "auto",
"IPRange": "0.0.0.0",
"Name": "playbook-service",
"Ports": {
"SCTP": "5-6",
"TCP": "1-2",
"UDP": "3-4"
},
"Protocol": "TCP/UDP/SCTP",
"Proxy": "disable",
"SessionTTL": "0",
"TCPHalfcloseTimer": 0,
"TCPHalfopenTimer": 0,
"TCPRSTTimer": 0,
"TCPTimewaitTimer": 0,
"UDPIdleTimer": 0,
"VDOM": "root"
}
}
}
Human Readable Output
Firewall Services
Name Details IP/FQDN Protocol playbook-service TCP/1-2 UDP/3-4 SCTP/5-6 0.0.0.0 TCP/UDP/SCTP
fortigate-create-firewall-service
Create firewall services. A service is the combination of network protocols and port numbers that define traffic sources or destinations. The command parameters can be used only in the following combinations: All-[vdom,name,comment,category], TCP/UDP/SCTP-[(start_ip,end_ip or fqdn),tcpRange,udpRange,sctpRange], IP-[ip_protocol], ICMP/ICMP6-[icmp_version,icmp_code,icmp_type].
Base Command
fortigate-create-firewall-service
Input
| Argument Name | Description | Required |
|---|---|---|
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
| serviceName | Name of the service to create. | Required |
| comment | A comment for the service. | Optional |
| category | Service category. | Optional |
| start_ip | Start of the IP range associated with the service. | Optional |
| end_ip | End of the IP range associated with the service. | Optional |
| fqdn | Fully Qualified Domain Name address. | Optional |
| tcpRange | Comma-separated list of TCP ports. Must be in the following template: {single} for example 5, {start}-{end} for example 1-50 or {start_source}-{end_source}:{start_destination}-{end_destinatinon} for example 1-3:6-9. | Optional |
| udpRange | Comma-separated list of TCP ports. Must be in the following template: {single} for example 5, {start}-{end} for example 1-50 or {start_source}-{end_source}:{start_destination}-{end_destinatinon} for example 1-3:6-9. | Optional |
| sctpRange | Comma-separated list of TCP ports. Must be in the following template: {single} for example 5, {start}-{end} for example 1-50 or {start_source}-{end_source}:{start_destination}-{end_destinatinon} for example 1-3:6-9. | Optional |
| icmp_type | Specifies the ICMP message type, defining the purpose or condition of the message. | Optional |
| icmp_code | Identifies the variant or additional information for the corresponding ICMP message type. | Optional |
| icmp_version | Determines the version of the Internet Control Message Protocol, either ICMP or ICMP6. Possible values are: ICMP, ICMP6. | Optional |
| ip_protocol | IP protocol number. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Fortigate.Service.Ports.SCTP | String | Multiple SCTP port ranges. |
| Fortigate.Service.Ports.UDP | String | Multiple UDP port ranges. |
| Fortigate.Service.Ports.TCP | String | Multiple TCP port ranges. |
| Fortigate.Service.FQDN | String | Fully Qualified Domain Name address. |
| Fortigate.Service.StartIP | String | Start of the IP range associated with the service. |
| Fortigate.Service.EndIP | String | End of the IP range associated with the service. |
| Fortigate.Service.ICMPCode | Number | ICMP code. |
| Fortigate.Service.ICMPType | Number | ICMP type. |
| Fortigate.Service.ProtocolNumber | Number | IP protocol number. |
| Fortigate.Service.Name | String | The service name. |
Command example
!fortigate-create-firewall-service serviceName=playbook-service tcpRange=1-2 udpRange=3-4 sctpRange=5-6
Context Example
{
"Fortigate": {
"Service": {
"Name": "playbook-service",
"Ports": {
"SCTP": "5-6",
"TCP": "1-2",
"UDP": "3-4"
}
}
}
}
Human Readable Output
The firewall service ‘playbook-service’ was successfully created
fortigate-update-firewall-service
Update firewall services. A service is the combination of network protocols and port numbers that define traffic sources or destinations. The command parameters can be used only in the following combinations: All-[vdom,name,comment,category], TCP/UDP/SCTP-[(start_ip,end_ip or fqdn),tcpRange,udpRange,sctpRange], IP-[ip_protocol], ICMP/ICMP6-[icmp_version,icmp_code,icmp_type].
Base Command
fortigate-update-firewall-service
Input
| Argument Name | Description | Required |
|---|---|---|
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
| name | Name of the service to update. Names can be retrieved with the command fortigate-list-firewall-services. |
Required |
| comment | A comment for the service. | Optional |
| category | Service category. | Optional |
| start_ip | Start of the IP range associated with the service. | Optional |
| end_ip | End of the IP range associated with the service. | Optional |
| fqdn | Fully Qualified Domain Name address. | Optional |
| tcpRange | Comma-separated list of TCP ports. Must be in the following template: {single} for example 5, {start}-{end} for example 1-50 or {start_source}-{end_source}:{start_destination}-{end_destinatinon} for example 1-3:6-9. | Optional |
| udpRange | Comma-separated list of TCP ports. Must be in the following template: {single} for example 5, {start}-{end} for example 1-50 or {start_source}-{end_source}:{start_destination}-{end_destinatinon} for example 1-3:6-9. | Optional |
| sctpRange | Comma-separated list of TCP ports. Must be in the following template: {single} for example 5, {start}-{end} for example 1-50 or {start_source}-{end_source}:{start_destination}-{end_destinatinon} for example 1-3:6-9. | Optional |
| action | Whether to add or remove destination and source ports from TCP/UDP/SCTP. Possible values are: add, remove. | Optional |
| icmp_type | Specifies the ICMP message type, defining the purpose or condition of the message. | Optional |
| icmp_code | Identifies the variant or additional information for the corresponding ICMP message type. | Optional |
| icmp_version | Determines the version of the Internet Control Message Protocol, either ICMPv4 or ICMPv6. Possible values are: icmp4, icmp6. | Optional |
| ip_protocol | IP protocol number. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Fortigate.Service.Ports.SCTP | String | Multiple SCTP port ranges. |
| Fortigate.Service.Ports.UDP | String | Multiple UDP port ranges. |
| Fortigate.Service.Ports.TCP | String | Multiple TCP port ranges. |
| Fortigate.Service.FQDN | String | Fully Qualified Domain Name address. |
| Fortigate.Service.IPRange | String | Start and end of the IP range associated with the service. |
| Fortigate.Service.ICMPCode | Number | ICMP code. |
| Fortigate.Service.ICMPType | Number | ICMP type. |
| Fortigate.Service.ProtocolNumber | Number | IP protocol number. |
| Fortigate.Service.Name | String | The service name. |
Command example
!fortigate-update-firewall-service name=playbook-service comment=helloworld
Context Example
{
"Fortigate": {
"Service": {
"Name": "playbook-service",
"Ports": {
"SCTP": "",
"TCP": "",
"UDP": ""
}
}
}
}
Human Readable Output
The firewall service ‘playbook-service’ was successfully updated
fortigate-delete-firewall-service
Delete firewall services. A service is the combination of network protocols and port numbers that define traffic sources or destinations.
Base Command
fortigate-delete-firewall-service
Input
| Argument Name | Description | Required |
|---|---|---|
| name | Name of the service to delete. Names can be retrieved with the command fortigate-list-firewall-services. |
Required |
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Fortigate.Service.Name | String | The name of the deleted service. |
| Fortigate.Service.Deleted | Boolean | Whether the service was deleted. |
Command example
!fortigate-delete-firewall-service name=playbook-service
Context Example
{
"Fortigate": {
"Service": {
"Deleted": true,
"Name": "playbook-service"
}
}
}
Human Readable Output
The firewall service ‘playbook-service’ was successfully deleted
fortigate-list-firewall-service-groups
Retrieve firewall service groups. Service groups are collections of predefined services. Service groups can be used as the source and destination of the policy.
Base Command
fortigate-list-firewall-service-groups
Input
| Argument Name | Description | Required |
|---|---|---|
| name | Name of a specific service group to return. | Optional |
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
| filter_field | Specifies the field to be searched, such as name or comment, to narrow down the search criteria within the objects. Fields must be written as they are in the raw_response. Reference to possible fields: https://docs.fortinet.com/document/fortigate/7.2.5/cli-reference/232620/config-firewall-service-group. |
Optional |
| filter_value | Indicates the value or partial value, for example Sales, that the API should look for within the specified field to find matching objects. |
Optional |
| format_fields | Comma-separated fields to format the API call to display certain information. Fields must be written as they are in the raw_response, for example: name or comment. Fields must be written as they are in the raw_response. Reference to possible fields: https://docs.fortinet.com/document/fortigate/7.2.5/cli-reference/232620/config-firewall-service-group. |
Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Fortigate.ServiceGroup.FabricObject | String | Security Fabric global object setting. Can be `enable` or `disable`. If `enable`, the object is set as a security fabric-wide global object, otherwise the object is local to this security fabric member. |
| Fortigate.ServiceGroup.Comment | String | The object`s comment. |
| Fortigate.ServiceGroup.Proxy | String | Enable/disable web proxy service. |
| Fortigate.ServiceGroup.Name | String | The service group name. |
| Frotigate.ServiceGroup.Member.Name | String | Service objects contained within the group. |
| Fortigate.ServiceGroup.VDOM | String | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. |
Command example
!fortigate-list-firewall-service-groups name=playbook-service-group
Context Example
{
"Fortigate": {
"ServiceGroup": {
"Comment": "",
"FabricObject": "disable",
"Member": {
"Name": [
"playbook-service-1"
]
},
"Name": "playbook-service-group",
"Proxy": "disable",
"VDOM": "root"
}
}
}
Human Readable Output
Firewall Service Groups
Name Members playbook-service-group playbook-service-1
fortigate-create-firewall-service-group
Create firewall service groups. Service groups are collections of predefined services. Service groups can be used as the source and destination of the policy.
Base Command
fortigate-create-firewall-service-group
Input
| Argument Name | Description | Required |
|---|---|---|
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
| name | Name of the service group to create. | Required |
| comment | A comment for the service group. | Optional |
| members | Comma-separated list of service and service group names. Names can be retrieved with the commands fortigate-list-firewall-services and fortigate-list-firewall-service-groups. |
Required |
Context Output
| Path | Type | Description |
|---|---|---|
| Fortigate.ServiceGroup.Name | String | The service group name. |
| Fortigate.ServiceGroup.Members | String | Service objects contained within the group. |
Command example
!fortigate-create-firewall-service-group name=playbook-service-group members=playbook-service-1
Context Example
{
"Fortigate": {
"ServiceGroup": {
"Members": "playbook-service-1",
"Name": "playbook-service-group"
}
}
}
Human Readable Output
The firewall service group ‘playbook-service-group’ was successfully created
fortigate-update-firewall-service-group
Update firewall service groups. Service groups are collections of predefined services. Service groups can be used as the source and destination of the policy. New members will override the existing members within the group incase of a conflict.
Base Command
fortigate-update-firewall-service-group
Input
| Argument Name | Description | Required |
|---|---|---|
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
| groupName | Name of the service group to update. Names can be retrieved with the command fortigate-list-firewall-service-groups. |
Required |
| comment | A comment for the service group. | Optional |
| serviceName | Comma-separated list of service and service group names. Names can be retrieved with the commands fortigate-list-firewall-services and fortigate-list-firewall-service-groups. |
Optional |
| action | Whether to add or remove members from the service group. Possible values are: add, remove. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Fortigate.ServiceGroup.Name | String | The service group name. |
| Fortigate.ServiceGroup.Service.Name | String | Service objects contained within the group. |
Command example
!fortigate-update-firewall-service-group groupName=playbook-service-group comment=helloworld
Context Example
{
"Fortigate": {
"ServiceGroup": {
"Name": "playbook-service-group",
"Service": {
"Name": [
"playbook-service-1"
]
}
}
}
}
Human Readable Output
The firewall service group ‘playbook-service-group’ was successfully updated
fortigate-delete-firewall-service-group
Delete firewall service groups. Service groups are collections of predefined services. Service groups can be used as the source and destination of the policy.
Base Command
fortigate-delete-firewall-service-group
Input
| Argument Name | Description | Required |
|---|---|---|
| groupName | Name of the service group to delete. Names can be retrieved with the command fortigate-list-firewall-service-groups. |
Required |
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Fortigate.ServiceGroup.Name | String | The name of the deleted service group. |
| Fortigate.ServiceGroup.Deleted | Boolean | Whether the service group was deleted. |
Command example
!fortigate-delete-firewall-service-group groupName=playbook-service-group
Context Example
{
"Fortigate": {
"ServiceGroup": {
"Deleted": true,
"Name": "playbook-service-group"
}
}
}
Human Readable Output
The firewall service group ‘playbook-service-group’ was successfully deleted
fortigate-list-firewall-policies
Retrieve firewall policies. Firewall policies dictate the traffic flow and its processing. They are integral to most of the firewall functions, ensuring that every piece of traffic passing through the unit adheres to a specific policy. These policies determine the direction of the traffic, processing method, and its permission to traverse the firewall.
Base Command
fortigate-list-firewall-policies
Input
| Argument Name | Description | Required |
|---|---|---|
| policyID | ID of a specific policy to return. | Optional |
| policyName | Name of a specific policy to return. | Optional |
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
| filter_field | Specifies the field to be searched, such as name or comment, to narrow down the search criteria within the objects. Fields must be written as they are in the raw_response. Reference to possible fields: https://docs.fortinet.com/document/fortigate/7.2.5/cli-reference/287620/config-firewall-policy. |
Optional |
| filter_value | Indicates the value or partial value, for example Sales, that the API should look for within the specified field to find matching objects. |
Optional |
| format_fields | Comma-separated fields to format the API call to display certain information. Fields must be written as they are in the raw_response, for example: name or comment. Reference to possible fields: https://docs.fortinet.com/document/fortigate/7.2.5/cli-reference/287620/config-firewall-policy. |
Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Fortigate.Policy.ServiceNegate | String | When enabled specifies what the service must not be. |
| Fortigate.Policy.Destination6Negate | String | When enabled, specifies what the destination IPv6 address must not be. |
| Fortigate.Policy.DestinationNegate | String | When enabled, specifies what the destination IPv4 address must not be. |
| Fortigate.Policy.Source6Negate | String | When enabled, specifies what the source IPv6 address must not be. |
| Fortigate.Policy.SourceNegate | String | When enabled, specifies what the source IPv4 address must not be. |
| Fortigate.Policy.NAT | String | Whether the source NAT is enabled or disabled. |
| Fortigate.Policy.LogStart | String | Whether recording logs when a session starts is enabled or disabled. |
| Fortigate.Policy.Log | String | All log sessions or security profile sessions. |
| Fortigate.Policy.Service | String | Service and service group names. |
| Fortigate.Policy.Source6 | String | Source IPv6 address name and address group names. |
| Fortigate.Policy.Destination6 | String | Destination IPv6 address name and address group names. |
| Fortigate.Policy.Destination | String | Destination IPv4 address and address group names. |
| Fortigate.Policy.Source | String | Source IPv4 address and address group names. |
| Fortigate.Policy.Action | String | Policy action (accept/deny/ipsec). |
| Fortigate.Policy.DestinationInterface | String | Outgoing (egress) interface. |
| Fortigate.Policy.SourceInterface | String | Incoming (ingress) interface. |
| Fortigate.Policy.UUID | String | Universally Unique Identifier. |
| Fortigate.Policy.Name | String | The policy name. |
| Fortigate.Policy.Status | String | Whether this policy is enabled or disabled. |
| Fortigate.Policy.ID | Number | The policy ID. |
| Fortigate.Policy.Description | String | The policy description. |
| Fortigate.Policy.Security | String | Policy attached security profile. |
| Fortigate.Policy.VDOM | String | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. |
| Fortigate.Policy.Schedule | String | The name of the schedule. |
Command example
!fortigate-list-firewall-policies policyName=playbook-policy-123456789
Context Example
{
"Fortigate": {
"Policy": {
"Action": "accept",
"Description": "",
"Destination": "playbook-address-ipv4-1",
"Destination6Negate": "disable",
"DestinationInterface": [
"port2"
],
"DestinationNegate": "disable",
"ID": 18,
"Log": "utm",
"LogStart": "disable",
"NAT": "enable",
"Name": "playbook-policy-123456789",
"Schedule": "always",
"Security": [
"no-inspection",
"default",
"single"
],
"Service": [
"playbook-service-1"
],
"ServiceNegate": "disable",
"Source": "playbook-address-ipv4-1",
"Source6Negate": "disable",
"SourceInterface": [
"port1"
],
"SourceNegate": "disable",
"Status": "enable",
"UUID": "cb72f302-aa22-51ee-eef0-cce9ba5b7ad3",
"VDOM": "root"
}
}
}
Human Readable Output
Firewall Policies
ID Name From To Source Destination Schedule Service Action NAT Security Profiles Log 18 playbook-policy-123456789 port1 port2 playbook-address-ipv4-1 playbook-address-ipv4-1 always playbook-service-1 accept enable no-inspection,
default,
singleutm
fortigate-create-firewall-policy
Create firewall policies. Firewall policies dictate the traffic flow and its processing. They are integral to most of the firewall functions, ensuring that every piece of traffic passing through the unit adheres to a specific policy. These policies determine the direction of the traffic, processing method, and its permission to traverse the firewall.
Base Command
fortigate-create-firewall-policy
Input
| Argument Name | Description | Required |
|---|---|---|
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
| policyName | Name of the policy to create. | Required |
| description | The policy description. | Optional |
| sourceIntf | Comma-separated list of incoming (ingress) interfaces. | Required |
| dstIntf | Comma-separated list of outgoing (egress) interfaces. | Required |
| source | Comma-separated list of source IPv4 address and address group names. Names can be retrieved with the commands fortigate-list-firewall-address-ipv4s, fortigate-list-firewall-address-ipv4-multicasts and fortigate-list-firewall-address-ipv4-groups. |
Optional |
| source6 | Comma-separated list of source IPv6 address name and address group names. Names can be retrieved with the commands fortigate-list-firewall-address-ipv6s, fortigate-list-firewall-address-ipv6-multicasts and fortigate-list-firewall-address-ipv6-groups. |
Optional |
| destination | Comma-separated list of destination IPv4 address and address group names. Names can be retrieved with the commands fortigate-list-firewall-address-ipv4s, fortigate-list-firewall-address-ipv4-multicasts and fortigate-list-firewall-address-ipv4-groups. |
Optional |
| destination6 | Comma-separated list of destination IPv6 address name and address group names. Names can be retrieved with the commands fortigate-list-firewall-address-ipv6s, fortigate-list-firewall-address-ipv6-multicasts and fortigate-list-firewall-address-ipv6-groups. |
Optional |
| negate_source_address | When enabled, the source address specifies what the source address must not be. Possible values are: enable, disable. | Optional |
| negate_destination_address | When enabled, the destination address specifies what the destination address must not be. Possible values are: enable, disable. | Optional |
| service | Comma-separated list of service and service group names. Names can be retrieved with the commands fortigate-list-firewall-services and fortigate-list-firewall-service-groups. |
Required |
| negate_service | When enabled, the service specifies what the service must not be. Possible values are: enable, disable. | Optional |
| action | Whether to accept or deny sessions that match the firewall policy. Possible values are: accept, block. | Required |
| status | Enable or disable this policy. Possible values are: enable, disable. Default is enable. | Optional |
| log | Enable or disable logging. Log all sessions or security profile sessions. Possible values are: all, utm, disable. Default is enable. | Optional |
| schedule | The schedule name. This is a time frame that is applied to the policy. Default is always. | Optional |
| nat | Enable/disable source Network Address Translation. Possible values are: enable, disable. Default is enable. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Fortigate.Policy.NAT | String | Whether the source NAT is enabled or disabled. |
| Fortigate.Policy.Log | String | All log sessions or security profile sessions. |
| Fortigate.Policy.Service | String | Service and service group names. |
| Fortigate.Policy.Source.Address6.name | String | Source IPv6 address name and address group names. |
| Fortigate.Policy.Destination.Address6.name | String | Destination IPv6 address name and address group names. |
| Fortigate.Policy.Destination.Address.name | String | Destination IPv4 address and address group names. |
| Fortigate.Policy.Source.Address.name | String | Source IPv4 address and address group names. |
| Fortigate.Policy.Action | String | Policy action (accept/deny/ipsec). |
| Fortigate.Policy.Destination.Interface | String | Outgoing (egress) interface. |
| Fortigate.Policy.Source.Interface | String | Incoming (ingress) interface. |
| Fortigate.Policy.Name | String | The policy name. |
| Fortigate.Policy.Status | String | Whether this policy is enabled or disabled. |
| Fortigate.Policy.Description | String | The policy description. |
Command example
!fortigate-create-firewall-policy policyName=playbook-policy sourceIntf=port1 dstIntf=port2 action=accept service=playbook-service-1 source=playbook-address-ipv4-1 destination=playbook-address-ipv4-2
Context Example
{
"Fortigate": {
"Policy": {
"Action": "accept",
"Description": null,
"Destination": {
"Address": [
{
"name": "playbook-address-ipv4-2"
}
],
"Address6": [
{
"name": ""
}
],
"Interface": "port2"
},
"Log": "enable",
"NAT": "enable",
"Name": "playbook-policy",
"Service": "playbook-service-1",
"Source": {
"Address": [
{
"name": "playbook-address-ipv4-1"
}
],
"Address6": [
{
"name": ""
}
],
"Interface": "port1"
},
"Status": "enable"
}
}
}
Human Readable Output
The firewall policy ‘playbook-policy’ was successfully created
fortigate-update-firewall-policy
Update firewall policies. Firewall policies dictate the traffic flow and its processing. They are integral to most of the firewall functions, ensuring that every piece of traffic passing through the unit adheres to a specific policy. These policies determine the direction of the traffic, processing method, and its permission to traverse the firewall.
Base Command
fortigate-update-firewall-policy
Input
| Argument Name | Description | Required |
|---|---|---|
| policyID | ID of the policy to update. IDs can be retrieved with the command fortigate-list-firewall-policies. |
Required |
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
| field | Field parameter to update. Possible values are: source_interface, destination_interface, description, status, source, destination, service, schedule, action, log, nat, source6, destination6, negate_source, negate_destination, negate_source6, negate_destination6, negate_service. | Required |
| value | Value of the field parameter to update. | Required |
| keep_original_data | Whether to keep the original data or not. Only relevant if the updated field is “source” or “destination”. If the supplied value is True, the current data will not be replaced. Instead, the supplied addresses will be added / removed from the existing data. Possible values are: true, false. |
Optional |
| add_or_remove | Whether to add or remove the supplied addresses from the existing data. Only relevant in case the field to update is “source” or “destination”, and keep_original_data is specified to True. Possible values are: add, remove. |
Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Fortigate.Policy.ServiceNegate | String | When enabled, specifies what the service must not be. |
| Fortigate.Policy.Destination6Negate | String | When enabled, specifies what the destination IPv6 address must not be. |
| Fortigate.Policy.DestinationNegate | String | When enabled, specifies what the destination IPv4 address must not be. |
| Fortigate.Policy.Source6Negate | String | When enabled, specifies what the source IPv6 address must not be. |
| Fortigate.Policy.SourceNegate | String | When enabled, specifies what the source IPv4 address must not be. |
| Fortigate.Policy.NAT | String | Whether the source NAT is enabled or disabled. |
| Fortigate.Policy.LogStart | String | Whether recording logs when a session starts is enabled or disabled. |
| Fortigate.Policy.Log | String | All log sessions or security profile sessions. |
| Fortigate.Policy.Service | String | Service and service group names. |
| Fortigate.Policy.Source6 | String | Source IPv6 address name and address group names. |
| Fortigate.Policy.Destination6 | String | Destination IPv6 address name and address group names. |
| Fortigate.Policy.Destination | String | Destination IPv4 address and address group names. |
| Fortigate.Policy.Source | String | Source IPv4 address and address group names. |
| Fortigate.Policy.Action | String | Policy action (accept/deny/ipsec). |
| Fortigate.Policy.DestinationInterface | String | Outgoing (egress) interface. |
| Fortigate.Policy.SourceInterface | String | Incoming (ingress) interface. |
| Fortigate.Policy.UUID | String | Universally Unique Identifier. |
| Fortigate.Policy.Name | String | The policy name. |
| Fortigate.Policy.Status | String | Whether this policy is enabled or disabled. |
| Fortigate.Policy.ID | Number | The policy ID. |
| Fortigate.Policy.Description | String | The policy description. |
| Fortigate.Policy.Security | String | Policy attached security profile. |
| Fortigate.Policy.Schedule | String | The name of the schedule. |
Command example
!fortigate-update-firewall-policy policyID=123456789 field=description value=helloworld
Context Example
{
"Fortigate": {
"Policy": {
"Action": "accept",
"Description": "helloworld",
"Destination": "playbook-address-ipv4-2",
"Destination6Negate": "disable",
"DestinationInterface": [
"port2"
],
"DestinationNegate": "disable",
"ID": 123456789,
"Log": "utm",
"LogStart": "disable",
"NAT": "enable",
"Name": "playbook-policy-222",
"Schedule": "always",
"Security": [
"no-inspection",
"default",
"single"
],
"Service": [
"playbook-service-1"
],
"ServiceNegate": "disable",
"Source": "playbook-address-ipv4-1",
"Source6Negate": "disable",
"SourceInterface": [
"port1"
],
"SourceNegate": "disable",
"Status": "enable",
"UUID": "8aaa8c5e-aa22-51ee-b28a-472e6447ac59"
}
}
}
Human Readable Output
The firewall policy ‘123456789’ was successfully updated
fortigate-move-firewall-policy
Move the position of firewall policies. Firewall policies dictate the traffic flow and its processing. They are integral to most of the firewall functions, ensuring that every piece of traffic passing through the unit adheres to a specific policy. These policies determine the direction of the traffic, processing method, and its permission to traverse the firewall.
Base Command
fortigate-move-firewall-policy
Input
| Argument Name | Description | Required |
|---|---|---|
| policyID | ID of the policy to move. IDs can be retrieved with the command fortigate-list-firewall-policies. |
Required |
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
| position | Whether to position the policy before or after its neighbor. Possible values are: before, after. | Required |
| neighbor | The ID of the neighbor policy. IDs can be retrieved with the command fortigate-list-firewall-policies. |
Required |
Context Output
| Path | Type | Description |
|---|---|---|
| Fortigate.Policy.ID | Number | The policy ID. |
| Fortigate.Policy.Moved | Boolean | Whether the policy was moved. |
Command example
!fortigate-move-firewall-policy policyID=123456789 position=after neighbor=1010101
Context Example
{
"Fortigate": {
"Policy": {
"ID": "123456789",
"Moved": true
}
}
}
Human Readable Output
The firewall policy ‘123456789’ was successfully moved
fortigate-delete-firewall-policy
Delete firewall policies. Firewall policies dictate the traffic flow and its processing. They are integral to most of the firewall functions, ensuring that every piece of traffic passing through the unit adheres to a specific policy. These policies determine the direction of the traffic, processing method, and its permission to traverse the firewall.
Base Command
fortigate-delete-firewall-policy
Input
| Argument Name | Description | Required |
|---|---|---|
| policyID | ID of the policy to delete. IDs can be retrieved with the command fortigate-list-firewall-policies. |
Required |
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Fortigate.Policy.ID | Number | The policy ID. |
| Fortigate.Policy.Deleted | Boolean | Whether the policy was deleted. |
Command example
!fortigate-delete-firewall-policy policyID=123456789
Context Example
{
"Fortigate": {
"Policy": {
"Deleted": true,
"ID": "123456789"
}
}
}
Human Readable Output
The firewall policy ‘123456789’ was successfully deleted
fortigate-list-system-vdoms
Retrieve system VDOMs. Virtual Domains (VDOMs) are used to divide a FortiGate into two or more virtual units that function independently. VDOMs can provide separate security policies and, in NAT mode, completely separate configurations for routing and VPN services for each connected network. Multiple VDOMs can be created and managed as independent units in multi VDOM mode.
Base Command
fortigate-list-system-vdoms
Input
| Argument Name | Description | Required |
|---|---|---|
| filter_field | Specifies the field to be searched, such as name or comment, to narrow down the search criteria within the objects. Fields must be written as they are in the raw_response. Reference to possible fields: https://docs.fortinet.com/document/fortigate/7.2.5/cli-reference/620/config-system-vdom. |
Optional |
| filter_value | Indicates the value or partial value, for example Sales, that the API should look for within the specified field to find matching objects. |
Optional |
| format_fields | Comma-separated fields to format the API call to display certain information. Fields must be written as they are in the raw_response, for example: name or comment. Reference to possible fields: https://docs.fortinet.com/document/fortigate/7.2.5/cli-reference/620/config-system-vdom. |
Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Fortigate.VDOM.VClusterID | Number | Virtual cluster ID. |
| Fortigate.VDOM.ShortName | String | The virtual domain short name. |
| Fortigate.VDOM.Name | String | The virtual domain name. |
Command example
#### Context Example
```json
{
"Fortigate": {
"VDOM": {
"Name": "root",
"ShortName": "root",
"VClusterID": 0,
"VDOM": "root"
}
}
}
Human Readable Output
Virtual Domains
Name ShortName VClusterID root root 0
fortigate-list-banned-ips
Retrieve Banned IPs. Banned IPs are IP addresses that have been quarantined for a variety of reasons, such as administrative decisions or due to security alerts from services like intrusion prevention systems (IPS), antivirus (AV), and denial-of-service (DoS) mitigation.
Base Command
fortigate-list-banned-ips
Input
| Argument Name | Description | Required |
|---|---|---|
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
| filter_field | Specifies the field to be searched, such as name or comment, to narrow down the search criteria within the objects. Fields must be written as they are in the raw_response. |
Optional |
| filter_value | Indicates the value or partial value, for example Sales, that the API should look for within the specified field to find matching objects. |
Optional |
| format_fields | Comma-separated fields to format the API call to display certain information. Fields must be written as they are in the raw_response, for example: name or comment. |
Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| Fortigate.BannedIP.IsV6 | Number | Whether the IP is IPv4 (0) or IPv6 (1). |
| Fortigate.BannedIP.Source | String | Source of the ban. |
| Fortigate.BannedIP.IP | String | The IPv4 address. |
| Fortigate.BannedIP.Created | Number | Date/time the IP address was added to the banned list. |
| Fortigate.BannedIP.Expires | Number | Date/time the IP address expires from the banned list. |
| Fortigate.BannedIP.VDOM | String | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. |
Command example
#### Context Example
```json
{
"Fortigate": {
"BannedIP": [
{
"Created": "2023-12-06 17:44:09",
"Expires": "1970-01-01 00:00:00",
"IP": "0.0.0.0",
"IsV6": 0,
"Source": "Administrative",
"VDOM": "root"
},
{
"Created": "2023-11-27 05:33:32",
"Expires": "1970-01-01 00:00:00",
"IP": "2.2.2.2",
"IsV6": 0,
"Source": "IPS",
"VDOM": "root"
},
{
"Created": "2023-11-27 05:33:41",
"Expires": "1970-01-01 00:00:00",
"IP": "3.3.3.3",
"IsV6": 0,
"Source": "AV",
"VDOM": "root"
},
{
"Created": "2023-11-27 05:33:49",
"Expires": "1970-01-01 00:00:00",
"IP": "4.4.4.4",
"IsV6": 0,
"Source": "DOS",
"VDOM": "root"
},
{
"Created": "2023-11-27 05:34:00",
"Expires": "1970-01-01 00:00:00",
"IP": "5.5.5.5",
"IsV6": 0,
"Source": "Administrative",
"VDOM": "root"
}
]
}
}
Human Readable Output
Banned IPs
IP IsV6 Created Expires Source 0.0.0.0 0 2023-12-06 17:44:09 1970-01-01 00:00:00 Administrative 2.2.2.2 0 2023-11-27 05:33:32 1970-01-01 00:00:00 IPS 3.3.3.3 0 2023-11-27 05:33:41 1970-01-01 00:00:00 AV 4.4.4.4 0 2023-11-27 05:33:49 1970-01-01 00:00:00 DOS 5.5.5.5 0 2023-11-27 05:34:00 1970-01-01 00:00:00 Administrative
fortigate-ban-ip
Ban IPs. Banned IPs are IP addresses that have been quarantined for a variety of reasons, such as administrative decisions or due to security alerts from services like intrusion prevention systems (IPS), antivirus (AV), and denial-of-service (DoS) mitigations.
Base Command
fortigate-ban-ip
Input
| Argument Name | Description | Required |
|---|---|---|
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
| ip_address | Comma-separated list of IPs to ban. Both IPv4 and IPv6 addresses are supported. | Required |
| expiry | Time until the ban expires in seconds. 0 for indefinite ban. Default is 0. |
Optional |
Context Output
There is no context output for this command.
Command example
!fortigate-ban-ip ip_address=0.0.0.0 expiry=0
Human Readable Output
The IPs ‘0.0.0.0’ were successfully banned
fortigate-unban-ip
Unban IPs. Banned IPs are IP addresses that have been quarantined for a variety of reasons, such as administrative decisions or due to security alerts from services like intrusion prevention systems (IPS), antivirus (AV), and denial-of-service (DoS) mitigations.
Base Command
fortigate-unban-ip
Input
| Argument Name | Description | Required |
|---|---|---|
| vdom | Virtual domains (VDOMs) enable you to partition and use your FortiGate unit as if it were multiple units. Use * to retrieve all virtual domains. VDOMs can be retrieved with the command fortigate-list-system-vdoms. Default is root. |
Optional |
| ip_address | Comma-separated list of IPs to unban. Both IPv4 and IPv6 addresses are supported. IPs can be retrieved with the command fortigate-list-banned-ips. |
Required |
Context Output
There is no context output for this command.
Command example
!fortigate-unban-ip ip_address=0.0.0.0
Human Readable Output
The IPs ‘0.0.0.0’ were successfully unbanned
Configuration parameters
server— Server URL (e.g. https://192.168.0.1) (required)credentials— Account usernameapi_key— API Keyunsecure— Trust any certificate (not secure)proxy— Use system proxy settings
Commands (58)
-
fortigate-ban-ipBan IPs. Banned IPs are IP addresses that have been quarantined for a variety of reasons, such as administrative decisions or due to security alerts from services like intrusion prevention systems (IPS), antivirus (AV), and denial-of-service (DoS) mitigations.
-
fortigate-create-addressDeprecatedDeprecated. Use `fortigate-create-firewall-address-ipv4` instead. Creates a new address object.
-
fortigate-create-address-groupDeprecatedDeprecated. Use `fortigate-create-firewall-address-ipv4-group` instead. Create an address group in FortiGate firewall.
-
fortigate-create-firewall-address-ipv4Create firewall IPv4 addresses. Addresses define sources and destinations of network traffic and can be used in many functions such as firewall policies, ZTNA, etc. The command parameters can be used only in the following combinations: All-[vdom,name,comment,associated_interface], Subnet-[address,mask,allow_routing], IP Range-[start_ip,end_ip], FQDN-[fqdn,allow_routing], Geography-[country], Device (Mac Address)-[mac_addresses].
-
fortigate-create-firewall-address-ipv4-groupCreate firewall IPv4 address groups. Address groups are designed for ease of use in the administration of the device.
-
fortigate-create-firewall-address-ipv4-multicastCreate firewall IPv4 multicast addresses. Multicasting allows a single source to send data to multiple receivers efficiently, conserving bandwidth and minimizing network traffic. It`s suitable for media streaming, news feeds, financial updates, and certain dynamic routing protocols like RIPv2, OSPF, and EIGRP.
-
fortigate-create-firewall-address-ipv6Create firewall IPv6 addresses. Addresses define sources and destinations of network traffic and can be used in many functions such as firewall policies, ZTNA, etc. The command parameters can be used only in the following combinations: All-[vdom,name,comment], Subnet-[address,mask], IP Range-[start_ip,end_ip], FQDN-[fqdn], Geography-[country], Fabric Connector Address-[sdn_connector], Device (Mac Address)-[mac_addresses].
-
fortigate-create-firewall-address-ipv6-groupCreate firewall IPv6 address groups. Address groups are designed for ease of use in the administration of the device.
-
fortigate-create-firewall-address-ipv6-multicastCreate firewall IPv6 multicast addresses. Multicasting allows a single source to send data to multiple receivers efficiently, conserving bandwidth and minimizing network traffic. It is suitable for media streaming, news feeds, financial updates, and certain dynamic routing protocols like RIPv2, OSPF, and EIGRP.
-
fortigate-create-firewall-policyCreate firewall policies. Firewall policies dictate the traffic flow and its processing. They are integral to most of the firewall functions, ensuring that every piece of traffic passing through the unit adheres to a specific policy. These policies determine the direction of the traffic, processing method, and its permission to traverse the firewall.
-
fortigate-create-firewall-serviceCreate firewall services. A service is the combination of network protocols and port numbers that define traffic sources or destinations. The command parameters can be used only in the following combinations: All-[vdom,name,comment,category], TCP/UDP/SCTP-[(start_ip,end_ip or fqdn),tcpRange,udpRange,sctpRange], IP-[ip_protocol], ICMP/ICMP6-[icmp_version,icmp_code,icmp_type].
-
fortigate-create-firewall-service-groupCreate firewall service groups. Service groups are collections of predefined services. Service groups can be used as the source and destination of the policy.
-
fortigate-create-policyDeprecatedDeprecated. Use `fortigate-create-firewall-policy` instead. Create a firewall policy (rule) on FortiGate.
-
fortigate-delete-addressDeprecatedDeprecated. Use `fortigate-delete-firewall-address-ipv4` instead. Deletes an address by name.
-
fortigate-delete-address-groupDeprecatedDeprecated. Use `fortigate-delete-firewall-address-ipv4-group` instead. Delete an address group from FortiGate firewall.
-
fortigate-delete-firewall-address-ipv4Delete firewall IPv4 addresses. Addresses define sources and destinations of network traffic and can be used in many functions such as firewall policies, ZTNA, etc.
-
fortigate-delete-firewall-address-ipv4-groupDelete firewall IPv4 address groups. Address groups are designed for ease of use in the administration of the device.
-
fortigate-delete-firewall-address-ipv4-multicastDelete firewall IPv4 multicast addresses. Multicasting allows a single source to send data to multiple receivers efficiently, conserving bandwidth and minimizing network traffic. It is suitable for media streaming, news feeds, financial updates, and certain dynamic routing protocols like RIPv2, OSPF, and EIGRP.
-
fortigate-delete-firewall-address-ipv6Delete firewall IPv6 addresses. Addresses define sources and destinations of network traffic and can be used in many functions such as firewall policies, ZTNA, etc.
-
fortigate-delete-firewall-address-ipv6-groupDelete firewall IPv6 address groups. Address groups are designed for ease of use in the administration of the device.
-
fortigate-delete-firewall-address-ipv6-multicastDelete firewall IPv6 multicast addresses. Multicasting allows a single source to send data to multiple receivers efficiently, conserving bandwidth and minimizing network traffic. It is suitable for media streaming, news feeds, financial updates, and certain dynamic routing protocols like RIPv2, OSPF, and EIGRP.
-
fortigate-delete-firewall-policyDelete firewall policies. Firewall policies dictate the traffic flow and its processing. They are integral to most of the firewall functions, ensuring that every piece of traffic passing through the unit adheres to a specific policy. These policies determine the direction of the traffic, processing method, and its permission to traverse the firewall.
-
fortigate-delete-firewall-serviceDelete firewall services. A service is the combination of network protocols and port numbers that define traffic sources or destinations.
-
fortigate-delete-firewall-service-groupDelete firewall service groups. Service groups are collections of predefined services. Service groups can be used as the source and destination of the policy.
-
fortigate-delete-policyDeprecatedDeprecated. Use `fortigate-delete-firewall-policy` instead. Delete a policy from FortiGate firewall.
-
fortigate-delete-service-groupDeprecatedDeprecated. Use `fortigate-delete-firewall-service-group` instead. Delete a service group from FortiGate.
-
fortigate-get-address-groupsDeprecatedDeprecated. Use `fortigate-list-firewall-address-ipv4-groups` instead. Get information about address groups from FortiGate.
-
fortigate-get-addressesDeprecatedDeprecated. Use `fortigate-list-firewall-address-ipv4s` instead. Get all address objects from your firewall.
-
fortigate-get-banned-ipsDeprecatedDeprecated. Use `fortigate-list-banned-ips` instead. Returns a list of banned IP addresses.
-
fortigate-get-firewall-serviceDeprecatedDeprecated. Use `fortigate-list-firewall-services` instead. Get information about a service from FortiGate Firewall.
-
fortigate-get-policyDeprecatedDeprecated. Use `fortigate-list-firewall-policies` instead. Get information about a firewall policy on FortiGate.
-
fortigate-get-service-groupsDeprecatedDeprecated. Use `fortigate-list-firewall-service-groups` instead. Get information about FortiGate service groups.
-
fortigate-list-banned-ipsRetrieve Banned IPs. Banned IPs are IP addresses that have been quarantined for a variety of reasons, such as administrative decisions or due to security alerts from services like intrusion prevention systems (IPS), antivirus (AV), and denial-of-service (DoS) mitigation.
-
fortigate-list-firewall-address-ipv4-groupsRetrieve firewall IPv4 address groups. Address groups are designed for ease of use in the administration of the device.
-
fortigate-list-firewall-address-ipv4-multicastsRetrieve firewall IPv4 multicast addresses. Multicasting allows a single source to send data to multiple receivers efficiently, conserving bandwidth and minimizing network traffic. It is suitable for media streaming, news feeds, financial updates, and certain dynamic routing protocols like RIPv2, OSPF, and EIGRP.
-
fortigate-list-firewall-address-ipv4sRetrieve firewall IPv4 addresses. Addresses define sources and destinations of network traffic and can be used in many functions such as firewall policies, ZTNA, etc.
-
fortigate-list-firewall-address-ipv6-groupsRetrieve firewall IPv6 address groups. Address groups are designed for ease of use in the administration of the device.
-
fortigate-list-firewall-address-ipv6-multicastsRetrieve firewall IPv6 multicast addresses. Multicasting allows a single source to send data to multiple receivers efficiently, conserving bandwidth and minimizing network traffic. It is suitable for media streaming, news feeds, financial updates, and certain dynamic routing protocols like RIPv2, OSPF, and EIGRP.
-
fortigate-list-firewall-address-ipv6sRetrieve firewall IPv6 addresses. Addresses define sources and destinations of network traffic and can be used in many functions such as firewall policies, ZTNA, etc.
-
fortigate-list-firewall-policiesRetrieve firewall policies. Firewall policies dictate the traffic flow and its processing. They are integral to most of the firewall functions, ensuring that every piece of traffic passing through the unit adheres to a specific policy. These policies determine the direction of the traffic, processing method, and its permission to traverse the firewall.
-
fortigate-list-firewall-service-groupsRetrieve firewall service groups. Service groups are collections of predefined services. Service groups can be used as the source and destination of the policy.
-
fortigate-list-firewall-servicesRetrieve firewall services. A service is the combination of network protocols and port numbers that define traffic sources or destinations.
-
fortigate-list-system-vdomsRetrieve system VDOMs. Virtual Domains (VDOMs) are used to divide a FortiGate into two or more virtual units that function independently. VDOMs can provide separate security policies and, in NAT mode, completely separate configurations for routing and VPN services for each connected network. Multiple VDOMs can be created and managed as independent units in multi VDOM mode.
-
fortigate-move-firewall-policyMove the position of firewall policies. Firewall policies dictate the traffic flow and its processing. They are integral to most of the firewall functions, ensuring that every piece of traffic passing through the unit adheres to a specific policy. These policies determine the direction of the traffic, processing method, and its permission to traverse the firewall.
-
fortigate-move-policyDeprecatedDeprecated. Use `fortigate-move-firewall-policy` instead. Move a firewall policy rule to a different position.
-
fortigate-unban-ipUnban IPs. Banned IPs are IP addresses that have been quarantined for a variety of reasons, such as administrative decisions or due to security alerts from services like intrusion prevention systems (IPS), antivirus (AV), and denial-of-service (DoS) mitigations.
-
fortigate-update-address-groupDeprecatedDeprecated. Use `fortigate-update-firewall-address-ipv4-group` instead. Update an address group on FortiGate firewall.
-
fortigate-update-firewall-address-ipv4Update firewall IPv4 addresses. Addresses define sources and destinations of network traffic and can be used in many functions such as firewall policies, ZTNA, etc. The command parameters can be used only in the following combinations: All-[vdom,name,comment,associated_interface,type], Subnet-[address,mask,allow_routing], IP Range-[start_ip,end_ip], FQDN-[fqdn,allow_routing], Geography-[country], Device (Mac Address)-[mac_addresses].
-
fortigate-update-firewall-address-ipv4-groupUpdate firewall IPv4 address groups. Address groups are designed for ease of use in the administration of the device. New members will override the existing members within the group incase of a conflict.
-
fortigate-update-firewall-address-ipv4-multicastUpdate firewall IPv4 multicast addresses. Multicasting allows a single source to send data to multiple receivers efficiently, conserving bandwidth and minimizing network traffic. It`s suitable for media streaming, news feeds, financial updates, and certain dynamic routing protocols like RIPv2, OSPF, and EIGRP.
-
fortigate-update-firewall-address-ipv6Update firewall IPv6 addresses. Addresses define sources and destinations of network traffic and can be used in many functions such as firewall policies, ZTNA, etc. The command parameters can be used only in the following combinations: All-[vdom,name,comment,associated_interface], Subnet-[address,mask], IP Range-[start_ip,end_ip], FQDN-[fqdn], Geography-[country], Fabric Connector Address-[sdn_connector], Device (Mac Address)-[mac_addresses].
-
fortigate-update-firewall-address-ipv6-groupUpdate firewall IPv6 address groups. Address groups are designed for ease of use in the administration of the device. New members will override the existing members within the group incase of a conflict.
-
fortigate-update-firewall-address-ipv6-multicastUpdate firewall IPv6 multicast addresses. Multicasting allows a single source to send data to multiple receivers efficiently, conserving bandwidth and minimizing network traffic. It is suitable for media streaming, news feeds, financial updates, and certain dynamic routing protocols like RIPv2, OSPF, and EIGRP.
-
fortigate-update-firewall-policyUpdate firewall policies. Firewall policies dictate the traffic flow and its processing. They are integral to most of the firewall functions, ensuring that every piece of traffic passing through the unit adheres to a specific policy. These policies determine the direction of the traffic, processing method, and its permission to traverse the firewall.
-
fortigate-update-firewall-serviceUpdate firewall services. A service is the combination of network protocols and port numbers that define traffic sources or destinations. The command parameters can be used only in the following combinations: All-[vdom,name,comment,category], TCP/UDP/SCTP-[(start_ip,end_ip or fqdn),tcpRange,udpRange,sctpRange], IP-[ip_protocol], ICMP/ICMP6-[icmp_version,icmp_code,icmp_type].
-
fortigate-update-firewall-service-groupUpdate firewall service groups. Service groups are collections of predefined services. Service groups can be used as the source and destination of the policy. New members will override the existing members within the group incase of a conflict.
-
fortigate-update-policyDeprecatedDeprecated. Use `fortigate-update-firewall-policy` instead. Update a firewall policy on FortiGate.
-
fortigate-update-service-groupDeprecatedDeprecated. Use `fortigate-update-firewall-service-group` instead. Update a FortiGate service group.
import json import os from collections.abc import Callable from typing import Any import CommonServerPython import FortiGate import pytest TEST_DATA = "test_data" BASE_URL = "https://www.example.com" API_URL = CommonServerPython.urljoin(BASE_URL, "api/v2") def load_mock_response(file_name: str) -> dict[str, Any]: """Load mock file that simulates an API response. Args: file_name (str): Name of the mock response JSON file to return. Returns: str: Mock file content. """ file_path = os.path.join(TEST_DATA, file_name) with open(file_path, encoding="utf-8") as mock_file: return json.loads(mock_file.read()) @pytest.fixture() def mock_client() -> FortiGate.Client: """ Establish a mock connection to the client with a username and password. Returns: Client: Mock connection to client. """ return FortiGate.Client( base_url=BASE_URL, username="Pokemon", password="Pikachu", ) @pytest.mark.parametrize( "args, include_ipv6, expected_result", [ ( {"address": "0.0.0.0", "mask": "0.0.0.0"}, False, "ipmask", ), ( {"start_ip": "0.0.0.0", "end_ip": "0.0.0.00"}, False, "iprange", ), ( {"fqdn": "example.com"}, False, "fqdn", ), ( {"country": "US"}, False, "geography", ), ( {"mac_addresses": ["00:00:00:00:00:00"]}, False, "mac", ), ( {"address": "0.0.0.0", "mask": "0.0.0.0", "allow_routing": True}, False, "ipmask", ), ( {"fqdn": "example.com", "allow_routing": True}, False, "fqdn", ), ( {"address": "0000:0000:0000:0000:0000:0000:0000:0000", "mask": "64"}, True, "ipprefix", ), ( {"sdn_connector": "connector_id"}, True, "dynamic", ), ], ) def test_get_address_type_success(args: dict[str, Any], include_ipv6: bool, expected_result: str): """ Scenario: - Test the get_address_type function's success handling for valid arguments. Given: - A dictionary of arguments that are complete and correctly isolated per group. When: - get_address_type is called with these arguments and the include_ipv6 flag. Then: - Ensure that the correct address type string is returned for each set of arguments. """ result = FortiGate.get_address_type(args, include_ipv6) assert result == expected_result @pytest.mark.parametrize( "args,error_message", [ ( {}, ( "No group of arguments was fully set. Please provide arguments from one of the following groups: " "['Subnet', 'IP Range', 'FQDN', 'Geography', 'Device (Mac Address)']" ), ), ( {"start_ip": "0.0.0.0"}, "Missing arguments for the group IP Range, please provide all: ['start_ip', 'end_ip']", ), ( {"address": "0.0.0.0", "fqdn": "example.com"}, "Arguments must only come from one group. Mixed groups: Subnet, FQDN", ), ], ) def test_get_address_type_error(args: dict[str, Any], error_message: str): """ Scenario: - Test the get_address_type function's error handling for invalid arguments. Given: - A dictionary of arguments that are incomplete or incorrectly combined. When: - No arguments provided. - Partial arguments from a group are provided. - Mixing between argument groups. Then: - Ensure that a DemistoException is raised with the correct error message. - Ensure that the actual error message matches the expected error message. """ with pytest.raises(CommonServerPython.DemistoException) as exc_info: FortiGate.get_address_type(args) assert str(exc_info.value) == error_message @pytest.mark.parametrize( "args, expected_result", [ ({"start_ip": "0.0.0.0", "end_ip": "0.0.0.0", "tcpRange": "80"}, FortiGate.TCP_UDP_SCTP), ({"tcpRange": "80"}, FortiGate.TCP_UDP_SCTP), ({"udpRange": "80"}, FortiGate.TCP_UDP_SCTP), ({"sctpRange": "80"}, FortiGate.TCP_UDP_SCTP), ({"ip_protocol": "6"}, FortiGate.IP), ({"icmp_version": "icmp", "icmp_type": "8", "icmp_code": "0"}, FortiGate.ICMP), ({"icmp_version": "icmp6", "icmp_type": "128", "icmp_code": "0"}, FortiGate.ICMP6), ], ) def test_get_service_type_success(args: dict[str, Any], expected_result: str): """ Scenario: - Test the get_service_type function's success handling for valid arguments. Given: - A dictionary of arguments that are complete and correctly isolated per protocol type. When: - get_service_type is called with these arguments. Then: - Ensure that the correct service type string is returned for each set of arguments. """ result = FortiGate.get_service_type(args) assert result == expected_result @pytest.mark.parametrize( "args, error_message", [ ( {}, ( "No protocol type arguments were fully set." " Please provide arguments from one of the following protocol types:" " ['TCP/UDP/SCTP', 'IP', 'ICMP/ICMP6']" ), ), ( {"start_ip": "0.0.0.0"}, ( "Missing arguments for the protocol type TCP/UDP/SCTP," " please provide at least one of: tcpRange, udpRange, sctpRange." ), ), ( {"icmp_type": "8"}, "Missing arguments for the protocol type ICMP/ICMP6, please provide: icmp_version", ), ( {"start_ip": "0.0.0.0", "ip_protocol": "6"}, "Arguments must only come from one protocol type. Mixed protocol types: IP, TCP/UDP/SCTP", ), ], ) def test_get_service_type_error(args: dict[str, Any], error_message: str): """ Scenario: - Test the get_service_type function's error handling for invalid arguments. Given: - A dictionary of arguments that are incomplete or incorrectly combined. When: - No arguments provided. - Partial arguments from a protocol type are provided. - Mixing between protocol type arguments. Then: - Ensure that a DemistoException is raised with the correct error message. - Ensure that the actual error message matches the expected error message. """ with pytest.raises(CommonServerPython.DemistoException) as exc_info: FortiGate.get_service_type(args) assert str(exc_info.value) == error_message @pytest.mark.parametrize( "mac_addresses", [ ["00:00:00:00:00:ZZ"], ["ZZ:ZZ:ZZ:ZZ:ZZ:ZZ"], ], ) def test_validate_mac_addresses_error(mac_addresses: list[str]): """ Scenario: - Test the validate_mac_addresses function's error handling for invalid MAC addresses. Given: - A list of invalid MAC addresses. When: - MAC addresses do not conform to the standard MAC address format. Then: - Ensure that a DemistoException is raised with a message indicating an invalid MAC address. - Ensure that the actual error message contains "Invalid MAC address". """ with pytest.raises(CommonServerPython.DemistoException) as exc_info: FortiGate.validate_mac_addresses(mac_addresses) assert "Invalid MAC address" in str(exc_info.value) @pytest.mark.parametrize( "ipv4_addresses", [ ("256.256.256.256"), # Invalid IPv4 address ], ) def test_validate_optional_ipv4_addresses_error(ipv4_addresses): """ Scenario: - Test the validate_optional_ipv4_addresses function's error handling for invalid IPv4 addresses. Given: - A list of invalid IPv4 addresses. When: - IPv4 addresses are not in the correct format or range. Then: - Ensure that a DemistoException is raised with a message indicating an invalid IPv4 address. - Ensure that the actual error message contains "Invalid IPv4 address". """ with pytest.raises(CommonServerPython.DemistoException) as exc_info: FortiGate.validate_optional_ipv4_addresses(ipv4_addresses) assert "Invalid IPv4 address" in str(exc_info.value) @pytest.mark.parametrize( "ipv6_networks", [("gggg:gggg:gggg:gggg:gggg:gggg:gggg:gggg")], ) def test_validate_optional_ipv6_networks_error(ipv6_networks: str): """ Scenario: - Test the validate_optional_ipv6_networks function's error handling for invalid IPv6 addresses. Given: - A list of invalid IPv6 addresses. When: - IPv6 addresses do not conform to the standard IPv6 format. Then: - Ensure that a DemistoException is raised with a message indicating an invalid IPv6 address. - Ensure that the actual error message contains "Invalid IPv6 address". """ with pytest.raises(CommonServerPython.DemistoException) as e_info: FortiGate.validate_optional_ipv6_networks(ipv6_networks) assert "Invalid IPv6 address" in str(e_info.value) @pytest.mark.parametrize( "mask", [129, -1], ) def test_validate_mask_error(mask: int): """ Scenario: - Test the validate_mask function's error handling for invalid mask values. Given: - Invalid mask values (either too large or negative). When: - Mask values are outside the valid range for subnet masks. Then: - Ensure that a DemistoException is raised with a message indicating an invalid mask. - Ensure that the actual error message contains "Invalid mask". """ with pytest.raises(CommonServerPython.DemistoException) as e_info: FortiGate.validate_mask(mask) assert "Invalid mask" in str(e_info.value) @pytest.mark.parametrize( "command,args,error_message", [ ( FortiGate.update_firewall_address_ipv4_group_command, {"address": "1"}, "`address` or `excluded_addresses` must be set with `action`.", ), ( FortiGate.update_firewall_address_ipv6_group_command, {"action": "add"}, "`members` must be set with `action`.", ), ], ) def test_update_group_errors( mock_client: FortiGate.Client, command: Callable[[FortiGate.Client, dict[str, Any]], CommonServerPython.CommandResults], args: dict[str, Any], error_message: str, ): """ Scenario: - Test the update group function's error handling for incorrect parameter combinations. Given: - A combination of parameters where 'action' or the group items are missing. When: - group items is provided but 'action' is missing, meaning an action must be specified for the input items. - 'action' is provided but group items is missing, meaning an action must be specified for the input items. Then: - Ensure that a DemistoException is raised with the correct error message. - Ensure that the actual error message matches the expected error message based on the given parameter. """ with pytest.raises(CommonServerPython.DemistoException) as exc_info: command(mock_client, args) assert str(exc_info.value) == error_message @pytest.mark.parametrize( "given,expected", [ ("camelCase", "camel-case"), ("PascalCase", "pascal-case"), ("snake_case", "snake-case"), ("kebab-case", "kebab-case"), ("CONSTANT_CASE", "constant-case"), ("Title Case", "title-case"), ], ) def test_to_kebab_case(given: str, expected: str): assert FortiGate.to_kebab_case(given) == expected @pytest.mark.parametrize( "build_table, items, expected_table", [ ( FortiGate.build_address_table, [ { "Name": "Router1", "AssociatedInterface": "eth0", "StartIP": "0.0.0.0", "EndIP": "0.0.0.0", } ], [ { "Name": "Router1", "Interface": "eth0", "Type": None, "Comments": None, "Routable": None, "Details": "0.0.0.0-0.0.0.0", } ], ), ( FortiGate.build_address_table, [ { "Country": "US", } ], [ { "Name": None, "Interface": None, "Type": None, "Comments": None, "Routable": None, "Details": "US", } ], ), ( FortiGate.build_address_table, [ {"FQDN": "example.com"}, {"MACAddresses": "00:00:00:00:00:00"}, ], [ { "Name": None, "Interface": None, "Type": None, "Comments": None, "Routable": None, "Details": "example.com", }, { "Name": None, "Interface": None, "Type": None, "Comments": None, "Routable": None, "Details": "00:00:00:00:00:00", }, ], ), ( FortiGate.build_address_group_table, [ { "Name": "Group1", "Type": "Type1", "Comment": "A sample group", "ExcludeMember": "Member1", "AllowRouting": True, "Member": {"Name": "MemberName1"}, } ], [ { "Name": "Group1", "Type": "Type1", "Comments": "A sample group", "Exclude Members": "Member1", "Routable": True, "Details": "MemberName1", } ], ), ( FortiGate.build_service_table, [ { "Name": "Service1", "Category": "Cat1", "Protocol": FortiGate.TCP_UDP_SCTP, "Ports": {"TCP": "80", "UDP": "53", "SCTP": "10000"}, "IPRange": "0.0.0.0-0.0.0.0", } ], [ { "Name": "Service1", "Category": "Cat1", "Protocol": FortiGate.TCP_UDP_SCTP, "Details": "TCP/80 UDP/53 SCTP/10000", "IP/FQDN": "0.0.0.0-0.0.0.0", } ], ), ( FortiGate.build_service_group_table, [ { "Name": "Group1", "Comment": "A sample group", "Member": {"Name": ["Member1", "Member2"]}, } ], [ { "Name": "Group1", "Comments": "A sample group", "Members": ["Member1", "Member2"], } ], ), ( FortiGate.build_policy_table, [ { "ID": "1", "Name": "Policy1", "SourceInterface": "Interface1", "DestinationInterface": "Interface2", "Schedule": "Always", "Service": "Web", "Action": "Allow", "NAT": "Enabled", "Security": "Profile1", "Log": "Enabled", "Source": "0.0.0.0", "Destination": "0.0.0.0", }, { "ID": "2", "Name": "Policy2", "SourceInterface": "Interface3", "DestinationInterface": "Interface4", "Schedule": "Night", "Service": "Email", "Action": "Deny", "NAT": "Disabled", "Security": "Profile2", "Log": "Disabled", "Source6": "0000::0", "Destination6": "0000::0", }, ], [ { "ID": "1", "Name": "Policy1", "From": "Interface1", "To": "Interface2", "Schedule": "Always", "Service": "Web", "Action": "Allow", "NAT": "Enabled", "Security Profiles": "Profile1", "Log": "Enabled", "Source": "0.0.0.0", "Destination": "0.0.0.0", }, { "ID": "2", "Name": "Policy2", "From": "Interface3", "To": "Interface4", "Schedule": "Night", "Service": "Email", "Action": "Deny", "NAT": "Disabled", "Security Profiles": "Profile2", "Log": "Disabled", "Source": "0000::0", "Destination": "0000::0", }, ], ), ], ) def test_build_table(build_table: Callable, items: dict[str, Any], expected_table: dict[str, Any]): """ Scenario: - Test the build table function's ability to correctly format data into a different tables. """ assert build_table(items) == expected_table @pytest.mark.parametrize( "item, expected_result", [ ({"Ports": {"TCP": "80 443", "UDP": "53", "SCTP": "10000"}}, "TCP/80 TCP/443 UDP/53 SCTP/10000"), ({"Ports": {}}, ""), ({"Ports": {"TCP": "22"}}, "TCP/22"), ], ) def test_handle_tcp_udp_sctp(item: dict[str, Any], expected_result: str): """Validates that the function correctly handles different combinations of TCP, UDP, and SCTP port ranges.""" assert FortiGate.handle_tcp_udp_sctp(item) == expected_result @pytest.mark.parametrize( "item, expected_result", [({"ProtocolNumber": 4}, "IP/4"), ({"ProtocolNumber": 0}, "Any"), ({}, "Any")], ) def test_handle_ip(item, expected_result): """Checks if the function correctly handles the IP protocol number.""" assert FortiGate.handle_ip(item) == expected_result @pytest.mark.parametrize( "item, expected_result", [ ({"Protocol": "ICMP", "ICMPType": 8, "ICMPCode": 1}, "ICMP/1"), ({"Protocol": "ICMP", "ICMPType": 8, "ICMPCode": 0}, "ICMP/ANY"), ({"Protocol": "ICMP6", "ICMPType": 128}, "ICMP6/ANY"), ({"Protocol": "ICMP"}, "ANY"), ({}, "ANY"), ], ) def test_handle_icmp_icmp6(item, expected_result): """Ensures that the function correctly processes ICMP and ICMP6 protocol types and codes.""" assert FortiGate.handle_icmp_icmp6(item) == expected_result def test_map_keys(): """ Test the map_keys function to ensure it correctly maps keys from an old dictionary to a new dictionary. """ old_dict = {"key1": "value1", "key2": {"subkey1": "subvalue1", "subkey2": "subvalue2"}} mappings = [ FortiGate.Mapping(old_keys=["key1"], new_keys=["newKey1"]), FortiGate.Mapping(old_keys=["key2", "subkey1"], new_keys=["newKey2", "newSubKey1"]), FortiGate.Mapping(old_keys=["nonexistentKey"], new_keys=["newKey3"], default_value="defaultValue"), FortiGate.Mapping( old_keys=["key2", "subkey2"], new_keys=["newKey2", "newSubKey2"], default_value=None, value_changer=lambda x: x.upper(), ), ] expected_result = { "newKey1": "value1", "newKey2": {"newSubKey1": "subvalue1", "newSubKey2": "SUBVALUE2"}, "newKey3": "defaultValue", } assert FortiGate.map_keys(old_dict, mappings) == expected_result @pytest.mark.parametrize( "input_items, action, current_items, expected_result", [ ( ["item3", "item4"], "add", ["item1", "item2"], ["item1", "item2", "item3", "item4"], ), ( ["item2", "item3"], "remove", ["item1", "item2", "item3"], ["item1"], ), ( ["item3"], None, ["item1", "item2"], ["item1", "item2"], ), ( ["item2", "item3"], "add", ["item1", "item2"], ["item1", "item2", "item3"], ), ], ) def test_handle_group_items_by_action(input_items, action, current_items, expected_result): """ Scenario: - Test adding or removing items from a group. Given: - A list of input items and a list of current items in the group. - An action specifying whether to add or remove items. When: - handle_group_items_by_action is invoked with different combinations of input items, actions, and current items. Then: - Ensure that the returned list of items is correct for each scenario. """ result = FortiGate.handle_group_items_by_action(input_items, action, current_items) assert set(result) == set(expected_result) @pytest.mark.parametrize( "obj, action, tcp_port_ranges, udp_port_ranges, sctp_port_ranges, expected_result", [ ( {"tcp-portrange": "80 443", "udp-portrange": "53", "sctp-portrange": "10000"}, "add", ["8080"], ["69"], ["12345"], { "tcp_port_ranges": ["80", "443", "8080"], "udp_port_ranges": ["53", "69"], "sctp_port_ranges": ["10000", "12345"], }, ), ( {"tcp-portrange": "80 443", "udp-portrange": "53", "sctp-portrange": "10000"}, "remove", ["443"], ["53"], ["10000"], {"tcp_port_ranges": ["80"], "udp_port_ranges": [], "sctp_port_ranges": []}, ), ( {}, "add", ["22"], ["123"], ["9999"], {"tcp_port_ranges": ["22"], "udp_port_ranges": ["123"], "sctp_port_ranges": ["9999"]}, ), ], ) def test_handle_action_for_port_ranges(obj, action, tcp_port_ranges, udp_port_ranges, sctp_port_ranges, expected_result): """Test the handle_action_for_port_ranges function with different actions and port ranges. Scenarios: - Adding new port ranges. - Removing existing port ranges. - Handling None action. - Handling empty initial port ranges. """ result = FortiGate.handle_action_for_port_ranges(obj, action, tcp_port_ranges, udp_port_ranges, sctp_port_ranges) for key in expected_result: assert set(result[key]) == set(expected_result[key]) @pytest.mark.parametrize( "list_command,response_file,outputs_file,endpoint_suffix,outputs_prefix,outputs_key_field", [ ( FortiGate.list_firewall_address_ipv4s_command, "address_ipv4_response.json", "address_ipv4_outputs.json", FortiGate.Client.ADDRESS_IPV4_ENDPOINT, FortiGate.ADDRESS_CONTEXT, "Name", ), ( FortiGate.list_firewall_address_ipv6s_command, "address_ipv6_response.json", "address_ipv6_outputs.json", FortiGate.Client.ADDRESS_IPV6_ENDPOINT, FortiGate.ADDRESS6_CONTEXT, "Name", ), ( FortiGate.list_firewall_address_ipv4_multicasts_command, "address_ipv4_multicast_response.json", "address_ipv4_multicast_outputs.json", FortiGate.Client.ADDRESS_IPV4_MULTICAST_ENDPOINT, FortiGate.ADDRESS_MULTICAST_CONTEXT, "Name", ), ( FortiGate.list_firewall_address_ipv6_multicasts_command, "address_ipv6_multicast_response.json", "address_ipv6_multicast_outputs.json", FortiGate.Client.ADDRESS_IPV6_MULTICAST_ENDPOINT, FortiGate.ADDRESS6_MULTICAST_CONTEXT, "Name", ), ( FortiGate.list_firewall_address_ipv4_groups_command, "address_ipv4_group_response.json", "address_ipv4_group_outputs.json", FortiGate.Client.ADDRESS_IPV4_GROUP_ENDPOINT, FortiGate.ADDRESS_GROUP_CONTEXT, "Name", ), ( FortiGate.list_firewall_address_ipv6_groups_command, "address_ipv6_group_response.json", "address_ipv6_group_outputs.json", FortiGate.Client.ADDRESS_IPV6_GROUP_ENDPOINT, FortiGate.ADDRESS6_GROUP_CONTEXT, "Name", ), ( FortiGate.list_firewall_services_command, "service_response.json", "service_outputs.json", FortiGate.Client.SERVICE_ENDPOINT, FortiGate.SERVICE_CONTEXT, "Name", ), ( FortiGate.list_firewall_service_groups_command, "service_group_response.json", "service_group_outputs.json", FortiGate.Client.SERVICE_GROUP_ENDPOINT, FortiGate.SERVICE_GROUP_CONTEXT, "Name", ), ( FortiGate.list_firewall_policies_command, "policy_response.json", "policy_outputs.json", FortiGate.Client.POLICY_ENDPOINT, FortiGate.POLICY_CONTEXT, "ID", ), ( FortiGate.list_system_vdoms_command, "vdom_response.json", "vdom_outputs.json", "cmdb/system/vdom", FortiGate.VDOM_CONTEXT, "Name", ), ( FortiGate.list_banned_ips_command, "banned_ip_response.json", "banned_ip_outputs.json", CommonServerPython.urljoin(FortiGate.Client.BANNED_IP_ENDPOINT, "select"), FortiGate.BANNED_IP_CONTEXT, "IP", ), ], ) def test_list_commands( requests_mock, mock_client: FortiGate.Client, list_command: Callable[[FortiGate.Client, dict[str, Any]], CommonServerPython.CommandResults], response_file: str, outputs_file: str, endpoint_suffix: str, outputs_prefix: str, outputs_key_field: str, ): """ Scenario: - Test retrieving a list of objects. Given: - vdom, filter_field, filter_value, format_fields. When: - list_firewall_address_ipv4s_command - list_firewall_address_ipv6s_command - list_firewall_address_ipv4_multicasts_command - list_firewall_address_ipv6_multicasts_command - list_firewall_address_ipv4_groups_command - list_firewall_address_ipv6_groups_command - list_firewall_services_command - list_firewall_service_groups_command - list_firewall_policies_command - list_system_vdoms_command - list_banned_ips_command Then: - Ensure that the CommandResults outputs is correct. - Ensure that the CommandResults raw_response is correct. - Ensure that the CommandResults outputs_prefix is correct. - Ensure that the CommandResults outputs_key_field is correct. """ args = { "vdom": "Pokemon", "filter_field": "Lior", "filter_value": "SB", "format_fields": ["I", "Choose", "You"], } response = load_mock_response(response_file) outputs = load_mock_response(outputs_file) requests_mock.get( url=CommonServerPython.urljoin(API_URL, endpoint_suffix), json=response, ) command_results = list_command(mock_client, args) assert command_results.outputs == outputs assert command_results.raw_response == response assert command_results.outputs_prefix == outputs_prefix assert command_results.outputs_key_field == outputs_key_field @pytest.mark.parametrize( "delete_command,identifier_field,endpoint_suffix,firewall_object,outputs_prefix,outputs_key_field", [ ( FortiGate.delete_firewall_address_ipv4_command, "name", FortiGate.Client.ADDRESS_IPV4_ENDPOINT, "address", FortiGate.ADDRESS_CONTEXT, "Name", ), ( FortiGate.delete_firewall_address_ipv6_command, "name", FortiGate.Client.ADDRESS_IPV6_ENDPOINT, "address", FortiGate.ADDRESS6_CONTEXT, "Name", ), ( FortiGate.delete_firewall_address_ipv4_multicast_command, "name", FortiGate.Client.ADDRESS_IPV4_MULTICAST_ENDPOINT, "address multicast IPv4", FortiGate.ADDRESS_MULTICAST_CONTEXT, "Name", ), ( FortiGate.delete_firewall_address_ipv6_multicast_command, "name", FortiGate.Client.ADDRESS_IPV6_MULTICAST_ENDPOINT, "address multicast IPv6", FortiGate.ADDRESS6_MULTICAST_CONTEXT, "Name", ), ( FortiGate.delete_firewall_address_ipv4_group_command, "name", FortiGate.Client.ADDRESS_IPV4_GROUP_ENDPOINT, "address IPv4 group", FortiGate.ADDRESS_GROUP_CONTEXT, "Name", ), ( FortiGate.delete_firewall_address_ipv6_group_command, "name", FortiGate.Client.ADDRESS_IPV6_GROUP_ENDPOINT, "address IPv6 group", FortiGate.ADDRESS6_GROUP_CONTEXT, "Name", ), ( FortiGate.delete_firewall_service_command, "name", FortiGate.Client.SERVICE_ENDPOINT, "service", FortiGate.SERVICE_CONTEXT, "Name", ), ( FortiGate.delete_firewall_service_group_command, "groupName", FortiGate.Client.SERVICE_GROUP_ENDPOINT, "service group", FortiGate.SERVICE_GROUP_CONTEXT, "Name", ), ( FortiGate.delete_firewall_policy_command, "policyID", FortiGate.Client.POLICY_ENDPOINT, "policy", FortiGate.POLICY_CONTEXT, "ID", ), ], ) def test_delete_commands( requests_mock, mock_client: FortiGate.Client, delete_command: Callable[[FortiGate.Client, dict[str, Any]], CommonServerPython.CommandResults], identifier_field: dict[str, Any], endpoint_suffix: str, firewall_object: str, outputs_prefix: str, outputs_key_field: str, ): """ Scenario: - Test delete an object. Given: - Identifier. When: - delete_firewall_address_ipv4_command - delete_firewall_address_ipv6_command - delete_firewall_address_ipv4_multicast_command - delete_firewall_address_ipv6_multicast_command - delete_firewall_address_ipv4_group_command - delete_firewall_address_ipv6_group_command - delete_firewall_service_command - delete_firewall_service_group_command Then: - Ensure that the CommandResults outputs is correct. - Ensure that the CommandResults readable_output is correct. - Ensure that the CommandResults raw_response is correct. - Ensure that the CommandResults outputs_prefix is correct. - Ensure that the CommandResults outputs_key_field is correct. """ args = {identifier_field: "pikachu"} response = load_mock_response("non_get_response.json") requests_mock.delete( url=CommonServerPython.urljoin( url=API_URL, suffix=CommonServerPython.urljoin(endpoint_suffix, args[identifier_field]), ), json=response, ) command_results = delete_command(mock_client, args) assert command_results.outputs == {outputs_key_field: args[identifier_field], "Deleted": True} assert ( command_results.readable_output == f"## The firewall {firewall_object} '{args[identifier_field]}' was successfully deleted." ) assert command_results.raw_response == response assert command_results.outputs_prefix == outputs_prefix assert command_results.outputs_key_field == outputs_key_field @pytest.mark.parametrize( "command,args,http_method,endpoint_suffix,action,outputs,outputs_prefix,firewall_object,return_value", [ ( FortiGate.create_firewall_address_ipv4_command, { "name": "Pikachu", "address": "0.0.0.0", "mask": "1.1.1.1", }, "POST", FortiGate.Client.ADDRESS_IPV4_ENDPOINT, "created", { "Name": "Pikachu", "IPAddress": "0.0.0.0", "Mask": "1.1.1.1", }, FortiGate.ADDRESS_CONTEXT, "address", None, ), ( FortiGate.update_firewall_address_ipv4_command, { "name": "Pikachu", "type": "Device (Mac Address)", "mac_addresses": "00:00:5e:00:53:af,00:B0:D0:63:C2:26,00:50:56:00:00:00-00:50:56:3F:FF:FF", }, "PUT", FortiGate.Client.ADDRESS_IPV4_ENDPOINT, "updated", { "Name": "Pikachu", "MAC": "00:00:5e:00:53:af,00:B0:D0:63:C2:26,00:50:56:00:00:00-00:50:56:3F:FF:FF", }, FortiGate.ADDRESS_CONTEXT, "address", {"type": "mac"}, ), ( FortiGate.create_firewall_address_ipv6_command, { "name": "Pikachu", "sdn_connector": "Lior", }, "POST", FortiGate.Client.ADDRESS_IPV6_ENDPOINT, "created", { "Name": "Pikachu", "SDN": "Lior", }, FortiGate.ADDRESS6_CONTEXT, "address", None, ), ( FortiGate.update_firewall_address_ipv6_command, { "name": "Pikachu", "address": "0000:0000::", "mask": "64", }, "PUT", FortiGate.Client.ADDRESS_IPV6_ENDPOINT, "updated", { "Name": "Pikachu", "IPAddress": "0000:0000::", "Mask": "64", }, FortiGate.ADDRESS6_CONTEXT, "address", {"type": "ipprefix"}, ), ( FortiGate.create_firewall_address_ipv4_multicast_command, { "name": "Pikachu", "type": "Broadcast Subnet", "first_ip": "0.0.0.0", "final_ip": "1.1.1.1", }, "POST", FortiGate.Client.ADDRESS_IPV4_MULTICAST_ENDPOINT, "created", { "Name": "Pikachu", "Type": "Broadcast Subnet", "FirstIP": "0.0.0.0", "FinalIP": "1.1.1.1", }, FortiGate.ADDRESS_MULTICAST_CONTEXT, "address multicast IPv4", None, ), ( FortiGate.update_firewall_address_ipv4_multicast_command, { "name": "Pikachu", "type": "Multicast IP Range", "first_ip": "0.0.0.0", "final_ip": "1.1.1.1", }, "PUT", FortiGate.Client.ADDRESS_IPV4_MULTICAST_ENDPOINT, "updated", { "Name": "Pikachu", "Type": "Multicast IP Range", "FirstIP": "0.0.0.0", "FinalIP": "1.1.1.1", }, FortiGate.ADDRESS_MULTICAST_CONTEXT, "address multicast IPv4", {"type": "multicastrange"}, ), ( FortiGate.create_firewall_address_ipv6_multicast_command, { "name": "Pikachu", "address": "0000:0000:0000:0000:0000:0000:0000:0000", "mask": "64", }, "POST", FortiGate.Client.ADDRESS_IPV6_MULTICAST_ENDPOINT, "created", { "Name": "Pikachu", "IPAddress": "0000:0000:0000:0000:0000:0000:0000:0000", "Mask": "64", }, FortiGate.ADDRESS6_MULTICAST_CONTEXT, "address multicast IPv6", None, ), ( FortiGate.update_firewall_address_ipv6_multicast_command, { "name": "Pikachu", "address": "0000:0000:0000:0000:0000:0000:0000:0000", "mask": "64", }, "PUT", FortiGate.Client.ADDRESS_IPV6_MULTICAST_ENDPOINT, "updated", { "Name": "Pikachu", "IPAddress": "0000:0000:0000:0000:0000:0000:0000:0000", "Mask": "64", }, FortiGate.ADDRESS6_MULTICAST_CONTEXT, "address multicast IPv6", None, ), ( FortiGate.create_firewall_address_ipv4_group_command, { "groupName": "Pikachu", "type": "group", "address": "pikachu,use,thunderbolt", "excluded_addresses": "pikachu,use,irontail", "allow_routing": "enable", }, "POST", FortiGate.Client.ADDRESS_IPV4_GROUP_ENDPOINT, "created", { "Name": "Pikachu", "Address": "pikachu,use,thunderbolt", }, FortiGate.ADDRESS_GROUP_CONTEXT, "address IPv4 group", None, ), ( FortiGate.create_firewall_address_ipv6_group_command, { "name": "Pikachu", "members": "pikachu,use,thunderbolt", }, "POST", FortiGate.Client.ADDRESS_IPV6_GROUP_ENDPOINT, "created", { "Name": "Pikachu", "Address": "pikachu,use,thunderbolt", }, FortiGate.ADDRESS6_GROUP_CONTEXT, "address IPv6 group", None, ), ( FortiGate.create_firewall_service_command, { "serviceName": "Pikachu", "category": "thunder", "tcpRange": "1-2", }, "POST", FortiGate.Client.SERVICE_ENDPOINT, "created", { "Name": "Pikachu", "Ports": { "TCP": "1-2", "UDP": "", "SCTP": "", }, }, FortiGate.SERVICE_CONTEXT, "service", None, ), ( FortiGate.update_firewall_service_command, { "name": "Pikachu", "category": "thunder", "tcpRange": "1-2", "action": "add", }, "PUT", FortiGate.Client.SERVICE_ENDPOINT, "updated", { "Name": "Pikachu", "Ports": { "TCP": "1-2", "UDP": "", "SCTP": "", }, }, FortiGate.SERVICE_CONTEXT, "service", { "protocol": FortiGate.TCP_UDP_SCTP, "tcp-portrange": "1-2 3-4", "udp-portrange": "1-2", }, ), ( FortiGate.create_firewall_service_group_command, { "name": "Pikachu", "members": "use,thunderbolt", }, "POST", FortiGate.Client.SERVICE_GROUP_ENDPOINT, "created", { "Name": "Pikachu", "Members": "use,thunderbolt", }, FortiGate.SERVICE_GROUP_CONTEXT, "service group", None, ), ( FortiGate.create_firewall_policy_command, { "policyName": "Pikachu", "sourceIntf": "use,thunderbolt", "dstIntf": "chikorita", "service": "mudkip", "source": "voltorb", "destination": "gengar", "action": "deny", }, "POST", FortiGate.Client.POLICY_ENDPOINT, "created", { "Name": "Pikachu", "Description": None, "Status": "enable", "Service": "mudkip", "Action": "deny", "Log": "enable", "Source": { "Interface": "use,thunderbolt", "Address": [{"name": "voltorb"}], "Address6": [{"name": ""}], }, "Destination": { "Interface": "chikorita", "Address": [{"name": "gengar"}], "Address6": [{"name": ""}], }, "NAT": "enable", }, FortiGate.POLICY_CONTEXT, "policy", None, ), ], ) def test_create_and_update_commands( requests_mock, mock_client: FortiGate.Client, command: Callable[[FortiGate.Client, dict[str, Any]], CommonServerPython.CommandResults], args: dict[str, Any], http_method: str, endpoint_suffix: str, action: str, outputs: dict[str, Any], outputs_prefix: str, firewall_object: str, return_value: str | None, ): """ Scenario: - Test create and update firewall address commands. Given: - arguments for creation or editing. When: - create_firewall_address_ipv4_command - update_firewall_address_ipv4_command - create_firewall_address_ipv6_command - update_firewall_address_ipv6_command - create_firewall_address_ipv4_multicast_command - update_firewall_address_ipv4_multicast_command - create_firewall_address_ipv6_multicast_command - update_firewall_address_ipv6_multicast_command - create_firewall_service_command - update_firewall_service_command - create_firewall_service_group_command - create_firewall_policy_command Then: - Ensure that the CommandResults outputs is correct. - Ensure that the CommandResults readable_output is correct. - Ensure that the CommandResults raw_response is correct. - Ensure that the CommandResults outputs_prefix is correct. - Ensure that the CommandResults outputs_key_field is correct. """ response = load_mock_response("non_get_response.json") endpoint = CommonServerPython.urljoin(API_URL, endpoint_suffix) is_post = http_method == "POST" identifier = next(iter(args.values())) # Mock the GET request to validate the given and API's type are the same. if not is_post and "multicast IPv6" not in firewall_object: requests_mock.get( url=CommonServerPython.urljoin(endpoint, identifier), json={"results": [return_value]}, ) requests_mock.request( method=http_method, url=endpoint if is_post else CommonServerPython.urljoin(endpoint, identifier), json=response, ) command_results = command(mock_client, args) assert command_results.readable_output == f"## The firewall {firewall_object} '{identifier}' was successfully {action}." assert command_results.raw_response == response assert command_results.outputs == outputs assert command_results.outputs_prefix == outputs_prefix assert command_results.outputs_key_field == "Name" @pytest.mark.parametrize( "command,args,endpoint_suffix,outputs,outputs_prefix,firewall_object,response1,response2", [ ( FortiGate.update_firewall_address_ipv4_group_command, { "groupName": "Pikachu", "address": "pikachu,use,thunderbolt", "excluded_addresses": "prepare,for,trouble", "allow_routing": "enable", "action": "remove", }, FortiGate.Client.ADDRESS_IPV4_GROUP_ENDPOINT, { "Name": "Pikachu", "Address": {"Name": ["go"]}, "UUID": "12345", }, FortiGate.ADDRESS_GROUP_CONTEXT, "address IPv4 group", { "results": [ { "member": [ {"name": "go"}, {"name": "pikachu"}, {"name": "use"}, {"name": "thunderbolt"}, ], "exclude-member": [ {"name": "prepare"}, {"name": "for"}, {"name": "double"}, {"name": "trouble"}, ], } ] }, { "results": [ { "uuid": "12345", "member": [{"name": "go"}], "exclude-member": [{"name": "double"}], } ] }, ), ( FortiGate.update_firewall_address_ipv6_group_command, { "name": "Pikachu", "members": "pikachu,use,thunderbolt", "action": "add", }, FortiGate.Client.ADDRESS_IPV6_GROUP_ENDPOINT, { "Name": "Pikachu", "Address": {"Name": ["go", "pikachu", "use", "thunderbolt"]}, }, FortiGate.ADDRESS6_GROUP_CONTEXT, "address IPv6 group", { "results": [ { "member": [ {"name": "go"}, {"name": "pikachu"}, {"name": "use"}, ], } ] }, { "results": [ { "member": [ {"name": "go"}, {"name": "pikachu"}, {"name": "use"}, {"name": "thunderbolt"}, ], } ] }, ), ( FortiGate.update_firewall_service_group_command, { "groupName": "Pikachu", "serviceName": "pikachu,use,thunderbolt", "action": "add", }, FortiGate.Client.SERVICE_GROUP_ENDPOINT, { "Name": "Pikachu", "Service": {"Name": ["go", "pikachu", "use", "thunderbolt"]}, }, FortiGate.SERVICE_GROUP_CONTEXT, "service group", { "results": [ { "member": [ {"name": "go"}, {"name": "pikachu"}, {"name": "use"}, ], } ] }, { "results": [ { "member": [ {"name": "go"}, {"name": "pikachu"}, {"name": "use"}, {"name": "thunderbolt"}, ], } ] }, ), ], ) def test_update_group_commands( requests_mock, mock_client: FortiGate.Client, command: Callable[[FortiGate.Client, dict[str, Any]], CommonServerPython.CommandResults], args: dict[str, Any], endpoint_suffix: str, outputs: dict[str, Any], outputs_prefix: str, firewall_object: str, response1: dict[str, Any], response2: dict[str, Any], ): """ Scenario: - Test update firewall group commands. Given: - arguments for editing. When: - update_firewall_address_ipv4_group_command - update_firewall_address_ipv6_group_command Then: - Ensure that the CommandResults outputs is correct. - Ensure that the CommandResults readable_output is correct. - Ensure that the CommandResults raw_response is correct. - Ensure that the CommandResults outputs_prefix is correct. - Ensure that the CommandResults outputs_key_field is correct. """ identifier = next(iter(args.values())) endpoint = CommonServerPython.urljoin(API_URL, f"{endpoint_suffix}/{identifier}") # Mock the GET request to fetch current items in group requests_mock.get( url=endpoint, json=response1, ) # Mock the PUT request to update the group requests_mock.put( url=endpoint, json={}, ) # Mock the GET request to fetch the updated group requests_mock.get( url=endpoint, json=response2, ) command_results = command(mock_client, args) assert command_results.readable_output == f"## The firewall {firewall_object} '{identifier}' was successfully updated." assert command_results.raw_response == response2 assert command_results.outputs == outputs assert command_results.outputs_prefix == outputs_prefix assert command_results.outputs_key_field == "Name" @pytest.mark.parametrize( "command,args,endpoint_suffix,action", [ ( FortiGate.ban_ip_command, {"ip_address": "0.0.0.0,0000:0000:0000:0000:0000:0000:0000:0000", "source": "ips"}, "add_users", "banned", ), ( FortiGate.unban_ip_command, {"ip_address": "0.0.0.0,0000:0000:0000:0000:0000:0000:0000:0000"}, "clear_users", "unbanned", ), ], ) def test_banned_ip_commands( requests_mock, mock_client: FortiGate.Client, command: Callable[[FortiGate.Client, dict[str, Any]], CommonServerPython.CommandResults], args: dict[str, Any], endpoint_suffix: str, action: str, ): """ Scenario: - Test banning and unbanning IP addresses Given: - IP addresses. When: - ban_ip_command - unban_IP_command Then: - Ensure that the CommandResults readable_output is correct. - Ensure that the CommandResults raw_response is correct. """ response = load_mock_response("non_get_response.json") endpoint = CommonServerPython.urljoin(API_URL, f"{FortiGate.Client.BANNED_IP_ENDPOINT}/{endpoint_suffix}") requests_mock.post( url=endpoint, json=response, ) command_results = command(mock_client, args) assert command_results.readable_output == f"## The IPs '{next(iter(args.values()))}' were successfully {action}." assert command_results.raw_response == response assert command_results.outputs_prefix == FortiGate.BANNED_IP_CONTEXT @pytest.mark.parametrize( "args, response, expected_error", [ ( {"name": "testService", "tcpRange": "80", "icmp_version": "icmp", "action": "remove"}, {"protocol": FortiGate.TCP_UDP_SCTP}, "Arguments must only come from one protocol type. Mixed protocol types: TCP/UDP/SCTP, ICMP/ICMP6", ), ( {"name": "testService", "action": "add"}, {}, f"'action' and '{FortiGate.TCP_UDP_SCTP}' must be set together.", ), ], ) def test_update_firewall_service_command_error( requests_mock, mock_client: FortiGate.Client, args: dict[str, Any], response: dict[str, Any], expected_error: str, ): """ Test the update_firewall_service_command function for failure scenarios. Scenarios: - Mismatch between input protocol type and API protocol type. - Action provided without TCP/UDP/SCTP parameters. """ requests_mock.get( url=CommonServerPython.urljoin(API_URL, f"{FortiGate.Client.SERVICE_ENDPOINT}/{args['name']}"), json=response, ) with pytest.raises(CommonServerPython.DemistoException) as exc_info: FortiGate.update_firewall_service_command(mock_client, args) assert str(exc_info.value) == expected_error def test_move_firewall_policy_command(requests_mock, mock_client: FortiGate.Client): """ Scenario: - Test move_firewall_policy_command. Given: - arguments for creation or editing. When: - move_firewall_policy_command is called Then: - Ensure that the CommandResults outputs is correct. - Ensure that the CommandResults readable_output is correct. - Ensure that the CommandResults raw_response is correct. - Ensure that the CommandResults outputs_prefix is correct. - Ensure that the CommandResults outputs_key_field is correct. """ args = { "policyID": "Pikachu", "position": "after", "neighbor": "1", } response = load_mock_response("non_get_response.json") requests_mock.put( url=CommonServerPython.urljoin(API_URL, f"{FortiGate.Client.POLICY_ENDPOINT}/{args['policyID']}"), json=response, ) command_results = FortiGate.move_firewall_policy_command(mock_client, args) assert command_results.readable_output == f"## The firewall policy '{args['policyID']}' was successfully moved." assert command_results.raw_response == response assert command_results.outputs == {"ID": "Pikachu", "Moved": True} assert command_results.outputs_prefix == FortiGate.POLICY_CONTEXT assert command_results.outputs_key_field == "ID" def test_update_firewall_policy_command(requests_mock, mock_client: FortiGate.Client): """ Scenario: - Test update_firewall_policy_command. Given: - arguments for creation or editing. When: - update_firewall_policy_command is called Then: - Ensure that the CommandResults outputs is correct. - Ensure that the CommandResults readable_output is correct. - Ensure that the CommandResults raw_response is correct. - Ensure that the CommandResults outputs_prefix is correct. - Ensure that the CommandResults outputs_key_field is correct. """ args = { "policyID": "2", "field": "service", "value": "boo", "keep_original_data": True, "add_or_remove": "add", } response = load_mock_response("policy_response.json") outputs = load_mock_response("policy_outputs.json")[0] response["results"] = [response["results"][0]] requests_mock.get( url=CommonServerPython.urljoin(API_URL, f"{FortiGate.Client.POLICY_ENDPOINT}/{args['policyID']}"), json=response, ) requests_mock.put( url=CommonServerPython.urljoin(API_URL, f"{FortiGate.Client.POLICY_ENDPOINT}/{args['policyID']}"), json={}, ) response["results"][0]["service"].append({"name": "boo"}) requests_mock.get( url=CommonServerPython.urljoin(API_URL, f"{FortiGate.Client.POLICY_ENDPOINT}/{args['policyID']}"), json=response, ) command_results = FortiGate.update_firewall_policy_command(mock_client, args) outputs["Service"].append("boo") outputs.pop("VDOM") assert command_results.readable_output == f"## The firewall policy '{args['policyID']}' was successfully updated." assert command_results.raw_response == response assert command_results.outputs == outputs assert command_results.outputs_prefix == FortiGate.POLICY_CONTEXT assert command_results.outputs_key_field == "ID" def test_update_firewall_policy_command_error(mock_client: FortiGate.Client): """ Test the update_firewall_policy_command function for failure scenarios. Scenarios: - If 'keep_original_data' is set to True, but 'add_or_remove' isn't set. Then: - Ensure that the error message is the same. """ with pytest.raises(CommonServerPython.DemistoException) as exc_info: FortiGate.update_firewall_policy_command(mock_client, {"keep_original_data": "true"}) assert str(exc_info.value) == "If 'keep_original_data' is set to True, 'add_or_remove' must also be set." def test_list_firewall_policies_return_all_policy_name(mock_client: FortiGate.Client, requests_mock): """ Given: Args to run list_firewall_policies command with policyName to filter by which does not match any policy. When: Running list_firewall_policies command. Then: Validate no results are returned. """ args = { "vdom": "Pokemon", "filter_field": "Lior", "filter_value": "SB", "format_fields": ["I", "Choose", "You"], "policyName": "Non-exist-policy", } response = load_mock_response("policy_response.json") requests_mock.get( url=CommonServerPython.urljoin(API_URL, FortiGate.Client.POLICY_ENDPOINT), json=response, ) command_results = FortiGate.list_firewall_policies_command(mock_client, args) assert len(command_results.outputs) == 0