Querying a Preset SQL Inspection Rule
Function
This API is used to query a single preset SQL inspection rule.
Authorization
Each account has full permissions to call all APIs, but its IAM users need permission assignments to do so. For specific permission requirements, refer to Introduction.
URI
GET /v1/{project_id}/sql-defend-sys-rules/{rule_id}
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| project_id | Yes | String | Definition Project ID, which is used for resource isolation. For details about how to obtain its value, see Obtaining a Project ID. Constraints None Range The value can contain up to 64 characters. Only letters and digits are allowed. Default Value None |
| rule_id | Yes | String | Definition Rule ID. For details, see the rule ID in Table 3. Constraints None Range For details about the enumerated values, see Table 3.
Default Value None |
Request Parameters
None
Response Parameters
| Parameter | Type | Description |
|---|---|---|
| rule_id | String | Definition Rule ID. For details, see the rule ID in Table 3. Constraints None Range For details about the enumerated values, see Table 3.
Default Value None |
| category | String | Definition Rule status type. For details, see the status type column in Table 3. Constraints None Range Options:
Default Value None |
| actions | Array of strings | Action that can be performed. |
| engines | Array of strings | Engines supported. |
| no_limit | Boolean | Whether the rule has a limit value. |
| desc | String | Rule description. Maximum length: 2,000 characters. |
| param | SysRuleParam object | Configuration parameters of system rules. |
| Rule ID | Rule Name | Description | Category | Applicable Engine | Action | Value | Default System Rule | Example SQL Statement | Supported Engine Version |
|---|---|---|---|---|---|---|---|---|---|
| dynamic_0001 | Scan files number | Maximum number of files to be scanned. | dynamic | spark | Hint Intercept | Value range: 1–2000000 Default value: 200000 | Yes | NA | Spark 3.3.1 |
| dynamic_0002 | Scan partitions number | Maximum number of partitions involved in the operations (select, delete, update, and alter) that can be performed on a table. | dynamic | spark | Hint Intercept | Value range: 1–500000 Default value: 5000 | Yes | select * from Partitioned table | Spark 3.3.1 |
| running_0002 | Memory used(MB) | Peak memory usage of the SQL statement. | running | spark | Block | Value range: 1–8388608 | No | NA | Spark 3.3.1 |
| running_0003 | Run time(S) | Maximum running duration of the SQL statement. | running | spark | Block | Unit: second Value range: 1–43200 | No | NA | Spark 3.3.1 |
| running_0004 | Scan data(GB) | Maximum amount of data to be scanned. | running | spark | Block | Unit: GB Value range: 1–10240 | No | NA | Spark 3.3.1 |
| running_0005 | Shuffle data(GB) | Maximum amount of data to be shuffled. | running | spark | Block | Unit: GB Value range: 1–10240 Default value: 2048 | Yes | NA | Spark 3.3.1 Spark 2.4.5 |
| static_0001 | Count(distinct) occurrences | Maximum number of occurrences of count(distinct) in the SQL statement. | static | spark | Hint Intercept | Value range: 1–100 Default value: 10 | Yes | SELECT COUNT(DISTINCT deviceId), COUNT(DISTINCT collDeviceId) FROM table GROUP BY deviceName, collDeviceName, collCurrentVersion; | Spark 3.3.1 |
| static_0002 | Not in<Subquery> | Check whether not in <subquery> is used in the SQL statement. | static | spark | Hint Intercept | Value range: Yes or No Default value: Yes | Yes | SELECT * FROM Orders o WHERE Orders.Order_ID not in (Select Order_ID FROM HeldOrders h where h.order_id = o.order_id); | Spark 3.3.1 |
| static_0003 | Join occurrences | Maximum number of joins in the SQL statement. | static | spark | Hint Intercept | Value range: 1–50 | No | SELECT name, text FROM table_1 JOIN table_2 ON table_1.Id = table_2.Id | Spark 3.3.1 |
| static_0004 | Union occurrences | Maximum number of union all times in the SQL statement. | static | spark | Hint Intercept | Value range: 1–100 | No | select * from tables t1 union all select * from tables t2 union all select * from tables t3 | Spark 3.3.1 |
| static_0005 | Subquery nesting layers | Maximum number of subquery nesting layers. | static | spark | Hint Intercept | Value range: 1–20 | No | select * from ( with temp1 as (select * from tables) select * from temp1); | Spark 3.3.1 |
| static_0006 | Sql size(KB) | Maximum size of a SQL file. | static | spark | Hint Intercept | Unit: KB Value range: 1–1024 | No | NA | Spark 3.3.1 |
| static_0007 | Cartesian product | Limitation of Cartesian products when multiple tables are being associated. | static | spark | Hint Intercept | Value range: 0–1 | No | select * from A,B; | Spark 3.3.1 |
Example Request
None
Example Response
{
"defaultLimit": 200000,
"rule_id": "dynamic_0001",
"category": "dynamic",
"actions": [
"hint"
],
"engines": [
"spark",
"trino"
],
"no_limit": false,
"auto_rule": true,
"desc": "Scan files number",
"param": {
"desc": null,
"type": null,
"min": 1,
"max": 2000000,
"defaultValue": 200000
},
"engine_versions": {
"spark": "3.3.1"
}
} Status Codes
| Status Code | Description |
|---|---|
| 201 | A rule is successfully queried. |
| 400 | Request error. |
| 500 | Internal server error. |
Error Codes
If an error occurs when this API is called, the system does not return the result similar to the preceding example, but returns an error code and error message. For details, 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