3. WafRules WAF 规则相关 API 配置

URL: https://api-client.apeirocdn.com/api/v1

1. resources.wafrules.list 呈现当前的 WAF 规则列表

Method : GET

① 示范 (curl 模式)

curl --location --request GET 'https://api-client.apeirocdn.com/api/v1/resources/wafrules?groupName=cdn-xxx' \
--header 'Cookie: access_token=my-token'

Parameter :

栏位
类型
预设/填写范例
描述

groupName

required

string

groupName=cdn-xxx

项目的群组名称

from

integer

Default: 0

Example: from=0

从 n 开始检索

size

integer

Default: 10

Example: size=10

要检索的项目的数量

filters

string

Default: " "

filters=itemName:my_name filters=usedByFQDNConfigLength Example: filters=ruleName:example_deny filters=usedByFQDNConfigLength:10

用于检索项目的过滤器。

  • 使用 +AND 来分隔过滤特征

  • 使用 * 作为通配符

  • itemName=栏位名称 my_name=该栏位后面的 value

  • waf 当前被套用量:usedByFQDNConfigLength

  • 可以透过 usedByFQDNConfigLength 查看某条 WAF 被套用的数量,例如:usedByFQDNConfigLength:10 即为过滤出被套用在域名 or 专案中总数量为 10 的 waf

2. resources.wafrules.create 添加 WAF 规则

Method : POST

① 示范 (curl 模式)

curl --location --request POST 'https://api-client.apeirocdn.com/api/v1/resources/wafrules?groupName=cdn-xxx' \
--header 'content-type: application/json' \
--header 'Cookie: access_token=my-token' \
--data '{"ruleName":"myrule","wafAction":"00"}'

Parameter :

栏位
类型
预设/填写范例
描述

groupName

required

string

groupName=cdn-xxx

项目的群组名称

Body :

栏位
类型
预设/填写范例
描述

description

string

Default: ""

注解字段

tags

Array of strings

unique

Default: [""]

标签内容

ruleName

required

string ^[a-z0-9-_.]*$

<= 35 characters

Example: wafrule1

WAF 规则的名称

wafAction

string

Default: "00" Enum: "00" "01" "03" "05" "06" "07" "08" "09" "10" "12" "13" "14"

WAF 的动作,数值请参照 [Action Code]

wafCustomHtmlPageName

string

Default: ""

WAF 动作参数,如果 wafAction:Custom Page 规则存在,则使用 HtmlPage

请参阅 resources.htmlpages.list

wafDenyHtmlPageName

string

Default: "default"

WAF 动作参数,如果 wafAction:deny 规则存在,则使用 HtmlPage

请参阅 resources.htmlpages.list

wafOriginPolicyName

string

Default: ""

WAF 动作参数,如果 wafAction: OriginPolicy 存在,则使用 OriginPolicy

请参阅 resources.originpolicies.list

wafBucketTime

integer

[ 5 .. 43200 ]

Default: 300

阻挡多少秒,当 wafAction: block period 存在时才有效

wafSpeedLimit

integer

[ 1 .. 102400 ]

Default: 10240

WAF 动作参数,访问速度限制 (以 KB/s 为单位),当 wafAction: speed limit 存在时才有效

wafRedirectUrl

string

Default: ""

重定向的 URL,格式必须是有效的 URL,并且在 wafAction: redirect 存在时才可以正常工作。

wafRedirectHttpCode

string

Default: "302" Enum: "301" "302" "307"

WAF 动作参数,执行 http 重定向时的重定向 http 代码,当 wafAction:重定向存在时才有效

wafSetReqHeaders

string

Default: ""

WAF 动作参数 ,插入的请求头,当 wafAction:设置请求头存在时才有效,多个值用\n分隔

wafSetResHeaders

string

Default: ""

WAF 动作参数,要插入的响应头,当 wafAction:设置响应头存在时才有效,多个值用\n分隔

wafIp

string

Default: "0.0.0.0/0"

条件,触发 WAF 的 IP,格式应为有效网络,多个值用\n分隔。参见_validate.networks_

wafUri

string

Default: ""

条件,触发 WAF 的 URI,多个值用\n分隔

wafHeaderType

string

Default:"wafHeaders" Enum:"wafHeaders" "wafHeadersSet"

選擇使用 請求表頭 / 請求表頭組欄位

wafHeadersSet

Array of strings

Default: [""]

請求表頭組欄位, 字串元素之間判斷邏輯為 AND , 字串之中仍然可以以\n填入多個值,判斷邏輯為OR

wafHeaders

string

Default: ""

条件,触发 WAF 的头,多个值用\n分隔

wafHeadersNotExist

string

Default: ""

条件,触发 WAF 的头 (如果不存在),多个值用\n分隔

