Skip to content

Commit 25818e8

Browse files
committed
🎨增加支持根据扫描方案模板创建方案的开放接口与相关文档
1 parent 7a369e7 commit 25818e8

4 files changed

Lines changed: 34 additions & 138 deletions

File tree

doc/en/api/代码扫描数据模块接口.md

Lines changed: 0 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -135,140 +135,3 @@ GET /server/analysis/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/projec
135135
"status_code": 200
136136
}
137137
```
138-
139-
## 查看每次扫描的问题列表
140-
```
141-
GET /server/analysis/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/projects/<project_id>/codelint/scans/<scan_id>/issues/
142-
```
143-
#### 参数
144-
| 参数 | 类型 | 描述 |
145-
| --- | --- | --- |
146-
| state | str | 问题状态, 1为未处理,2为已处理,3为关闭,可多选,格式为1,2,3 |
147-
| severity | str | 严重程度, 1为致命,2为错误,3为警告,4为提示,可多选,格式为1,2,3,4 |
148-
| resolution | str | 解决方式, 0为无,1为修复,2为无需修复,3为误报,4为重复单过滤,5为路径过滤,6为规则移除 |
149-
| author | str | 问题责任人 |
150-
| scan_open_id | int | 发现问题的扫描编号 |
151-
| scan_fix_id | int | 修复问题的扫描编号 |
152-
| ci_time_gte | str | 修复问题的起始时间 |
153-
| ci_time_lte | str | 修复问题的结束时间 |
154-
| file_path | str | 文件路径 |
155-
| checkrule_display_name | str | 检查规则名 |
156-
| checkpackage | int | 问题所属的规则包 |
157-
158-
#### 返回结果
159-
```JSON
160-
{
161-
"data": {
162-
"count": 1,
163-
"next": null,
164-
"previous": null,
165-
"results": [
166-
{
167-
"id": 1,
168-
"repo_id": 1,
169-
"project_id": 1,
170-
"scan_time": "2021-03-11T20:46:44.171607+08:00",
171-
"file_path": "test/demo.py",
172-
"scm_url": "",
173-
"real_file_path": "",
174-
"line": 21,
175-
"column": 68,
176-
"checkrule_gid": 1,
177-
"checkrule_real_name": "xxx",
178-
"checkrule_display_name": "xxx",
179-
"checkrule_rule_title": "xxx",
180-
"checktool_name": "xxx",
181-
"category": 7,
182-
"msg": "xxx",
183-
"state": 1,
184-
"resolution": null,
185-
"author": "author",
186-
"scan_open_id": 1,
187-
"scan_fix_id": null,
188-
"issuedetail_uuid": "26d7ba88-8268-11eb-a304-5254005e71ca",
189-
"scan_revision": "scan_revision",
190-
"real_revision": "",
191-
"severity": 2,
192-
"language": "python",
193-
"revision": "revision",
194-
"ci_time": "2019-07-01T10:28:19+08:00",
195-
"file_owners": null,
196-
"created_time": "2021-03-11T20:49:00.539537+08:00",
197-
"fixed_time": null
198-
}
199-
]
200-
},
201-
"code": 0,
202-
"msg": "xxx",
203-
"status_code": 200
204-
}
205-
```
206-
207-
208-
## 查看指定CR扫描的问题列表
209-
```
210-
GET /server/analysis/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/projects/<project_id>/codelint/crscans/<scan_id>/issues/
211-
```
212-
#### 参数
213-
| 参数 | 类型 | 描述 |
214-
| --- | --- | --- |
215-
| state | str | 问题状态, 1为未处理,2为已处理,3为关闭,可多选,格式为1,2,3 |
216-
| severity | str | 严重程度, 1为致命,2为错误,3为警告,4为提示,可多选,格式为1,2,3,4 |
217-
| resolution | str | 解决方式, 0为无,1为修复,2为无需修复,3为误报,4为重复单过滤,5为路径过滤,6为规则移除 |
218-
| author | str | 问题责任人 |
219-
| scan_open_id | int | 发现问题的扫描编号 |
220-
| scan_fix_id | int | 修复问题的扫描编号 |
221-
| ci_time_gte | str | 修复问题的起始时间 |
222-
| ci_time_lte | str | 修复问题的结束时间 |
223-
| file_path | str | 文件路径 |
224-
| checkrule_display_name | str | 检查规则名 |
225-
| checkpackage | int | 问题所属的规则包 |
226-
227-
#### 返回结果
228-
```JSON
229-
{
230-
"data": {
231-
"count": 1,
232-
"next": null,
233-
"previous": null,
234-
"results": [
235-
{
236-
"id": 1,
237-
"repo_id": 1,
238-
"project_id": 1,
239-
"scan_time": "2021-03-11T20:46:44.171607+08:00",
240-
"file_path": "test/demo.py",
241-
"scm_url": "",
242-
"real_file_path": "",
243-
"line": 21,
244-
"column": 68,
245-
"checkrule_gid": 1,
246-
"checkrule_real_name": "xxx",
247-
"checkrule_display_name": "xxx",
248-
"checkrule_rule_title": "xxx",
249-
"checktool_name": "xxx",
250-
"category": 7,
251-
"msg": "xxx",
252-
"state": 1,
253-
"resolution": null,
254-
"author": "author",
255-
"scan_open_id": 1,
256-
"scan_fix_id": null,
257-
"issuedetail_uuid": "26d7ba88-8268-11eb-a304-5254005e71ca",
258-
"scan_revision": "scan_revision",
259-
"real_revision": "",
260-
"severity": 2,
261-
"language": "python",
262-
"revision": "revision",
263-
"ci_time": "2019-07-01T10:28:19+08:00",
264-
"file_owners": null,
265-
"created_time": "2021-03-11T20:49:00.539537+08:00",
266-
"fixed_time": null
267-
}
268-
]
269-
},
270-
"code": 0,
271-
"msg": "xxx",
272-
"status_code": 200
273-
}
274-
```

doc/en/api/项目管理模块接口.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,29 @@ GET /server/main/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/schemes/
478478
}
479479
```
480480

