更新精准防护规则
功能介绍
更新精准防护规则
URI
PUT /v1/edgesec/configuration/http/policies/{policy_id}/access-control-rule/{rule_id}
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
policy_id |
是 |
String |
策略id |
|
rule_id |
是 |
String |
防护规则id |
请求参数
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
X-Auth-Token |
是 |
String |
auth token |
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
name |
是 |
String |
规则名称 |
|
description |
否 |
String |
规则描述,最长512字符 |
|
status |
否 |
Integer |
规则开关状态 |
|
start |
否 |
Long |
生效时间 |
|
terminal |
否 |
Long |
失效时间 |
|
time_mode |
是 |
String |
生效模式 |
|
period_type |
否 |
String |
time_mode为period时必传,每日生效时间类型,目前只有day |
|
time_range |
否 |
Array of TimeRangeItem objects |
time_mode为period时必传,每日生效时间区间 |
|
time_zone |
否 |
String |
time_mode为period时必传,时区,例如:UTC+8 |
|
priority |
是 |
Integer |
执行该规则的优先级,值越小,优先级越高,值相同时,规则创建时间早,优先级越高。取值范围:1到100。 |
|
conditions |
是 |
Array of HttpAccessControlRuleCondition objects |
命中条件 |
|
action |
是 |
HttpRuleAction object |
防护规则动作 |
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
category |
否 |
String |
字段类型。可选值为:url、custom_asn、custom_geoip、robot、user-agent、ip、params、cookie、referer、header、method、request_line、request、response_code、response_length、response_time、response_header、response_body |
|
index |
否 |
String |
子字段:
|
|
contents |
否 |
Array of strings |
内容列表 |
|
logic_operation |
否 |
String |
处理逻辑 |
|
value_list_id |
否 |
String |
引用表id |
|
size |
否 |
Long |
若防护规则涉及阈值,即使用该字段 |
|
check_all_indexes_logic |
否 |
Integer |
1.所有子字段/2.任意子字段 |
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
category |
是 |
String |
操作类型。
|
|
followed_action_id |
否 |
String |
攻击惩罚规则id,只有当category参数值为block时才可配置该参数 |
|
detail |
否 |
HttpRuleActionDetail object |
防护规则动作 |
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
redirect_url |
否 |
String |
返回页面重定向的url |
|
response |
否 |
HttpRuleActionResponse object |
防护规则返回页面 |
响应参数
状态码:200
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
id |
String |
规则id |
|
name |
String |
规则名称 |
|
policy_id |
String |
规则所在策略id |
|
policy_name |
String |
规则所在策略名称 |
|
timestamp |
Long |
创建规则时间戳 |
|
description |
String |
规则描述 |
|
status |
Integer |
规则开关状态 |
|
time |
Boolean |
是否设定生效时间 |
|
start |
Long |
生效时间 |
|
terminal |
Long |
失效时间 |
|
priority |
Integer |
优先级 |
|
conditions |
Array of HttpAccessControlRuleCondition objects |
命中条件 |
|
action |
HttpRuleAction object |
防护规则动作 |
|
producer |
Integer |
创建来源 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
category |
String |
字段类型。可选值为:url、custom_asn、custom_geoip、robot、user-agent、ip、params、cookie、referer、header、method、request_line、request、response_code、response_length、response_time、response_header、response_body |
|
index |
String |
子字段:
|
|
contents |
Array of strings |
内容列表 |
|
logic_operation |
String |
处理逻辑 |
|
value_list_id |
String |
引用表id |
|
size |
Long |
若防护规则涉及阈值,即使用该字段 |
|
check_all_indexes_logic |
Integer |
1.所有子字段/2.任意子字段 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
category |
String |
操作类型。
|
|
followed_action_id |
String |
攻击惩罚规则id,只有当category参数值为block时才可配置该参数 |
|
detail |
HttpRuleActionDetail object |
防护规则动作 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
redirect_url |
String |
返回页面重定向的url |
|
response |
HttpRuleActionResponse object |
防护规则返回页面 |
状态码:400
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
error_code |
String |
标准化错误码:服务名.八位数字编码 |
|
error_msg |
String |
清晰的错误信息 |
|
encoded_authorization_message |
String |
对接IAM5.0的服务,拒绝访问时需要返回IAM的相关响应 |
状态码:401
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
error_code |
String |
标准化错误码:服务名.八位数字编码 |
|
error_msg |
String |
清晰的错误信息 |
|
encoded_authorization_message |
String |
对接IAM5.0的服务,拒绝访问时需要返回IAM的相关响应 |
状态码:500
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
error_code |
String |
标准化错误码:服务名.八位数字编码 |
|
error_msg |
String |
清晰的错误信息 |
|
encoded_authorization_message |
String |
对接IAM5.0的服务,拒绝访问时需要返回IAM的相关响应 |
请求示例
修改精准防护规则
PUT https://esa.cn-north-4.myhuaweicloud.com/v1/edgesec/configuration/http/policies/a7bd0ca4b2ac48cfb8c59deebf6b64e0/access-control-rule/a5bd0ca4b2ac48cfb8c59deebf6b64e8
{
"name" : "access_control1",
"description" : "test",
"time" : true,
"status" : 0,
"start" : 1731423500000,
"terminal" : 1731427900000,
"priority" : 10,
"conditions" : [ {
"category" : "cookie",
"index" : "test",
"contents" : [ "aaa", "bbb" ],
"logic_operation" : "contain"
} ],
"action" : {
"category" : "block",
"followed_action_id" : "a7bd0ca4b2ac48cfb8c59deebf6b64e1"
}
}
响应示例
状态码:200
请求成功
{
"id" : "a5bd0ca4b2ac48cfb8c59deebf6b64e8",
"name" : "access_control1",
"policy_id" : "a7bd0ca4b2ac48cfb8c59deebf6b64e0",
"policy_name" : "policy_test1",
"timestamp" : 1731427500000,
"description" : "test",
"status" : 0,
"time" : true,
"start" : 1731423500000,
"terminal" : 1731427900000,
"priority" : 10,
"conditions" : [ {
"category" : "cookie",
"index" : "test",
"contents" : [ "aaa", "bbb" ],
"logic_operation" : "contain"
} ],
"action" : {
"category" : "block",
"followed_action_id" : "a7bd0ca4b2ac48cfb8c59deebf6b64e1"
},
"producer" : 1
}
状态码
|
状态码 |
描述 |
|---|---|
|
200 |
请求成功 |
|
400 |
请求失败 |
|
401 |
token权限不足 |
|
500 |
服务器内部错误 |
错误码
请参见错误码。