wafCountry

Array of strings

unique

Default: [""]

条件,触发 WAF 的国家

wafHttpMethod

Array of strings

unique

Default: [] Items Enum: "get" "post" "purge" "put" "head" "options" "delete" "patch"

条件,触发 WAF 的 http 方法

wafRate

string

Default: ""

条件,WAF 的请求速率,格式为 次数/秒

wafRateLimitToken

boolean

"group": true, "ruleName": true, "ip": true, "host": true, "uri": true, "method": true, "country": true, "ua": true

Group及ruleName预设开启,不可修改成false

选择开启条件以生成token,没有填写的项目则预设不开启

注意:ip 以及 host 没另外带上填写,默认预设都是true

wafIpExclude

string

Default: "0.0.0.0/0"

条件,忽略触发 WAF 的 IP,格式应为 CIDR,多个值用\n分隔。参见_validate.networks_

wafUriExclude

string

Default: ""

条件,忽略触发 WAF 的 URI,格式应为有效 URI,多个值用\n分隔

wafHeadersExclude

string

Default: ""

条件,忽略触发 WAF 的 Header,格式应为有效字串,多个值用\n分隔

wafProxyType

Array of strings

unique

Default: [] Items Enum: "vpn" "tor" "dch" "pub" "web" "ses"

条件,触发 WAF 的 proxy IP 类型

wafIsDenyThenBucket

boolean

Default: false

仅限 deny 才有,开启 deny 后触发 Period 阻挡

wafDenyThenBucketRate

string

Default: "1/1"

仅限 deny 才有,deny 后触发 Period 阻挡频率

wafIsGlobalBucketRecord

boolean

Default: false

仅限 Block Period 才有,开启 Block Period 后在阻挡时间内,限制来源 IP 访问群组域名

wafIsp

string

Default: ""

条件,忽略触发 WAF 的 ISP 运营商名称,详细名称请查询欲触发 IP 对应 IP2Location 数据库的名称

wafWithL3BucketList

boolean

Default: false

仅限 block period 才有,使用 L3 阻挡

wafJa3Hashes

Array of strings

Default: []

條件,觸發WAF的JA3指紋Hash -> 必須為 32 個字元的十六進位字串(MD5 格式), 且符合[a-fA-F0-9]{32}之規則 -> 不允許重複的值。 -> 最多可有 10 個項目。 -> 可以為空。

Action Code :

  • code: 00: Allow

  • code: 01: Deny

  • code: 03: Gesture Challenge

  • code: 05: Speed Limit

  • code: 06: Redirect

  • code: 07: Cookie / JS Challenge

  • code: 08: Block Period

  • code: 09: Set Request Headers

  • code: 10: Set Response Headers

  • code: 12: Custom Page

  • code: 13: Origin Policy

  • code: 14: Smart Captcha

3.resources.wafrules.get 获取 WAF 规则信息

Method : GET

① 示范 (curl 模式)

Parameter :

栏位
类型
预设/填写范例
描述

groupName

required

string

groupName=cdn-xxx

项目的群组名称

Path :

Path
类型
预设/填写范例
描述

wafruleId

required

string

<groupName>-<ruleName>

Example: cdn-xxx-my_wafrule

要检索的 WAF 规则 ID

4.resources.wafrules.update 更新 WAF 规则信息

Method : PATCH

① 示范 (curl 模式)

Path :

栏位
类型
预设/填写范例
描述

wafruleId

required

string

<groupName>-<ruleName>

Example: cdn-xxx-my_wafrule

要检索的 WAF 规则 ID

Parameter :

栏位
类型
预设/填写范例
描述

groupName

required

string

groupName=cdn-xxx

项目的群组名称

Body :

栏位
类型
预设/填写范例
描述

description

string

Default: ""

注解字段

tags

Array of strings

unique

Default: [""]

标签内容

ruleName

required

string ^[a-z0-9-_.]*$

<= 35 characters

Example: wafrule1

WAF 规则的名称

wafAction

string

Default: "00" Enum: "00" "01" "03" "05" "06" "07" "08" "09" "10" "12" "13" "14"

WAF 的动作,数值请参照 [Action Code]

wafCustomHtmlPageName

string

Default: ""

WAF 动作参数,如果 wafAction:Custom Page 规则存在,则使用 HtmlPage

请参阅 resources.htmlpages.list

wafDenyHtmlPageName

string

Default: "default"

WAF 动作参数,如果 wafAction:deny 规则存在,则使用 HtmlPage

请参阅 resources.htmlpages.list

wafOriginPolicyName

string

Default: ""

WAF 动作参数,如果 wafAction: OriginPolicy 存在,则使用 OriginPolicy

请参阅 resources.originpolicies.list

