Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 【高危语句规则】新增高危语句规则管理功能的API,给上层SaaS使用 #2383 #2485

Merged
merged 7 commits into from
Nov 15, 2023
80 changes: 80 additions & 0 deletions docs/apidoc/esb/jobv3-confapis/apidocs/en/check_script.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
### Function Description

Check script

### Request Parameters

{{ common_args_desc }}

#### Interface parameters

| Fields | Type | Required | Description |
| --------------- | ------ | -------- | ------------------------------------------------------------ |
| script_language | int | yes | Script language:1 - shell, 2 - bat, 3 - perl, 4 - python, 5 - powershell, 6 - sql |
| content | string | yes | Script content, requiring Base64 encoding |


### Example of request

```json
{
"bk_app_code": "esb_test",
"bk_app_secret": "xxx",
"bk_token": "xxx",
"script_language": [1],
"content": "cm0gLXJmIC8="
}
```

### Example of responses

```json
{
"code": 0,
"result": true,
"data": [
{
"line": 1,
"lineContent": "rm /tmp",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

api 所有的字段格式都需要是下划线分隔的,而不是驼峰方式。 lineContent->line_content

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dto是下划线格式,文档从别处copy的,没注意,已改

"matchContent": "rm /tmp",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

api 所有的字段格式都需要是下划线分隔的,而不是驼峰方式

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已改

"level": 1,
"action": null,
"code": "103701001",
"description": "The first line of the script does not define a valid script type, for example: #!/bin/bash"
},
{
"line": 1,
"line_content": "rm /tmp",
"matchContent": "rm",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

api 所有的字段格式都需要是下划线分隔的,而不是驼峰方式

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已改

"level": 3,
"action": 2,
"code": null,
"description": "dangerous!!!"
}
]
}
```

### Response Description

#### response

| Fields | Type | Description |
| ---------- | ------ | ------------------------------------------------------------ |
| result | bool | Whether the request succeeded or not. True: request succeeded;False: request failed |
| code | int | Error code. 0 indicates success, >0 indicates failure |
| message | string | Error message |
| data | object | Data returned by request |
| permission | object | Permission information |

#### data

| Fields | Type | Description |
| ------------- | ------ | --------------------------------------------------- |
| line | int | Number of rows where the error occurred |
| line_content | string | The content of the line where the script is located |
| match_content | string | Matching Content |
| level | int | Error level: 1- Warning, 2- Error, 3- Fatal |
| action | int | Processing actions: 1- Scan, 2- Intercept |
| description | string | Description |
| code | string | Error code |
81 changes: 81 additions & 0 deletions docs/apidoc/esb/jobv3-confapis/apidocs/en/create_dangerous_rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
### Function Description

Create dangerous rule

### Request Parameters

{{ common_args_desc }}

#### Interface parameters

| Fields | Type | Required | Description |
| -------------------- | ------ | -------- | ------------------------------------------------------------ |
| expression | string | yes | Expression |
| script_language_list | array | yes | Script language:1 - shell, 2 - bat, 3 - perl, 4 - python, 5 - powershell, 6 - sql |
| description | string | yes | Rule description |
| action | int | yes | Processing actions: 1- Scan, 2- Intercept |


### Example of request

```json
{
"bk_app_code": "esb_test",
"bk_app_secret": "xxx",
"bk_token": "xxx",
"expression": "rm -rf",
"script_language_list": [1],
"description": "drangerous!!!",
"action": 2
}
```

### Example of responses

```json
{
"code": 0,
"result": true,
"data": {
"id": 1,
"expression": "rm -rf",
"script_language_list": [1],
"description": "drangerous!!!",
"order": 1,
"action": 2,
"status": 0,
"creator": "admin",
"create_time": 1695193968000,
"last_modify_user": "admin",
"last_modify_time": 1695193968000
}
}
```

### Response Description

#### response

| Fields | Type | Description |
| ---------- | ------ | ------------------------------------------------------------ |
| result | bool | Whether the request succeeded or not. True: request succeeded;False: request failed |
| code | int | Error code. 0 indicates success, >0 indicates failure |
| message | string | Error message |
| data | object | Data returned by request |
| permission | object | Permission information |

