Help Center/ CodeArts Check/ API Reference/ APIs/ Rule Management/ Viewing the Rule List of a Rule Set
Updated on 2024-03-15 GMT+08:00

Viewing the Rule List of a Rule Set

Function

This API is used to query the rule list based on conditions such as the project ID and rule set ID.

Calling Method

For details, see Calling APIs.

URI

GET /v2/{project_id}/ruleset/{ruleset_id}/rules

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID

ruleset_id

Yes

String

Rule Set ID

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

types

Yes

String

Status

'1: query all; 2: enabled; 3: disabled'

Default: 1

languages

No

String

Rule Language

tags

No

String

Tag to which the rule belongs

offset

No

Integer

Pagination index, offset

Minimum: 0

Default: 0

limit

No

Integer

Number of records displayed on each page.

Minimum: 1

Maximum: 1000

Default: 100

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

It can be obtained by calling an IAM API. The value of X-Subject-Token in the response header is the user token.

Minimum: 1

Maximum: 100000

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

info

Array of RuleItem objects

Rule list of a rule set.

total

Integer

Total

Table 5 RuleItem

Parameter

Type

Description

rule_id

String

Rule ID

rule_language

String

Rule Language

rule_name

String

Rule Name

rule_severity

String

Rule Problem Severity

tags

String

Rule Tag

checked

String

Rule status. The options are as follows: 0: disabled; 1: enabled.

rule_config_list

Array of RuleConfig objects

Threshold information about rule configuration parameters

Table 6 RuleConfig

Parameter

Type

Description

id

Integer

Rule Configuration ID

rule_id

Integer

Rule ID.

default_value

String

Default Value

option_value

String

Before acceleration

option_key

String

Key of the current rule configuration item.

option_name

String

Name of the current rule configuration item

template_id

String

Rule Set ID

description

String

Description

Status code: 400

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

Error Codes

error_msg

String

Description

Status code: 401

Table 8 Response body parameters

Parameter

Type

Description

error_code

String

Error Codes

error_msg

String

Description

Example Requests

GET https://{endpoint}/v2/{project_id}/ruleset/{ruleset_id}/rules

Example Responses

Status code: 200

Request succeeded!

{
  "info" : [ {
    "rule_language" : "cpp",
    "rule_id" : "1614",
    "checked" : "1",
    "rule_name" : "A buffer must have size of 2 integers if used as parameter of pipe().",
    "rule_severity" : "1",
    "tags" : "cwe",
    "rule_config_list" : [ ]
  }, {
    "rule_language" : "cpp",
    "rule_id" : "1611",
    "checked" : "1",
    "rule_name" : "A buffer must have size of 2 integers if used as parameter of pipe().",
    "rule_severity" : "1",
    "tags" : "cwe",
    "rule_config_list" : [ {
      "id" : 250,
      "rule_id" : 11707,
      "template_id" : "906e7eac47dd4bde9c984f5e6f2a54e8",
      "option_key" : "threshold",
      "option_name" : "Adding a Threshold",
      "option_value" : "10",
      "default_value" : "20",
      "description" : "If the code complexity exceeds the threshold, the code is identified as an ultra-large cyclomatic complexity. The difference between the cyclomatic complexity statistics and the cyclomatic complexity statistics is that only the number of switches is counted, and the case and default values are not counted. This parameter is mandatory."
    }, {
      "id" : 251,
      "rule_id" : 11707,
      "template_id" : "906e7eac47dd4bde9c984f5e6f2a54e8",
      "option_key" : "threshold_modify",
      "option_name" : "Modifying a threshold",
      "option_value" : "30",
      "default_value" : "20",
      "description" : "If the code complexity exceeds the threshold, the code is identified as ultra-large cyclomatic complexity. The difference between the cyclomatic complexity statistics and cyclomatic complexity statistics is that only the number of switches is counted, and the case and default values are not counted. The modified threshold must be greater than the new threshold. This parameter is optional."
    } ]
  } ],
  "total" : 2
}

Status code: 400

Bad Request

{
  "error_code" : "CC.00000000",
  "error_msg" : "The network is busy. Please try again later."
}

Status code: 401

Unauthorized

{
  "error_code" : "CC.00000003",
  "error_msg" : "The authentication information has expired."
}

Status Codes

Status Code

Description

200

Request succeeded!

400

Bad Request

401

Unauthorized

Error Codes

See Error Codes.