Fortinet white logo
Fortinet white logo

Script Reference Guide

WAF:stage()

WAF:stage()

The WAF:stage() method retrieves the current processing stage of the Web Application Firewall (WAF) module. This function helps identify which phase of WAF processing is currently executing, allowing for stage-specific logic and debugging.

Syntax

WAF:stage();

Arguments

N/A

Events

Applicable in all WAF events:

  • WAF_REQUEST_BEFORE_SCAN

  • WAF_RESPONSE_BEFORE_SCAN

  • WAF_REQUEST_ATTACK_DETECTED

  • WAF_RESPONSE_ATTACK_DETECTED

Returns: A string representing the current WAF processing stage
Possible Values:
    "REQUEST_BEFORE_SCAN" - Before request scanning begins
    "REQUEST_ATTACK_DETECTED" - When an attack is detected in the request
    "RESPONSE_BEFORE_SCAN" - Before response scanning begins
    "RESPONSE_ATTACK_DETECTED" - When an attack is detected in the response.
        

Example

when WAF_REQUEST_ATTACK_DETECTED {
    local stage = WAF:stage()
    if stage == "REQUEST_ATTACK_DETECTED" then
        debug("Blocking malicious request at stage: %s\n", stage)
        -- Add custom blocking logic here
    end
}

Supported Version

FortiADC version 6.2.x and later.

WAF:stage()

WAF:stage()

The WAF:stage() method retrieves the current processing stage of the Web Application Firewall (WAF) module. This function helps identify which phase of WAF processing is currently executing, allowing for stage-specific logic and debugging.

Syntax

WAF:stage();

Arguments

N/A

Events

Applicable in all WAF events:

  • WAF_REQUEST_BEFORE_SCAN

  • WAF_RESPONSE_BEFORE_SCAN

  • WAF_REQUEST_ATTACK_DETECTED

  • WAF_RESPONSE_ATTACK_DETECTED

Returns: A string representing the current WAF processing stage
Possible Values:
    "REQUEST_BEFORE_SCAN" - Before request scanning begins
    "REQUEST_ATTACK_DETECTED" - When an attack is detected in the request
    "RESPONSE_BEFORE_SCAN" - Before response scanning begins
    "RESPONSE_ATTACK_DETECTED" - When an attack is detected in the response.
        

Example

when WAF_REQUEST_ATTACK_DETECTED {
    local stage = WAF:stage()
    if stage == "REQUEST_ATTACK_DETECTED" then
        debug("Blocking malicious request at stage: %s\n", stage)
        -- Add custom blocking logic here
    end
}

Supported Version

FortiADC version 6.2.x and later.