Skip to main content

Zone Protection Profile Models

Overview

The Zone Protection Profile models provide a structured way to represent and validate zone protection profile configuration data for Palo Alto Networks' Strata Cloud Manager. These models ensure data integrity when creating and updating zone protection profiles, enforcing proper flood protection, scan protection, protocol filtering, and field validations.

Models

The module provides the following Pydantic models:

  • ZoneProtectionProfileBaseModel: Base model with fields common to all zone protection profile operations
  • ZoneProtectionProfileCreateModel: Model for creating new zone protection profiles
  • ZoneProtectionProfileUpdateModel: Model for updating existing zone protection profiles
  • ZoneProtectionProfileResponseModel: Response model for zone protection profile operations
  • FloodProtection: Flood protection configuration model
  • FloodRed: Random Early Detection (RED) configuration model
  • FloodSynCookies: SYN Cookies configuration model for TCP SYN flood protection
  • TcpSynFlood: TCP SYN flood protection configuration model
  • UdpFlood: UDP flood protection configuration model
  • SctpInitFlood: SCTP INIT flood protection configuration model
  • IcmpFlood: ICMP flood protection configuration model
  • Icmpv6Flood: ICMPv6 flood protection configuration model
  • OtherIpFlood: Other IP flood protection configuration model
  • ScanEntry: Scan protection entry configuration model
  • ScanAction: Scan action configuration model
  • ScanActionBlockIp: Block IP action configuration model for scan protection
  • ScanWhiteListEntry: Scan whitelist entry configuration model
  • NonIpProtocol: Non-IP protocol configuration model
  • NonIpProtocolEntry: Non-IP protocol entry configuration model
  • L2SecGroupTagProtection: Layer 2 Security Group Tag protection configuration model
  • SgtEntry: Security Group Tag entry configuration model

The ZoneProtectionProfileBaseModel and ZoneProtectionProfileCreateModel / ZoneProtectionProfileUpdateModel use extra="forbid" configuration, which rejects any fields not explicitly defined in the model. The ZoneProtectionProfileResponseModel uses extra="ignore" to provide resilience against unexpected fields returned by the API.

Model Attributes

ZoneProtectionProfileBaseModel

This is the base model containing fields common to all zone protection profile operations.

AttributeTypeRequiredDefaultDescription
namestrYesNoneName of the profile. Max 31 chars.
descriptionstrNoNoneDescription of the profile. Max 255 chars.
floodFloodProtectionNoNoneFlood protection configuration.
scanList[ScanEntry]NoNoneScan protection entries.
scan_white_listList[ScanWhiteListEntry]NoNoneScan whitelist entries.
spoofed_ip_discardboolNoNoneDiscard spoofed IP packets.
strict_ip_checkboolNoNoneEnable strict IP address checking.
fragmented_traffic_discardboolNoNoneDiscard fragmented traffic.
strict_source_routing_discardboolNoNoneDiscard strict source routing packets.
loose_source_routing_discardboolNoNoneDiscard loose source routing packets.
timestamp_discardboolNoNoneDiscard timestamp option packets.
record_route_discardboolNoNoneDiscard record route option packets.
security_discardboolNoNoneDiscard security option packets.
stream_id_discardboolNoNoneDiscard stream ID option packets.
unknown_option_discardboolNoNoneDiscard unknown option packets.
malformed_option_discardboolNoNoneDiscard malformed option packets.
mismatched_overlapping_tcp_segment_discardboolNoNoneDiscard mismatched overlapping TCP segments.
tcp_handshake_discardboolNoNoneDiscard incomplete TCP handshake packets.
tcp_syn_with_data_discardboolNoNoneDiscard TCP SYN packets with data.
tcp_synack_with_data_discardboolNoNoneDiscard TCP SYN-ACK packets with data.
reject_non_syn_tcpstrNoNoneReject non-SYN TCP. Pattern: ^(global|yes|no)$.
asymmetric_pathstrNoNoneAsymmetric path handling. Pattern: ^(global|drop|bypass)$.
mptcp_option_stripstrNoNoneMPTCP option strip. Pattern: ^(no|yes|global)$.
tcp_timestamp_stripboolNoNoneStrip TCP timestamp option.
tcp_fast_open_and_data_stripboolNoNoneStrip TCP Fast Open and data.
icmp_ping_zero_id_discardboolNoNoneDiscard ICMP ping with zero ID.
icmp_frag_discardboolNoNoneDiscard fragmented ICMP packets.
icmp_large_packet_discardboolNoNoneDiscard large ICMP packets.
discard_icmp_embedded_errorboolNoNoneDiscard ICMP embedded error messages.
suppress_icmp_timeexceededboolNoNoneSuppress ICMP time exceeded messages.
suppress_icmp_needfragboolNoNoneSuppress ICMP need fragmentation messages.
ipv6Dict[str, Any]NoNoneIPv6 protection configuration.
non_ip_protocolNonIpProtocolNoNoneNon-IP protocol configuration.
l2_sec_group_tag_protectionL2SecGroupTagProtectionNoNoneLayer 2 Security Group Tag protection.
folderstrNo**NoneFolder location. Pattern: ^[a-zA-Z\d\-_. ]+$. Max 64 chars.
snippetstrNo**NoneSnippet location. Pattern: ^[a-zA-Z\d\-_. ]+$. Max 64 chars.
devicestrNo**NoneDevice location. Pattern: ^[a-zA-Z\d\-_. ]+$. Max 64 chars.

