更新精准防护规则
功能介绍
更新精准防护规则
URI
PUT /v1/{project_id}/waf/policy/{policy_id}/custom/{rule_id}
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
project_id |
是 |
String |
用户操作的项目id |
|
policy_id |
是 |
String |
防护策略id,您可以通过调用查询防护策略列表(ListPolicy)获取策略id |
|
rule_id |
是 |
String |
customRuleId |
请求参数
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
X-Auth-Token |
是 |
String |
auth token |
|
Content-Type |
是 |
String |
内容类型 缺省值:application/json;charset=utf8 |
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
name |
否 |
String |
自定义规则的名称 |
|
time |
否 |
Boolean |
精准防护规则生效时间:
|
|
start |
否 |
Long |
精准防护规则生效的起始时间戳(毫秒)。当time=true,才会返回该参数。 |
|
terminal |
否 |
Long |
精准防护规则生效的终止时间戳(毫秒)。当time=true,才会返回该参数。 |
|
conditions |
否 |
Array of CustomConditions objects |
匹配条件列表 |
|
action |
否 |
CustomAction object |
精准防护规则命中后操作对象 |
|
priority |
否 |
Integer |
执行该规则的优先级,值越小,优先级越高,值相同时,规则创建时间早,优先级越高。取值范围:0到1000。 |
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
category |
否 |
String |
条件类型 固定值path、user-agent、ip、params、cookie、referer、header |
|
index |
否 |
String |
当“category”为“cookie”时,index表示cookie。
|
|
check_all_indexes_logic |
否 |
Integer |
取值范围:1,2;1 表示全部子字段,2 表示任意子字段 |
|
logic_operation |
否 |
Integer |
“contain”,“not_contain”,“equal”,“not_equal”,“prefix”,“not_prefix”,“suffix”,“not_suffix”分别代表包含、不包含、等于、不等于、前缀为、前缀不为、后缀为、后缀不为。当条件类型“category”为ip时,“logic_operation”只能为“equal”或者“not_equal” |
|
contents |
否 |
Array of strings |
条件匹配的内容 |
|
value_list_id |
否 |
String |
引用表的id |
响应参数
状态码: 200
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
id |
String |
精准防护规则的id |
|
policyid |
String |
精准防护规则的策略id |
|
conditions |
Array of conditions objects |
匹配条件列表,匹配条件必须同时满足。 |
|
action |
action object |
精准防护规则命中后操作对象 |
|
priority |
Integer |
执行该规则的优先级,值越小,优先级越高,值相同时,规则创建时间早,优先级越高。取值范围:0到1000。 |
|
timestamp |
Long |
创建精准防护规则的 |
|
start |
Long |
精准防护规则生效的起始时间戳(毫秒)。当time=true,才会返回该参数。 |
|
terminal |
Long |
精准防护规则生效的终止时间戳(毫秒)。当time=true,才会返回该参数。 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
category |
String |
条件类型。固定值path、user-agent、ip、params、cookie、referer、header。 |
|
index |
String |
当“category”为“cookie”时,index表示cookie。
|
|
check_all_indexes_logic |
Integer |
取值范围:1,2;1 表示全部子字段,2 表示任意子字段 |
|
logic_operation |
Integer |
“contain”,“not_contain”,“equal”,“not_equal”,“prefix”,“not_prefix”,“suffix”,“not_suffix”分别代表包含、不包含、等于、不等于、前缀为、前缀不为、后缀为、后缀不为。当条件类型“category”为ip时,“logic_operation”只能为“equal”或者“not_equal” |
|
contents |
Array of strings |
条件匹配的内容 |
状态码: 400
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
error_code |
String |
错误码 |
|
error_msg |
String |
错误信息 |
状态码: 401
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
error_code |
String |
错误码 |
|
error_msg |
String |
错误信息 |
状态码: 500
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
error_code |
String |
错误码 |
|
error_msg |
String |
错误信息 |
请求示例
PUT https://{Endpoint}/v1/{project_id}/waf/policy/{policy_id}/custom/{rule_id}?enterprise_project_id=0
{
"description" : "",
"action" : {
"category" : "block"
},
"priority" : 50,
"conditions" : [ {
"category" : "header",
"logic_operation" : "exist",
"index" : "sdfsafsda1"
} ],
"time" : false
}
响应示例
状态码: 200
ok
{
"action" : {
"category" : "block"
},
"action_mode" : false,
"aging_time" : 0,
"conditions" : [ {
"category" : "header",
"index" : "sdfsafsda1",
"logic_operation" : "exist"
} ],
"description" : "",
"id" : "2a3caa2bc9814c09ad73d02e3485b4a4",
"policyid" : "1f016cde588646aca3fb19f277c44d03",
"priority" : 50,
"producer" : 1,
"status" : 1,
"time" : false
}
状态码
|
状态码 |
描述 |
|---|---|
|
200 |
ok |
|
400 |
请求失败 |
|
401 |
token权限不足 |
|
500 |
服务器内部错误 |
错误码
请参见错误码。