#### data

| Fields | Type | Description |
| -------------------- | ------ | ------------------------------------------------------------ |
| id | long | Rule id |
| expression | string | expression |
| script_language_list | array | Script language:1 - shell, 2 - bat, 3 - perl, 4 - python, 5 - powershell, 6 - sql |
| description | string | Description |
| order | int | Order: Small comes first |
| action | int | Processing actions: 1- Scan, 2- Intercept |
| status | int | Enabling status: 0- disabled, 1- enabled |
| creator | string | Creator |
| create_time | long | Created time, Unix timestamp |
| last_modify_user | string | Last modify user |
| last_modify_time | long | Last modified time, Unix timestamp |
50 changes: 50 additions & 0 deletions docs/apidoc/esb/jobv3-confapis/apidocs/en/delete_dangerous_rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
### Function Description

Delete dangerous rule

### Request Parameters

{{ common_args_desc }}

#### Interface parameters

| Fields | Type | Required | Description |
| ------ | ---- | -------- | ----------- |
| id | int | yes | Rule id |


### Example of request

```json
{
"bk_app_code": "esb_test",
"bk_app_secret": "xxx",
"bk_token": "xxx",
"id": 1
}
```

### Example of responses

```json
{
"code": 0,
"result": true
}
```

### Response Description

#### response

| Fields | Type | Description |
| ---------- | ------ | ------------------------------------------------------------ |
| result | bool | Whether the request succeeded or not. True: request succeeded;False: request failed |
| code | int | Error code. 0 indicates success, >0 indicates failure |
| message | string | Error message |
| data | object | Data returned by request |
| permission | object | Permission information |

#### data

null
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
### Function Description

Disable dangerous rule

### Request Parameters

{{ common_args_desc }}

#### Interface parameters

| Fields | Type | Required | Description |
| ------ | ---- | -------- | ----------- |
| id | int | yes | Rule id |


### Example of request

```json
{
"bk_app_code": "esb_test",
"bk_app_secret": "xxx",
"bk_token": "xxx",
"id": 1
}
```

### Example of responses

```json
{
"code": 0,
"result": true,
"data": {
"id": 1,
"status": 0
}
}
```

### Response Description

#### response

| Fields | Type | Description |
| ---------- | ------ | ------------------------------------------------------------ |
| result | bool | Whether the request succeeded or not. True: request succeeded;False: request failed |
| code | int | Error code. 0 indicates success, >0 indicates failure |
| message | string | Error message |
| data | object | Data returned by request |
| permission | object | Permission information |

#### data

| Fields | Type | Description |
| ------ | ---- | ---------------------------------------- |
| id | long | Rule id |
| status | int | Enabling status: 0- disabled, 1- enabled |
57 changes: 57 additions & 0 deletions docs/apidoc/esb/jobv3-confapis/apidocs/en/enable_dangerous_rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
### Function Description

Enable dangerous rule

### Request Parameters

{{ common_args_desc }}

#### Interface parameters

| Fields | Type | Required | Description |
| ------ | ---- | -------- | ----------- |
| id | int | yes | Rule id |


### Example of request

```json
{
"bk_app_code": "esb_test",
"bk_app_secret": "xxx",
"bk_token": "xxx",
"id": 1
}
```

### Example of responses

```json
{
"code": 0,
"result": true,
"data": {
"id": 1,
"status": 1
}
}
```

### Response Description

#### response

| Fields | Type | Description |
| ---------- | ------ | ------------------------------------------------------------ |
| result | bool | Whether the request succeeded or not. True: request succeeded;False: request failed |
| code | int | Error code. 0 indicates success, >0 indicates failure |
| message | string | Error message |
| data | object | Data returned by request |
| permission | object | Permission information |

#### data

| Fields | Type | Description |
| ------ | ---- | ---------------------------------------- |
| id | long | Rule id |
| status | int | Enabling status: 0- disabled, 1- enabled |
Loading