** Exactly one container (folder/snippet/device) must be provided for create operations

ZoneProtectionProfileCreateModel

Inherits all fields from ZoneProtectionProfileBaseModel and enforces that exactly one of folder, snippet, or device is provided during creation.

ZoneProtectionProfileUpdateModel

Extends ZoneProtectionProfileBaseModel by adding:

AttributeTypeRequiredDefaultDescription
idUUIDYesNoneThe unique identifier of the zone protection profile

ZoneProtectionProfileResponseModel

Extends ZoneProtectionProfileBaseModel by adding:

AttributeTypeRequiredDefaultDescription
idUUIDYesNoneThe unique identifier of the zone protection profile
note

The ZoneProtectionProfileResponseModel uses extra="ignore" instead of extra="forbid". This means it will silently ignore any extra fields returned by the API that are not defined in the model, providing resilience against API changes.

Supporting Models

FloodProtection

This model defines the top-level flood protection configuration.

AttributeTypeRequiredDefaultDescription
tcp_synTcpSynFloodNoNoneTCP SYN flood protection.
udpUdpFloodNoNoneUDP flood protection.
sctp_initSctpInitFloodNoNoneSCTP INIT flood protection.
icmpIcmpFloodNoNoneICMP flood protection.
icmpv6Icmpv6FloodNoNoneICMPv6 flood protection.
other_ipOtherIpFloodNoNoneOther IP flood protection.

FloodRed

Random Early Detection (RED) configuration shared by multiple flood protection types.

AttributeTypeRequiredDefaultDescription
alarm_rateintNoNoneAlarm rate threshold. Range: 0-2000000.
activate_rateintNoNoneActivate rate threshold. Range: 0-2000000.
maximal_rateintNoNoneMaximal rate threshold. Range: 0-2000000.
Rate Ordering

When all three rate fields are set, they must satisfy alarm_rate <= activate_rate <= maximal_rate.

FloodSynCookies

SYN Cookies configuration for TCP SYN flood protection.

AttributeTypeRequiredDefaultDescription
alarm_rateintNoNoneAlarm rate threshold. Range: 0-2000000.
activate_rateintNoNoneActivate rate threshold. Range: 0-2000000.
maximal_rateintNoNoneMaximal rate threshold. Range: 0-2000000.
Rate Ordering

When all three rate fields are set, they must satisfy alarm_rate <= activate_rate <= maximal_rate.

TcpSynFlood

TCP SYN flood protection configuration. Supports either RED or SYN Cookies mode, but not both.

AttributeTypeRequiredDefaultDescription
enableboolNoNoneEnable TCP SYN flood protection.
redFloodRedNo*NoneRandom Early Detection configuration.
syn_cookiesFloodSynCookiesNo*NoneSYN Cookies configuration.

