跳转至

查询托管规则组列表

1. 接口描述

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

describeCustodyRuleGroups 用于按策略组 ID(wafId)分页查询 OWASP CRS 托管规则组列表。每条记录对应一类检测能力(如协议检测、SQL 注入等)。

Token 获取方式见 密钥鉴权

2. 输入参数

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

参数名称 必选 类型 描述
pageNum Integer 当前页数
示例值:1
pageSize Integer 每页显示条目个数
示例值:20
wafId Long 策略组 ID
示例值:22
filters Array 搜索条件列表
filters.label String 搜索字段,支持以下值:
groupName:规则组英文标识
groupMessage:规则组说明
示例值:groupName
filters.value Array of String 搜索值。传入单个值为模糊搜索,多个值为精确搜索
示例值:["REQUEST-PROTOCOL"]
params Object 扩展参数,一般传 {}

3. 示例

示例1 分页查询托管规则组

输入示例

{
  "pageNum": 1,
  "pageSize": 20,
  "wafId": 22,
  "params": {}
}

代码调用

请将 {登录域名}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 DescribeCustodyRuleGroupsTest {

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

        String requestBody = "{"
                + "\"pageNum\":1,"
                + "\"pageSize\":20,"
                + "\"wafId\":22,"
                + "\"params\":{}"
                + "}";

        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/describeCustodyRuleGroups"
    token := "eyJhbGciOiJIUzUxMiJ9.xxxxxx"

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

    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": 10,
  "rows": [
    {
      "groupId": 901,
      "groupName": "REQUEST-INITIALIZATION",
      "groupMessage": "安装检测",
      "status": "ON"
    },
    {
      "groupId": 911,
      "groupName": "REQUEST-METHOD-ENFORCEMENT",
      "groupMessage": "请求方法检测规则",
      "status": "ON"
    }
  ],
  "code": 200,
  "msg": "成功"
}

4. 输出参数

参数名称 类型 描述
code Integer 状态码。示例值:200
msg String 提示信息。示例值:成功
total Integer 符合条件的总条数。示例值:10
rows Array 托管规则组列表
rows[].groupId Long 规则组 ID。示例值:901
rows[].groupName String 规则组英文标识(CRS 分类名)。示例值:REQUEST-INITIALIZATION
rows[].groupMessage String 规则组说明。示例值:安装检测
rows[].status String 该组在当前 wafId 下的启用状态,支持以下值:
ON:已启用
OFF:已关闭
示例值:ON

5. 错误码

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