Updated on 2026-08-10 GMT+08:00

Obtaining Rules

Function

This API is used to query the rule list. You can filter rules by language and issue severity.

Calling Method

For details, see Calling APIs.

Authorization Information

Each account root user has all the permissions required to call all APIs, but IAM users must be assigned the following required identity policy-based permissions. For details about the required permissions, see Permissions Policies and Supported Actions.

Action

Access Level

Resource Type (*: required)

Condition Key

Alias

Dependencies

codeartscheck::listRules

List

-

-

-

-

URI

GET /v2/rules

Table 1 Query Parameters

Parameter

Mandatory

Type

Description

rule_languages

No

String

Definition

Rule language.

Constraints

Must be a language supported by the current environment.

Range

Only one language can be passed. The following languages are supported:

  • ARKTS

  • C#

  • CANGJIE

  • C++

  • CSS

  • GO

  • HTML

  • JAVA

  • JAVASCRIPT

  • KOTLIN

  • LUA

  • PHP

  • PYTHON

  • RUST

  • SCALA

  • SHELL

  • SQL

  • TERRAFORM

  • TYPESCRIPT

  • AZURERESOURCEMANAGER

  • DOCKER

  • KUBERNETES

Default Value

N/A

rule_severity

No

String

Definition

Issue severity.

Constraints

Only one value can be transferred.

Range

  • 0: critical

  • 1: major

  • 2: minor

  • 3: suggestion

Default Value

N/A

offset

No

Integer

Definition

Offset for pagination.

Constraints

N/A

Range

0–999

Default Value

0

limit

No

Integer

Definition

Number of records displayed on each page.

Constraints

N/A

Range

0–200

Default Value

100

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition

User token. Obtain one by calling the IAM API Obtaining a User Token. The value of X-Subject-Token in the response header is a token.

Constraints

N/A

Range

The length is the value of [1-100000].

Default Value

N/A

X-Language

No

String

Definition:

Language of the response.

Constraints:

N/A

Value range:

  • zh-cn: Chinese.

  • en-us: English.

Default value:

zh-cn

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

info

Array of RuleListItem objects

Definition:

Rule information.

total

Integer

Definition:

Total number.

Value range:

≥ 0.

Table 4 RuleListItem

Parameter

Type

Description

rule_set

String

Definition:

Service type.

Value range:

  • common: general.

  • common_standard_recommend: general recommendation.

  • common_standard_rule: general rule.

  • security: security.

  • security_standard_recommend: security recommendation.

  • security_standard_rule: security rule.

rule_id

String

Definition:

Rule ID.

Value range:

32-character UUID.

rule_language

String

Definition

Rule language.

Range

The following languages are supported:

  • ARKTS

  • C#

  • CANGJIE

  • C++

  • CSS

  • GO

  • HTML

  • JAVA

  • JAVASCRIPT

  • KOTLIN

  • LUA

  • PHP

  • PYTHON

  • RUST

  • SCALA

  • SHELL

  • SQL

  • TERRAFORM

  • TYPESCRIPT

  • AZURERESOURCEMANAGER

  • DOCKER

  • KUBERNETES

rule_name

String

Definition

Rule name.

Range

N/A

rule_severity

String

Definition:

Issue severity.

Value range:

  • 0: critical

  • 1: major

  • 2: minor

  • 3: suggestion

rule_tages

String

Definition:

Rule tag.

Value range:

  • huawei

  • iso5055

  • cert

  • cwe

  • top10

  • top25

  • misra

  • GJB

  • autosar

  • PCI DSS

right_example

String

Definition

Compliant example.

Range

Code block or text example.

error_example

String

Definition

Noncompliant example.

Range

Code block or text example.

revise_opinion

String

Definition

Fix suggestion.

Range

Code block or text example.

rule_desc

String

Definition

Rule description.

Range

N/A

Status code: 400

Table 5 Response body parameters

Parameter

Type

Description

error_code

String

Definition:

Error code.

Value range:

N/A

error_msg

String

Definition:

Error message.

Value range:

N/A

Status code: 401

Table 6 Response body parameters

Parameter

Type

Description

error_code

String

Definition:

Error code.

Value range:

N/A

error_msg

String

Definition:

Error message.

Value range:

N/A

Example Requests

GET https://{endpoint}/v2/rules

Example Responses

Status code: 200

Request succeeded.

{
  "info" : [ {
    "rule_id" : "2561",
    "rule_language" : "Java",
    "rule_name" : "\"=+\" cannot be replaced by \"+=\".",
    "rule_severity" : "1",
    "rule_tages" : "bug",
    "rule_desc" : "<p>Use strict equality operator (<code>===</code>) to compare different types. The result is always <code>false</code>. </p>",
    "right_example" : "<pre>\nvar a = 8;\nvar b = \"8\";\n\nif (a == b) {\n  // ...\n}\n</pre>\n<p>or</p>\n<pre>\nvar a = 8;\nvar b = \"8\";\n\nif (a === Number(b)) {\n  // ...\n}\n</pre>",
    "error_example" : "<pre>\nvar a = 8;\nvar b = \"8\";\n\nif (a === b) {  //Noncompliant, always false\n  // ...\n}\n</pre>",
    "revise_opinion" : "None",
    "rule_set" : "common"
  }, {
    "rule_id" : "8048",
    "rule_language" : "Java",
    "rule_name" : "\"Arrays.stream\" should be used for primitive arrays",
    "rule_severity" : "1",
    "rule_tages" : "performance",
    "rule_desc" : "<p>Use strict equality operator (<code>===</code>) to compare different types. The result is always <code>false</code>. </p>",
    "right_example" : "<pre>\nvar a = 8;\nvar b = \"8\";\n\nif (a == b) {\n  // ...\n}\n</pre>\n<p>or</p>\n<pre>\nvar a = 8;\nvar b = \"8\";\n\nif (a === Number(b)) {\n  // ...\n}\n</pre>",
    "error_example" : "<pre>\nvar a = 8;\nvar b = \"8\";\n\nif (a === b) {  //Noncompliant, always false\n  // ...\n}\n</pre>",
    "revise_opinion" : "None",
    "rule_set" : "common"
  } ],
  "total" : 2
}

Status code: 400

A request error occurred.

{
  "error_code" : "CC.xxxxxxxx.400",
  "error_msg" : "Verify request parameter failed. Check whether the request parameters are correct."
}

Status code: 401

The permission is insufficient.

{
  "error_code" : "CC.00000003",
  "error_msg" : "Authentication information expired."
}

Status Codes

Status Code

Description

200

Request succeeded.

400

A request error occurred.

401

The permission is insufficient.

Error Codes

See Error Codes.