* red and syn_cookies are mutually exclusive. Only one may be set at a time.

UdpFlood

UDP flood protection configuration.

AttributeTypeRequiredDefaultDescription
enableboolNoNoneEnable UDP flood protection.
redFloodRedNoNoneRandom Early Detection configuration.

SctpInitFlood

SCTP INIT flood protection configuration.

AttributeTypeRequiredDefaultDescription
enableboolNoNoneEnable SCTP INIT flood protection.
redFloodRedNoNoneRandom Early Detection configuration.

IcmpFlood

ICMP flood protection configuration.

AttributeTypeRequiredDefaultDescription
enableboolNoNoneEnable ICMP flood protection.
redFloodRedNoNoneRandom Early Detection configuration.

Icmpv6Flood

ICMPv6 flood protection configuration.

AttributeTypeRequiredDefaultDescription
enableboolNoNoneEnable ICMPv6 flood protection.
redFloodRedNoNoneRandom Early Detection configuration.

OtherIpFlood

Other IP flood protection configuration.

AttributeTypeRequiredDefaultDescription
enableboolNoNoneEnable other IP flood protection.
redFloodRedNoNoneRandom Early Detection configuration.

ScanEntry

Scan protection entry configuration.

AttributeTypeRequiredDefaultDescription
namestrYesNoneScan entry name. Pattern: ^(8001|8002|8003|8006)$.
actionScanActionNoNoneScan action configuration.
intervalintNoNoneScan interval. Range: 2-65535.
thresholdintNoNoneScan threshold. Range: 2-65535.

ScanAction

Scan action configuration. Exactly one action must be specified.

AttributeTypeRequiredDefaultDescription
allowDict[str, Any]No*NoneAllow action.
alertDict[str, Any]No*NoneAlert action.
blockDict[str, Any]No*NoneBlock action.
block_ipScanActionBlockIpNo*NoneBlock IP action.

* Exactly one of allow, alert, block, or block_ip must be set.

ScanActionBlockIp

Block IP action configuration for scan protection.

AttributeTypeRequiredDefaultDescription
track_bystrYesNoneTrack by method. Pattern: ^(source|source-and-destination)$.
durationintYesNoneBlock duration in seconds. Range: 1-3600.

ScanWhiteListEntry

Scan whitelist entry configuration.

AttributeTypeRequiredDefaultDescription
namestrYesNoneWhitelist entry name.
ipv4strNoNoneIPv4 address.
ipv6strNoNoneIPv6 address.

NonIpProtocol

Non-IP protocol configuration.

AttributeTypeRequiredDefaultDescription
list_typestrNoNoneList type. Pattern: ^(exclude|include)$.
protocolList[NonIpProtocolEntry]NoNoneProtocol entries.

NonIpProtocolEntry

Non-IP protocol entry configuration.

AttributeTypeRequiredDefaultDescription
namestrYesNoneProtocol entry name.
ether_typestrYesNoneEthernet type.
enableboolNoNoneEnable this protocol entry.

L2SecGroupTagProtection

Layer 2 Security Group Tag protection configuration.

AttributeTypeRequiredDefaultDescription
tagsList[SgtEntry]NoNoneSecurity Group Tag entries.

SgtEntry

Security Group Tag entry configuration.

AttributeTypeRequiredDefaultDescription
namestrYesNoneSGT entry name.
tagstrYesNoneSecurity group tag value.
enableboolNoNoneEnable this SGT entry.

Exceptions

The models perform strict validation and will raise ValueError in scenarios such as:

  • When creating a zone protection profile (ZoneProtectionProfileCreateModel), if not exactly one container (folder, snippet, or device) is provided.
  • When both red and syn_cookies are configured in a TcpSynFlood model (they are mutually exclusive).
  • When a ScanAction does not have exactly one action set (must have exactly one of allow, alert, block, or block_ip).
  • When the profile name exceeds the maximum length.
  • When container identifiers (folder, snippet, device) do not match the required pattern or exceed the maximum length.

Model Validators

Rate Ordering Validators