481+
## 使用指定扫描方案模板创建指定代码库的扫描方案
482+
```
483+
GET /server/main/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/copyscheme/
484+
```
485+
486+
#### 参数列表
487+
| 参数 | 类型 | 描述 |
488+
| --- | --- | --- |
489+
| name | str | 扫描方案名称 |
490+
| ref_scheme | int | 参照扫描方案编号 |
491+
492+
#### 返回结果
493+
```JSON
494+
{
495+
"data": {
496+
"scan_scheme": 1
497+
},
498+
"code": 0,
499+
"msg": "请求成功",
500+
"status_code": 201
501+
}
502+
```
503+
481504
## 查看指定代码库的指定扫描方案
482505
```
483506
GET /server/main/api/orgs/<org_sid>/teams/<team_name>/repos/<repo_id>/schemes/<scheme_id>/basicconf/

server/projects/main/apps/codeproj/api_urls/v1_org.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@
7777
v1_pt.PTProjectScanCreateAPIView.as_view(),
7878
name="apiv1_pt_project_team_repo_project_scans"),
7979
path("<int:repo_id>/schemes/", v1_pt.PTScanSchemeListAPIView.as_view(),
80-
name="apiv1_pt_project_team_repo_scheme_detail"),
80+
name="apiv1_pt_project_team_repo_scheme_list"),
81+
path("<int:repo_id>/copyscheme/", v1_pt.PTRepositorySchemeCopyApiView.as_view(),
82+
name="apiv1_pt_project_team_repo_scheme_copy"),
8183
path("<int:repo_id>/schemes/<int:scheme_id>/basicconf/", v1_pt.PTScanSchemeBasicConfAPIView.as_view(),
8284
name="apiv1_pt_project_team_repo_scheme_basicconf"),
8385
path("<int:repo_id>/schemes/<int:scheme_id>/lintconf/", v1_pt.PTScanSchemeLintConfAPIView.as_view(),

server/projects/main/apps/codeproj/apis/v1_pt.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,14 @@ class PTScanSchemeListAPIView(v3.ScanSchemeListApiView):
172172
"""
173173

174174

175+
class PTRepositorySchemeCopyApiView(v3.RepositorySchemeCopyApiView):
176+
"""拷贝方案模板
177+
178+
### POST
179+
应用场景:仅用于拷贝方案模板
180+
"""
181+
182+
175183
class PTScanSchemeBasicConfAPIView(v3.ScanSchemeBasicConfApiView):
176184
"""指定扫描方案详情接口,仅basic配置
177185

0 commit comments

Comments
 (0)