@@ -43,8 +43,8 @@ def homepage():
43
43
return render_template ('index.html' , data = data )
44
44
45
45
46
- @web .route ('/report/<int:task_id >' , methods = ['GET' ])
47
- def report (task_id ):
46
+ @web .route ('/report/<int:project_id >' , methods = ['GET' ])
47
+ def report (project_id ):
48
48
# 获取筛选数据
49
49
search_vul_type = request .args .get ("search_vul_type" , None )
50
50
search_rule = request .args .get ("search_rule" , None )
@@ -53,9 +53,10 @@ def report(task_id):
53
53
page = int (request .args .get ("page" , 1 ))
54
54
55
55
# 检测 task id 是否存在
56
- task_info = CobraTaskInfo .query .filter_by (id = task_id ).first ()
57
- if not task_info :
56
+ project_info = CobraProjects .query .filter_by (id = project_id ).first ()
57
+ if not project_info :
58
58
return jsonify (status = "4004" , msg = "report id not found." )
59
+ task_info = CobraTaskInfo .query .filter_by (target = project_info .repository ).order_by (CobraTaskInfo .id .desc ()).first ()
59
60
60
61
# 获取task的信息
61
62
repository = task_info .target
@@ -75,30 +76,29 @@ def report(task_id):
75
76
time_end = time .strftime ("%H:%M:%S" , time .localtime (time_end ))
76
77
77
78
# 获取project信息
78
- project = CobraProjects .query .filter_by (repository = repository ).first ()
79
- if project is None :
79
+ if project_info is None :
80
80
project_name = repository
81
81
project_id = 0 # add l4yn3
82
82
author = 'Anonymous'
83
83
project_description = 'Compress Project'
84
84
project_framework = 'Unknown Framework'
85
85
project_url = 'Unknown URL'
86
86
else :
87
- project_name = project .name
88
- project_id = project .id
89
- author = project .author
90
- project_description = project .remark
91
- project_framework = project .framework
92
- project_url = project .url
87
+ project_name = project_info .name
88
+ project_id = project_info .id
89
+ author = project_info .author
90
+ project_description = project_info .remark
91
+ project_framework = project_info .framework
92
+ project_url = project_info .url
93
93
94
94
# 获取漏洞总数量
95
- scan_results = CobraResults .query .filter_by (task_id = task_id ).all ()
95
+ scan_results = CobraResults .query .filter_by (project_id = project_id ).all ()
96
96
total_vul_count = len (scan_results )
97
97
98
98
# 获取出现的漏洞类型
99
99
res = db .session .query (count ().label ("vul_number" ), CobraVuls .name , CobraVuls .id ).filter (
100
100
and_ (
101
- CobraResults .task_id == task_id ,
101
+ CobraResults .project_id == project_id ,
102
102
CobraResults .rule_id == CobraRules .id ,
103
103
CobraVuls .id == CobraRules .vul_id ,
104
104
)
@@ -114,7 +114,7 @@ def report(task_id):
114
114
# 获取触发的规则类型
115
115
res = db .session .query (CobraRules .description , CobraRules .id ).filter (
116
116
and_ (
117
- CobraResults .task_id == task_id ,
117
+ CobraResults .project_id == project_id ,
118
118
CobraResults .rule_id == CobraRules .id ,
119
119
CobraVuls .id == CobraRules .vul_id
120
120
)
@@ -126,7 +126,7 @@ def report(task_id):
126
126
# 检索不同等级的漏洞数量
127
127
res = db .session .query (count ().label ('vuln_number' ), CobraRules .level ).filter (
128
128
and_ (
129
- CobraResults .task_id == task_id ,
129
+ CobraResults .project_id == project_id ,
130
130
CobraResults .rule_id == CobraRules .id ,
131
131
CobraVuls .id == CobraRules .vul_id ,
132
132
)
@@ -150,7 +150,7 @@ def report(task_id):
150
150
151
151
# 检索全部的漏洞信息
152
152
filter_group = (
153
- CobraResults .task_id == task_id ,
153
+ CobraResults .project_id == project_id ,
154
154
CobraResults .rule_id == CobraRules .id ,
155
155
CobraVuls .id == CobraRules .vul_id ,
156
156
)
@@ -234,7 +234,7 @@ def report(task_id):
234
234
pagination = Pagination (page = page , total = len (total_number ), per_page = page_size , bs_version = 3 )
235
235
236
236
data = {
237
- 'id' : int (task_id ),
237
+ 'id' : int (project_id ),
238
238
'project_name' : project_name ,
239
239
'project_id' : project_id ,
240
240
'project_repository' : repository ,
0 commit comments