wafBucketTime

integer

[ 5 .. 43200 ]

Default: 300

阻挡多少秒,当 wafAction: block period 存在时才有效

wafSpeedLimit

integer

[ 1 .. 102400 ]

Default: 10240

WAF 动作参数,访问速度限制 (以 KB/s 为单位),当 wafAction: speed limit 存在时才有效

wafRedirectUrl

string

Default: ""

重定向的 URL,格式必须是有效的 URL,并且在 wafAction: redirect 存在时才可以正常工作。

wafRedirectHttpCode

string

Default: "302" Enum: "301" "302" "307"

WAF 动作参数,执行 http 重定向时的重定向 http 代码,当 wafAction:重定向存在时才有效

wafSetReqHeaders

string

Default: ""

WAF 动作参数 ,插入的请求头,当 wafAction:设置请求头存在时才有效,多个值用\n分隔

wafSetResHeaders

string

Default: ""

WAF 动作参数,要插入的响应头,当 wafAction:设置响应头存在时才有效,多个值用\n分隔

wafIp

string

Default: "0.0.0.0/0"

条件,触发 WAF 的 IP,格式应为有效网络,多个值用\n分隔。参见_validate.networks_

wafUri

string

Default: ""

条件,触发 WAF 的 URI,多个值用\n分隔

wafHeaderType

string

Default:"wafHeaders" Enum:"wafHeaders" "wafHeadersSet"

選擇使用 請求表頭 / 請求表頭組欄位

wafHeadersSet

Array of strings

Default: [""]

請求表頭組欄位, 字串元素之間判斷邏輯為 AND , 字串之中仍然可以以\n填入多個值,判斷邏輯為OR

wafHeaders

string

Default: ""

条件,触发 WAF 的头,多个值用\n分隔

wafHeadersNotExist

string

Default: ""

条件,触发 WAF 的头 (如果不存在),多个值用\n分隔

wafCountry

Array of strings

unique

Default: [""]

条件,触发 WAF 的国家

wafHttpMethod

Array of strings

unique

Default: [] Items Enum: "get" "post" "purge" "put" "head" "options" "delete" "patch"

条件,触发 WAF 的 http 方法

wafRate

string

Default: ""

条件,WAF 的请求速率,格式为 次数/秒

wafRateLimitToken

boolean

"group": true, "ruleName": true, "ip": true, "host": true, "uri": true, "method": true, "country": true, "ua": true

Group及ruleName预设开启,不可修改成false

选择开启条件以生成token,没有填写的项目则预设不开启

注意:ip 以及 host 没另外带上填写,默认预设都是true

wafIpExclude

string

Default: "0.0.0.0/0"

条件,忽略触发 WAF 的 IP,格式应为 CIDR,多个值用\n分隔。参见_validate.networks_

wafUriExclude

string

Default: ""

条件,忽略触发 WAF 的 URI,格式应为有效 URI,多个值用\n分隔

wafHeadersExclude

string

Default: ""

条件,忽略触发 WAF 的 Header,格式应为有效字串,多个值用\n分隔

wafProxyType

Array of strings

unique

Default: [] Items Enum: "vpn" "tor" "dch" "pub" "web" "ses"

条件,触发 WAF 的 proxy IP 类型

wafIsDenyThenBucket

boolean

Default: false

仅限 deny 才有,开启 deny 后触发 Period 阻挡

wafDenyThenBucketRate

string

Default: "1/1"

仅限 deny 才有,deny 后触发 Period 阻挡频率

wafIsGlobalBucketRecord

boolean

Default: false

仅限 Block Period 才有,开启 Block Period 后在阻挡时间内,限制来源 IP 访问群组域名

wafIsp

string

Default: ""

条件,忽略触发 WAF 的 ISP 运营商名称,详细名称请查询欲触发 IP 对应 IP2Location 数据库的名称

wafWithL3BucketList

boolean

Default: false

仅限 block period 才有,使用 L3 阻挡

wafJa3Hashes

Array of strings

Default: []

條件,觸發WAF的JA3指紋Hash -> 必須為 32 個字元的十六進位字串(MD5 格式), 且符合[a-fA-F0-9]{32}之規則 -> 不允許重複的值。 -> 最多可有 10 個項目。 -> 可以為空。

5.resources.wafrules.delete 删除 WAF 规则

Method : DELETE

① 示范 (curl 模式)

Path :

栏位
类型
预设/填写范例
描述

wafruleId

required

string

<groupName>-<ruleName>

Example: cdn-xxx-my_wafrule

要检索的 WAF 规则 ID

Parameter :

栏位
类型
预设/填写范例
描述

groupName

required

string

groupName=cdn-xxx

项目的群组名称

Last updated