Viewing Rules of a Rule Set
Function
This API is used to query the rules in a rule set of a project. You can filter rules by rule status.
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::getRuleSet |
Read |
- |
- |
- |
- |
URI
GET /v2/{project_id}/ruleset/{ruleset_id}/rules
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
project_id |
Yes |
String |
Definition : You can obtain the 32-character UUID by calling the API used to query the project list. Constraints: N/A Value range: 32-character project ID. Default value: N/A |
|
ruleset_id |
Yes |
String |
Definition : Rule set ID. Obtain the ID by calling the API used to obtain the rule set list. Constraints: N/A Value range: 1 to 32 characters. Default value: N/A |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
types |
No |
String |
Definition: Rule status. Constraints: N/A Value range: Default value: 1 |
|
languages |
No |
String |
Definition Rule language. Constraints N/A Range N/A Default Value N/A |
|
tags |
No |
String |
Definition Rule tag. Constraints N/A Range N/A Default Value N/A |
|
offset |
No |
Integer |
Definition Offset for pagination. Constraints N/A Range 0–999 |
|
limit |
No |
Integer |
Definition Number of records displayed on each page. Constraints N/A Range 0–200 |
Request 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 Value range: 1–100,000 characters. Default value: N/A |
Response Parameters
Status code: 200
|
Parameter |
Type |
Description |
|---|---|---|
|
info |
Array of RuleItem objects |
Definition Rules of a rule set. Range N/A |
|
total |
Integer |
Definition Total number. Range N/A |
|
Parameter |
Type |
Description |
|---|---|---|
|
rule_id |
String |
Definition: Rule ID. Value range: 32-character ID. |
|
rule_language |
String |
Definition: Rule language. Value range: The following languages are supported: |
|
rule_name |
String |
Definition Rule name. Range N/A |
|
rule_severity |
String |
Definition: Issue severity. Value range: |
|
tags |
String |
Definition: Rule tag. Value range: |
|
checked |
String |
Definition: Rule status. Value range: |
|
rule_config_list |
Array of RuleConfigParam objects |
Rule threshold information. |
|
Parameter |
Type |
Description |
|---|---|---|
|
id |
Integer |
Definition : Rule configuration ID. Obtain the ID by calling the API used to obtain the rule list[. Value range: 32-character UUID. |
|
rule_id |
String |
Definition: Tool rule ID, that is, the ID of a threshold for configuring a threshold rule. To obtain such an ID, contact customer service. Value range: 32-character UUID. |
|
default_value |
String |
Definition Default threshold. Range N/A |
|
option_value |
String |
Definition New threshold of a parameter. Range N/A |
|
option_key |
String |
Definition : Key of the current rule configuration item. Obtain the ID by calling the API used to obtain the rule list[. Value range: N/A |
|
option_name |
String |
Definition : Key of the current rule configuration item. Obtain the ID by calling the API used to obtain the rule list[. Value range: N/A |
|
template_id |
String |
Definition : Rule set ID. Obtain the ID by calling the API used to obtain the rule set list. Value range: 32-character UUID. |
|
description |
String |
Definition Parameter description. This parameter is optional. Range N/A |
Status code: 400
|
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
|
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/{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 a huge cyclomatic complexity. The difference between the large cyclomatic complexity and cyclomatic complexity statistics is that only the number of switch statements is counted. The 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 a huge cyclomatic complexity. The difference between the large cyclomatic complexity and cyclomatic complexity statistics is that only the number of switch statements is 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.xxxxxxxx.400",
"error_msg" : "Verify request parameter failed. Check whether the request parameters are correct."
}
Status code: 401
Unauthorized
{
"error_code" : "CC.00000003",
"error_msg" : "Authentication information expired."
}
Status Codes
|
Status Code |
Description |
|---|---|
|
200 |
Request succeeded! |
|
400 |
Bad Request |
|
401 |
Unauthorized |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot