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

🎨增加使用扫描方案模板创建方案的开放接口与相关文档 #757

Merged
merged 1 commit into from
Feb 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 0 additions & 137 deletions doc/en/api/代码扫描数据模块接口.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,140 +135,3 @@ GET /server/analysis/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/projec
"status_code": 200
}
```

## 查看每次扫描的问题列表
```
GET /server/analysis/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/projects/<project_id>/codelint/scans/<scan_id>/issues/
```
#### 参数
| 参数 | 类型 | 描述 |
| --- | --- | --- |
| state | str | 问题状态, 1为未处理,2为已处理,3为关闭,可多选,格式为1,2,3 |
| severity | str | 严重程度, 1为致命,2为错误,3为警告,4为提示,可多选,格式为1,2,3,4 |
| resolution | str | 解决方式, 0为无,1为修复,2为无需修复,3为误报,4为重复单过滤,5为路径过滤,6为规则移除 |
| author | str | 问题责任人 |
| scan_open_id | int | 发现问题的扫描编号 |
| scan_fix_id | int | 修复问题的扫描编号 |
| ci_time_gte | str | 修复问题的起始时间 |
| ci_time_lte | str | 修复问题的结束时间 |
| file_path | str | 文件路径 |
| checkrule_display_name | str | 检查规则名 |
| checkpackage | int | 问题所属的规则包 |

#### 返回结果
```JSON
{
"data": {
"count": 1,
"next": null,
"previous": null,
"results": [
{
"id": 1,
"repo_id": 1,
"project_id": 1,
"scan_time": "2021-03-11T20:46:44.171607+08:00",
"file_path": "test/demo.py",
"scm_url": "",
"real_file_path": "",
"line": 21,
"column": 68,
"checkrule_gid": 1,
"checkrule_real_name": "xxx",
"checkrule_display_name": "xxx",
"checkrule_rule_title": "xxx",
"checktool_name": "xxx",
"category": 7,
"msg": "xxx",
"state": 1,
"resolution": null,
"author": "author",
"scan_open_id": 1,
"scan_fix_id": null,
"issuedetail_uuid": "26d7ba88-8268-11eb-a304-5254005e71ca",
"scan_revision": "scan_revision",
"real_revision": "",
"severity": 2,
"language": "python",
"revision": "revision",
"ci_time": "2019-07-01T10:28:19+08:00",
"file_owners": null,
"created_time": "2021-03-11T20:49:00.539537+08:00",
"fixed_time": null
}
]
},
"code": 0,
"msg": "xxx",
"status_code": 200
}
```


## 查看指定CR扫描的问题列表
```
GET /server/analysis/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/projects/<project_id>/codelint/crscans/<scan_id>/issues/
```
#### 参数
| 参数 | 类型 | 描述 |
| --- | --- | --- |
| state | str | 问题状态, 1为未处理,2为已处理,3为关闭,可多选,格式为1,2,3 |
| severity | str | 严重程度, 1为致命,2为错误,3为警告,4为提示,可多选,格式为1,2,3,4 |
| resolution | str | 解决方式, 0为无,1为修复,2为无需修复,3为误报,4为重复单过滤,5为路径过滤,6为规则移除 |
| author | str | 问题责任人 |
| scan_open_id | int | 发现问题的扫描编号 |
| scan_fix_id | int | 修复问题的扫描编号 |
| ci_time_gte | str | 修复问题的起始时间 |
| ci_time_lte | str | 修复问题的结束时间 |
| file_path | str | 文件路径 |
| checkrule_display_name | str | 检查规则名 |
| checkpackage | int | 问题所属的规则包 |

#### 返回结果
```JSON
{
"data": {
"count": 1,
"next": null,
"previous": null,
"results": [
{
"id": 1,
"repo_id": 1,
"project_id": 1,
"scan_time": "2021-03-11T20:46:44.171607+08:00",
"file_path": "test/demo.py",
"scm_url": "",
"real_file_path": "",
"line": 21,
"column": 68,
"checkrule_gid": 1,
"checkrule_real_name": "xxx",
"checkrule_display_name": "xxx",
"checkrule_rule_title": "xxx",
"checktool_name": "xxx",
"category": 7,
"msg": "xxx",
"state": 1,
"resolution": null,
"author": "author",
"scan_open_id": 1,
"scan_fix_id": null,
"issuedetail_uuid": "26d7ba88-8268-11eb-a304-5254005e71ca",
"scan_revision": "scan_revision",
"real_revision": "",
"severity": 2,
"language": "python",
"revision": "revision",
"ci_time": "2019-07-01T10:28:19+08:00",
"file_owners": null,
"created_time": "2021-03-11T20:49:00.539537+08:00",
"fixed_time": null
}
]
},
"code": 0,
"msg": "xxx",
"status_code": 200
}
```
23 changes: 23 additions & 0 deletions doc/en/api/项目管理模块接口.md
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,29 @@ GET /server/main/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/schemes/
}
```

## 使用指定扫描方案模板创建指定代码库的扫描方案
```
GET /server/main/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/copyscheme/
```

#### 参数列表
| 参数 | 类型 | 描述 |
| --- | --- | --- |
| name | str | 扫描方案名称 |
| ref_scheme | int | 参照扫描方案编号 |

#### 返回结果
```JSON
{
"data": {
"scan_scheme": 1
},
"code": 0,
"msg": "请求成功",
"status_code": 201
}
```

## 查看指定代码库的指定扫描方案
```
GET /server/main/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/schemes/<scheme_id>/basicconf/
Expand Down
4 changes: 3 additions & 1 deletion server/projects/main/apps/codeproj/api_urls/v1_org.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@
v1_pt.PTProjectScanCreateAPIView.as_view(),
name="apiv1_pt_project_team_repo_project_scans"),
path("<int:repo_id>/schemes/", v1_pt.PTScanSchemeListAPIView.as_view(),
name="apiv1_pt_project_team_repo_scheme_detail"),
name="apiv1_pt_project_team_repo_scheme_list"),
path("<int:repo_id>/copyscheme/", v1_pt.PTRepositorySchemeCopyApiView.as_view(),
name="apiv1_pt_project_team_repo_scheme_copy"),
path("<int:repo_id>/schemes/<int:scheme_id>/basicconf/", v1_pt.PTScanSchemeBasicConfAPIView.as_view(),
name="apiv1_pt_project_team_repo_scheme_basicconf"),
path("<int:repo_id>/schemes/<int:scheme_id>/lintconf/", v1_pt.PTScanSchemeLintConfAPIView.as_view(),
Expand Down
8 changes: 8 additions & 0 deletions server/projects/main/apps/codeproj/apis/v1_pt.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@ class PTScanSchemeListAPIView(v3.ScanSchemeListApiView):
"""


class PTRepositorySchemeCopyApiView(v3.RepositorySchemeCopyApiView):
"""拷贝方案模板

### POST
应用场景:仅用于拷贝方案模板
"""


class PTScanSchemeBasicConfAPIView(v3.ScanSchemeBasicConfApiView):
"""指定扫描方案详情接口,仅basic配置

Expand Down