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

Commit

Permalink
Merge pull request #525 from 40huo/master
Browse files Browse the repository at this point in the history
only show top 10 vulnerabilities in information page
  • Loading branch information
FeeiCN authored Sep 4, 2017
2 parents c992033 + 004a943 commit 197905e
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 19 deletions.
10 changes: 2 additions & 8 deletions cobra/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,10 @@
import time
import traceback

try:
# Python 2
from urlparse import unquote
except ImportError:
# Python 3
from urllib.parse import unquote

import requests
from flask import Flask, request, render_template
from flask_restful import Api, Resource
from werkzeug.urls import url_unquote

from . import cli
from .cli import get_sid
Expand Down Expand Up @@ -267,7 +261,7 @@ def post():
return {'code': 1003, 'msg': 'Only support json, please post json data.'}

sid = data.get('sid')
file_path = unquote(data.get('file_path'))
file_path = url_unquote(data.get('file_path'))

if not sid or sid == '':
return {"code": 1002, "msg": "sid is required."}
Expand Down
1 change: 1 addition & 0 deletions cobra/templates/asset/css/report.css
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
border-top: 1px solid #282828;
padding: 5px;
min-height: 75px;
word-wrap: break-word;
}

.vulnerabilities_list > li.critical {
Expand Down
2 changes: 1 addition & 1 deletion cobra/templates/asset/css/skins/square/grey.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
@media (-o-min-device-pixel-ratio: 5/4), (-webkit-min-device-pixel-ratio: 1.25), (min-resolution: 120dpi) {
.icheckbox_square-grey,
.iradio_square-grey {
background-image: url(grey@2x.png);
background-image: url(grey.png);
-webkit-background-size: 240px 24px;
background-size: 240px 24px;
}
Expand Down
8 changes: 6 additions & 2 deletions cobra/templates/asset/js/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ $(function () {
detail: function (vid) {
$('.vulnerabilities_list li').removeClass('active');
$('li[data-id=' + vid + ']').addClass('active');
// hide loading
$('.CodeMirror .cm-loading').hide();
vid = Number(vid);
var sid = $('#search_target').val();
var data = vul_list_origin.vulnerabilities[vid - 1];
Expand All @@ -82,6 +80,8 @@ $(function () {
data: JSON.stringify({sid: sid, file_path: data.file_path}),
dataType: 'json',
success: function (result) {
// hide loading
$('.CodeMirror .cm-loading').hide();
if (result.code === 1001) {
data.code_content = result.result.file_content;
data.language = result.result.extension;
Expand Down Expand Up @@ -145,6 +145,10 @@ $(function () {
} else {
alert(result.msg);
}
},
error: function (result) {
alert('Fetch detail failed.');
$('.CodeMirror .cm-loading').hide();
}
});
},
Expand Down
2 changes: 1 addition & 1 deletion cobra/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<style>
.bar {
width: 0%;
width: 0;
height: 30px;
background: #18cc18;
line-height: 30px;
Expand Down
31 changes: 24 additions & 7 deletions cobra/templates/summary.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
<!DOCTYPE html>
<!--[if IE 8]>
<html class="ie ie8"> <![endif]-->
<!--[if IE 9]>
<html class="ie ie9"> <![endif]-->
<!--[if gt IE 9]><!-->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="{{ url_for('static', filename='ico/favicon.ico') }}" type="image/x-icon">
<link rel="stylesheet" href="{{ url_for('static', filename='css/base.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='css/report.css') }}">
<script src="{{ url_for('static', filename='js/jquery-3.2.1.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/echarts.min.js') }}" charset="utf-8"></script>
<script src="{{ url_for('static', filename='js/bootstrap.min.js') }}"></script>
<title>Task Information</title>

<!--[if lt IE 9]>
<script src="asset/js/html5shiv.min.js"></script>
<script src="asset/js/respond.min.js"></script>
<![endif]-->

</head>
<body>
<div class="container-fluid">
Expand Down Expand Up @@ -93,7 +107,7 @@ <h5>Number of vulnerabilities</h5>
</div>
</div>
<div class="col-md-8">
<h4>Vulnerability distribution statistics</h4>
<h4>Top 10 vulnerability distribution statistics</h4>
<div id="vul_distributing" style="height:400px;">
{% if vuls | length == 0 %}
<img src="{{ url_for('static', filename='img/congratulations.jpg') }}"
Expand Down Expand Up @@ -201,9 +215,6 @@ <h4>Running Targets</h4>
<label for="search_rule" style="color: #aaaaaa;">Mode</label>
<select id="search_rule" class="form-control" style="height: 30px;">
<option value="all">All</option>
{% for rule in rule_filter %}
<option value="{{ rule }}">{{ rule_filter.get(rule) }}</option>
{% endfor %}
</select>
</div>
<div class="col-md-12" style="margin-top: 10px;">
Expand Down Expand Up @@ -273,10 +284,16 @@ <h4>Running Targets</h4>
<script>
var types = [];
var vuls = [];
{% for vul in vuls.keys() %}
types.push('{{ vul }}');
vuls.push({value: {{ vuls.get(vul) }}, name: '{{ vul }}'});
{% for type, num in vuls | dictsort(by='value') %}
// 取漏洞数量前十
{% if loop.revindex <= 10 %}
types.push('{{ type }}');
vuls.push({value: {{ num }}, name: '{{ type }}'});
{% endif %}
{% endfor %}
// 数量大的靠前
types.reverse();
vuls.reverse();
option = {
tooltip: {
trigger: 'item',
Expand Down

0 comments on commit 197905e

Please sign in to comment.