FloodRed and FloodSynCookies enforce rate ordering when all three rate fields are set:

  • validate_rate_ordering: Ensures that alarm_rate <= activate_rate <= maximal_rate. If any rate field is None, the validation is skipped. This matches the SCM API's server-side validation.

Field Validators in TcpSynFlood

  • validate_red_syn_cookies_mutual_exclusivity: Ensures that red and syn_cookies are mutually exclusive. If both are set, it raises a ValueError. Only one flood mitigation strategy can be active for TCP SYN flood protection at a time.

Field Validators in ScanAction

  • validate_exactly_one_action: Ensures that exactly one action is configured. If zero or more than one of allow, alert, block, or block_ip is set, it raises a ValueError.

Container Validation in ZoneProtectionProfileCreateModel

  • validate_container_type: After model initialization, this validator checks that exactly one of the container fields (folder, snippet, or device) is provided. If not, it raises a ValueError.

Usage Examples

Creating a Zone Protection Profile

Using a Dictionary with Flood Protection

from scm.models.network import ZoneProtectionProfileCreateModel

profile_data = {
"name": "zone-protect-1",
"description": "Standard zone protection profile",
"flood": {
"tcp_syn": {
"enable": True,
"red": {
"alarm_rate": 10000,
"activate_rate": 20000,
"maximal_rate": 40000
}
},
"udp": {
"enable": True,
"red": {
"alarm_rate": 10000,
"activate_rate": 20000,
"maximal_rate": 40000
}
},
"icmp": {
"enable": True,
"red": {
"alarm_rate": 10000,
"activate_rate": 20000,
"maximal_rate": 40000
}
}
},
"spoofed_ip_discard": True,
"strict_ip_check": True,
"folder": "Network Profiles"
}

# Validate and create model instance
profile = ZoneProtectionProfileCreateModel(**profile_data)
payload = profile.model_dump(exclude_unset=True, by_alias=True)
print(payload)

Using the Model Directly with Scan Protection

from scm.models.network import (
ZoneProtectionProfileCreateModel,
ScanEntry,
ScanAction,
ScanActionBlockIp,
)

# Create scan entries
scan_entries = [
ScanEntry(
name="8001",
action=ScanAction(
block_ip=ScanActionBlockIp(
track_by="source",
duration=300
)
),
interval=10,
threshold=100,
),
ScanEntry(
name="8002",
action=ScanAction(alert={}),
interval=10,
threshold=100,
),
]

# Create zone protection profile
profile = ZoneProtectionProfileCreateModel(
name="scan-protect-1",
description="Profile with scan protection",
scan=scan_entries,
spoofed_ip_discard=True,
folder="Network Profiles"
)
payload = profile.model_dump(exclude_unset=True, by_alias=True)
print(payload)

Updating a Zone Protection Profile

from scm.client import Scm

# Initialize client
client = Scm(
client_id="your_client_id",
client_secret="your_client_secret",
tsg_id="your_tsg_id"
)

# Fetch existing profile
existing = client.zone_protection_profile.fetch(
name="zone-protect-1",
folder="Network Profiles"
)

# Modify attributes using dot notation
existing.spoofed_ip_discard = True
existing.strict_ip_check = True
existing.fragmented_traffic_discard = True

# Pass modified object to update()
updated = client.zone_protection_profile.update(existing)
print(f"Updated profile: {updated.name}")

Creating a Profile with TCP SYN Cookies

from scm.models.network import (
ZoneProtectionProfileCreateModel,
FloodProtection,
TcpSynFlood,
FloodSynCookies,
)

# Create flood protection with SYN Cookies instead of RED
flood = FloodProtection(
tcp_syn=TcpSynFlood(
enable=True,
syn_cookies=FloodSynCookies(
alarm_rate=10000,
activate_rate=20000,
maximal_rate=40000
)
)
)

profile = ZoneProtectionProfileCreateModel(
name="syn-cookies-profile",
description="Profile using SYN Cookies for TCP SYN flood protection",
flood=flood,
folder="Network Profiles"
)
payload = profile.model_dump(exclude_unset=True, by_alias=True)
print(payload)