跳转至

查询托管规则明细列表

1. 接口描述

接口请求路径:POST /prod-api/waf/wafv3/custody/rules/describeCustodyRuleList

describeCustodyRuleList 用于在指定策略组(wafId)下,按规则组(groupId)分页查询托管检测单条规则列表。groupId 来自 查询托管规则组列表

Token 获取方式见 密钥鉴权

2. 输入参数

以下请求参数列表仅列出了接口请求参数和部分公共参数,完整公共参数列表见 公共请求参数

参数名称 必选 类型 描述
pageNum Integer 当前页数
示例值:1
pageSize Integer 每页显示条目个数
示例值:20
wafId Long 策略组 ID
示例值:22
groupId Long 规则组 ID
示例值:901
filters Array 搜索条件列表
filters.label String 搜索字段,支持以下值:
ruleId:规则 ID
ruleMessage:规则说明
groupName:规则组英文名
示例值:ruleId
filters.value Array of String 搜索值。传入单个值为模糊搜索,多个值为精确搜索
示例值:["901450"]
searchHeader Object 额外筛选条件
searchHeader.switchMode String 按规则状态筛选,支持以下值:
ON:启用
OFF:关闭
DEFAULT:未单独覆盖(跟随默认)
示例值:ON
params Object 扩展参数,一般传 {}

3. 示例

示例1 按规则组查询明细

输入示例

{
  "pageNum": 1,
  "pageSize": 20,
  "wafId": 22,
  "groupId": 901,
  "params": {},
  "filters": []
}

代码调用

请将 {登录域名}token 替换为实际值。

import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

public class DescribeCustodyRuleListTest {

    public static void main(String[] args) throws Exception {
        String url = "https://{登录域名}/prod-api/waf/wafv3/custody/rules/describeCustodyRuleList";
        String token = "eyJhbGciOiJIUzUxMiJ9.xxxxxx";

        String requestBody = "{"
                + "\"pageNum\":1,"
                + "\"pageSize\":20,"
                + "\"wafId\":22,"
                + "\"groupId\":901,"
                + "\"params\":{},"
                + "\"filters\":[]"
                + "}";

        try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
            HttpPost httpPost = new HttpPost(url);
            httpPost.setHeader("Authorization", "Bearer " + token);
            httpPost.setEntity(new StringEntity(requestBody, ContentType.APPLICATION_JSON));

            try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
                int statusCode = response.getStatusLine().getStatusCode();
                String body = EntityUtils.toString(response.getEntity(), "UTF-8");
                System.out.println("Status Code: " + statusCode);
                System.out.println("Body: " + body);
            }
        }
    }
}
package main

import (
    "bytes"
    "fmt"
    "io"
    "net/http"
)

func main() {
    url := "https://{登录域名}/prod-api/waf/wafv3/custody/rules/describeCustodyRuleList"
    token := "eyJhbGciOiJIUzUxMiJ9.xxxxxx"

    requestBody := []byte(`{
  "pageNum": 1,
  "pageSize": 20,
  "wafId": 22,
  "groupId": 901,
  "params": {},
  "filters": []
}`)

    req, err := http.NewRequest(http.MethodPost, url, bytes.NewReader(requestBody))
    if err != nil {
        panic(err)
    }
    req.Header.Set("Authorization", "Bearer "+token)
    req.Header.Set("Content-Type", "application/json")

    resp, err := http.DefaultClient.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    body, err := io.ReadAll(resp.Body)
    if err != nil {
        panic(err)
    }
    fmt.Println("Status Code:", resp.StatusCode)
    fmt.Println("Body:", string(body))
}

输出示例

{
  "total": 3,
  "rows": [
    {
      "ruleId": 901001,
      "ruleMessage": "基础规则:检查配置是否进行有效配置",
      "groupName": "REQUEST-INITIALIZATION",
      "defaultStatus": "ON",
      "status": "DEFAULT"
    },
    {
      "ruleId": 901450,
      "ruleMessage": "规则引擎已根据采样率暂停执行",
      "groupName": "REQUEST-INITIALIZATION",
      "defaultStatus": "ON",
      "status": "DEFAULT"
    },
    {
      "ruleId": 901500,
      "ruleMessage": "检测偏执级别低于设定值,属于非法操作。请求已强制阻断。",
      "groupName": "REQUEST-INITIALIZATION",
      "defaultStatus": "ON",
      "status": "DEFAULT"
    }
  ],
  "code": 200,
  "msg": "成功"
}

4. 输出参数

参数名称 类型 描述
code Integer 状态码。示例值:200
msg String 提示信息。示例值:成功
total Integer 符合条件的总条数。示例值:3
rows Array 托管规则明细列表
rows[].ruleId Long 托管规则 ID。示例值:901001
rows[].ruleMessage String 规则说明。示例值:基础规则:检查配置是否进行有效配置
rows[].groupName String 所属规则组英文标识。示例值:REQUEST-INITIALIZATION
rows[].defaultStatus String 平台默认推荐状态,支持以下值:
ON:启用
OFF:关闭
示例值:ON
rows[].status String 当前策略组下该规则的实际状态,支持以下值:
ON:启用
OFF:关闭
DEFAULT:未单独覆盖,跟随 defaultStatus
示例值:DEFAULT

5. 错误码

HTTP 状态码 / 业务提示 描述
200 成功
401 未鉴权或 Token 无效
403 无权限
查询失败,无效的wafId wafId 不存在或不属于当前账号
wafId不能为空 未传 wafId
groupId不能为空 未传 groupId
参数异常 filters.label 不是 ruleId / ruleMessage / groupName