Skip to content
This repository was archived by the owner on Nov 28, 2023. It is now read-only.

Commit 1bdc6a6

Browse files
authored
Merge pull request #560 from 40huo/develop
fix #552
2 parents 2d979c5 + 93973f0 commit 1bdc6a6

File tree

4 files changed

+13
-22
lines changed

4 files changed

+13
-22
lines changed

cobra/api.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def post():
167167
'msg': 'success',
168168
'sid': sid,
169169
'status': result.get('status'),
170-
'report': result.get('report'),
170+
'report': request.url_root + result.get('report'),
171171
'still_running': result.get('still_running'),
172172
'total_target_num': r_data.get('total_target_num'),
173173
'not_finished': int(r_data.get('total_target_num')) - len(r_data.get('sids'))
@@ -312,7 +312,6 @@ def summary():
312312
key=key)
313313

314314
status_url = 'http://{host}:{port}/api/status'.format(host=running_host, port=running_port)
315-
logger.critical(status_url)
316315
post_data = {
317316
'key': key,
318317
'sid': a_sid,
@@ -340,7 +339,6 @@ def summary():
340339
elif len(split_target) == 2:
341340
target, branch = target_str, 'master'
342341
else:
343-
logger.critical('[API] Target url exception: {u}'.format(u=target_str))
344342
target, branch = target_str, 'master'
345343
still_running[s_sid] = {'target': target,
346344
'branch': branch}
@@ -373,7 +371,6 @@ def summary():
373371
elif len(split_target) == 2:
374372
target, branch = target_str, 'master'
375373
else:
376-
logger.critical('Target url exception: {u}'.format(u=target_str))
377374
target, branch = target_str, 'master'
378375

379376
target_info.update({

cobra/export.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import csv
1515
import json
1616
import os
17-
from codecs import open,BOM_UTF8
17+
from codecs import open, BOM_UTF8
1818

1919
from prettytable import PrettyTable
2020

cobra/templates/asset/js/report.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ $(function () {
108108
$('.commit-author').text('@' + data.commit_author);
109109
$('.commit-time').text('@' + data.commit_time);
110110
$('.v-level').text(score2level[data.level]);
111-
$('.v-type').text(data.rule_name);
111+
$('.v-type').text('CVI-' + data.id + ' ' + data.rule_name);
112112
$('.v-solution').text(data.solution);
113113
// $('.v-rule').text(data.match_result);
114114
}
@@ -341,8 +341,8 @@ $(function () {
341341
' data-start="1" data-line="1">' +
342342
'<strong>MVE-' + (i + 1) + '</strong><br><span>' + list[i].file_path + line + '</span><br>' +
343343
'<span class="issue-information">' +
344-
'<small>' +
345-
' => ' + list[i].commit_time +
344+
'<small>' + 'CVI-' + list[i].id +
345+
' => ' + list[i].rule_name +
346346
'</small>' +
347347
'</span>' +
348348
'</li>';

docs/api.md

+8-14
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"code": 1001, # 状态码为1001则表示逻辑处理正常
2121
"result": {
2222
"msg": "Add scan job successfully.", # 消息
23-
"sid": "afbe69gxpy6h" # 扫描的任务ID(调用任务状态查询时需要用到)
23+
"sid": "a938e2y2vnkf", # 扫描的任务ID(调用任务状态查询时需要用到)
24+
"total_target_num": 1 # 扫描任务的项目总数
2425
}
2526
}
2627
```
@@ -45,9 +46,12 @@
4546
"code": 1001, # 状态码为1001则表示逻辑处理正常
4647
"result": {
4748
"msg": "success", # 消息
49+
"not_finished": 0, # 未完成的项目数
50+
"report": "http://127.0.0.1/?sid=ae3ea90pkoo5", # 扫描报告页
51+
"sid": "ae3ea90pkoo5", # 扫描的任务ID
4852
"status": "done", # 扫描状态
49-
"report": "?sid=afbe69v8jjme", # 扫描报告页
50-
"sid": "sfbe69y2sjge" # 扫描的任务ID
53+
"still_running": {}, # 正在扫描的项目
54+
"total_target_num": 1, # 扫描任务的项目总数
5155
}
5256
}
5357
```
@@ -69,24 +73,14 @@ curl -H "Content-Type: application/json" -X POST -d '{"key":"your_secret_key", "
6973

7074
## 查询任务状态
7175
```bash
72-
curl -H "Content-Type: application/json" -X POST -d '{"key":"your_secret_key","sid": "e3ea91nd1f4"}' http://127.0.0.1/api/status
73-
```
74-
75-
## 查询扫描报告
76-
```bash
77-
curl -H "Content-Type: application/json" -X POST -d '{"key":"your_secret_key","task_id": "your_task_id"}' http://127.0.0.1/api/report
76+
curl -H "Content-Type: application/json" -X POST -d '{"key":"your_secret_key","sid": "a938e29vdse8"}' http://127.0.0.1/api/status
7877
```
7978

8079
# Web 报告页
8180

82-
## 任务汇总报告
8381
```
8482
http://127.0.0.1/?sid=afbe69p7dxva
8583
```
8684

87-
## 扫描详情报告
88-
```
89-
http://127.0.0.1/report/afbe69p7dxva/sfbe69plo5qs
90-
```
9185
---
9286
下一章:[高级功能配置](https://wufeifei.github.io/cobra/config)

0 commit comments

Comments
 (0)