Fortinet white logo
Fortinet white logo

Script Reference Guide

HTTP:enable_auto(code)

HTTP:enable_auto(code)

This command is same as HTTP:disable_auto(), but it does the opposite task. By default, all the events are automatically enabled after disable_event() is called. So we only need to call this to undo earlier calling of disable_auto(). See the example in disable_auto() section above.

Syntax

HTTP:enable_auto(code)

Arguments

Parameter

Description

code

A Lua integer in hex format to indicate the event.

0x01 — HTTP_REQUEST

0x02 — HTTP_RESPONSE

0x04 — HTTP_DATA_REQUEST

0x08 — HTTP_DATA_RESPONSE

0x10 — CLIENTSSL_HANDSHAKE

0x20 — SERVERSSL_HANDSHAKE

0x40 — TCP_ACCEPTED

0x80 — TCP_CLOSED

0x100 — CLIENTSSL_RENEGOTIATE

0x200 — SERVERSSL_RENEGOTIATE

0x400 — SERVER_CONNECTED

0x800 — SERVER_CLOSED

0x1000 — SERVER_BEFORE_CONNECT

0x2000 — AUTH_RESULT

0x4000 — COOKIE_BAKE

0x8000 — PERSISTENCE

0x10000 — BEFORE_AUTH

0x20000 — POST_PERSIST

0x40000 — WAF_REQUEST_BEFORE_SCAN

0x80000 — WAF_RESPONSE_BEFORE_SCAN

0x100000 — WAF_REQUEST_ATTACK_DETECTED

0x200000 — WAF_RESPONSE_ATTACK_DETECTED

0x400000 — VS_LISTENER_BINDT_REQUEST_CODE

Events

  • HTTP_REQUEST

  • HTTP_RESPONSE

  • HTTP_DATA_REQUEST

  • HTTP_DATA_RESPONSE

  • BEFORE_AUTH

  • WAF_REQUEST_BEFORE_SCAN

  • WAF_RESPONSE_BEFORE_SCAN

  • WAF_REQUEST_ATTACK_DETECTED

  • WAF_RESPONSE_ATTACK_DETECTED

Example

In this example, code 0x2 means HTTP_RESPONSE event, once we disable it, the corresponding event function will not be called for this request. Once we call disable_auto() with the same code, it will continue disabled until enable_auto() is called.

when RULE_INIT {
    count = 0
}
when HTTP_REQUEST {
    count = count+1
    if count>3 then 
        count=1
    end
    debug("==> begin REQUEST scripting: count=%d\n", count)
    -- Disable RESPONSE event (code == 0x2)
    code = 0x2
    if (count == 1) then
        debug("==> disable_event: count=%d\n", count)
        HTTP:disable_event(code)
        --Also disable automatic enabling for the next request
        HTTP:disable_auto(code)
    end
    if (count == 2) then
        -- Enable it for the third one.
        HTTP:enable_auto(code)
    end
    debug("==> end REQUEST scripting.\n\n")
}
when HTTP_RESPONSE {
    debug("=====> begin RESPONSE scripting: count=%d\n", count)
    debug("=====> end RESPONSE scripting.\n\n")
}

Supported Version

FortiADC version 5.0.x and later.

HTTP:enable_auto(code)

HTTP:enable_auto(code)

This command is same as HTTP:disable_auto(), but it does the opposite task. By default, all the events are automatically enabled after disable_event() is called. So we only need to call this to undo earlier calling of disable_auto(). See the example in disable_auto() section above.

Syntax

HTTP:enable_auto(code)

Arguments

Parameter

Description

code

A Lua integer in hex format to indicate the event.

0x01 — HTTP_REQUEST

0x02 — HTTP_RESPONSE

0x04 — HTTP_DATA_REQUEST

0x08 — HTTP_DATA_RESPONSE

0x10 — CLIENTSSL_HANDSHAKE

0x20 — SERVERSSL_HANDSHAKE

0x40 — TCP_ACCEPTED

0x80 — TCP_CLOSED

0x100 — CLIENTSSL_RENEGOTIATE

0x200 — SERVERSSL_RENEGOTIATE

0x400 — SERVER_CONNECTED

0x800 — SERVER_CLOSED

0x1000 — SERVER_BEFORE_CONNECT

0x2000 — AUTH_RESULT

0x4000 — COOKIE_BAKE

0x8000 — PERSISTENCE

0x10000 — BEFORE_AUTH

0x20000 — POST_PERSIST

0x40000 — WAF_REQUEST_BEFORE_SCAN

0x80000 — WAF_RESPONSE_BEFORE_SCAN

0x100000 — WAF_REQUEST_ATTACK_DETECTED

0x200000 — WAF_RESPONSE_ATTACK_DETECTED

0x400000 — VS_LISTENER_BINDT_REQUEST_CODE

Events

  • HTTP_REQUEST

  • HTTP_RESPONSE

  • HTTP_DATA_REQUEST

  • HTTP_DATA_RESPONSE

  • BEFORE_AUTH

  • WAF_REQUEST_BEFORE_SCAN

  • WAF_RESPONSE_BEFORE_SCAN

  • WAF_REQUEST_ATTACK_DETECTED

  • WAF_RESPONSE_ATTACK_DETECTED

Example

In this example, code 0x2 means HTTP_RESPONSE event, once we disable it, the corresponding event function will not be called for this request. Once we call disable_auto() with the same code, it will continue disabled until enable_auto() is called.

when RULE_INIT {
    count = 0
}
when HTTP_REQUEST {
    count = count+1
    if count>3 then 
        count=1
    end
    debug("==> begin REQUEST scripting: count=%d\n", count)
    -- Disable RESPONSE event (code == 0x2)
    code = 0x2
    if (count == 1) then
        debug("==> disable_event: count=%d\n", count)
        HTTP:disable_event(code)
        --Also disable automatic enabling for the next request
        HTTP:disable_auto(code)
    end
    if (count == 2) then
        -- Enable it for the third one.
        HTTP:enable_auto(code)
    end
    debug("==> end REQUEST scripting.\n\n")
}
when HTTP_RESPONSE {
    debug("=====> begin RESPONSE scripting: count=%d\n", count)
    debug("=====> end RESPONSE scripting.\n\n")
}

Supported Version

FortiADC version 5.0.x and later.