From ede6fdcb140df7fc26834329d0053a4bf86b4c5b Mon Sep 17 00:00:00 2001 From: 40huo Date: Mon, 14 Aug 2017 11:10:09 +0800 Subject: [PATCH 1/3] refine result page and docs --- cobra/templates/asset/js/report.js | 2 +- docs/api.md | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/cobra/templates/asset/js/report.js b/cobra/templates/asset/js/report.js index dc406405..3e1cd3d7 100644 --- a/cobra/templates/asset/js/report.js +++ b/cobra/templates/asset/js/report.js @@ -60,7 +60,7 @@ $(function () { // panel $('.v-path').text(data.file_path + ':' + data.line_number); $('.v-id').text('MVE-' + vid); - $('.v-language').text(data.lang); + $('.v-language').text(data.language); // widget function init_widget() { var lis = $('.widget-trigger li'); diff --git a/docs/api.md b/docs/api.md index 164b0fbd..6e757be3 100644 --- a/docs/api.md +++ b/docs/api.md @@ -22,4 +22,16 @@ curl -H "Content-Type: application/json" -X POST -d '{"key":"your_secret_key","s ## 查询扫描报告 ```bash 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 +``` + +# Web 报告页 + +## 任务汇总报告 +``` +http://127.0.0.1/?sid=afbe69p7dxva +``` + +## 扫描详情报告 +``` +http://127.0.0.1/report/afbe69p7dxva/sfbe69plo5qs ``` \ No newline at end of file From df0767b3e0b4649c824aa8661c19d0b6ae2a3a9a Mon Sep 17 00:00:00 2001 From: 40huo Date: Mon, 14 Aug 2017 14:38:14 +0800 Subject: [PATCH 2/3] add vulnerability rank in result page and refine widget --- cobra/templates/asset/js/report.js | 12 ++++++++++-- cobra/templates/result.html | 9 +-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/cobra/templates/asset/js/report.js b/cobra/templates/asset/js/report.js index 3e1cd3d7..1e7f19fd 100644 --- a/cobra/templates/asset/js/report.js +++ b/cobra/templates/asset/js/report.js @@ -66,9 +66,17 @@ $(function () { var lis = $('.widget-trigger li'); $('.commit-author').text('@' + data.commit_author); $('.commit-time').text('@' + data.commit_time); - $('.v-level').text(data.level); + if (9<= data.level && data.level<= 10) { + $('.v-level').text('Critical'); + } else if (6 <= data.level && data.level <= 8) { + $('.v-level').text('High'); + } else if (3 <= data.level && data.level <= 5) { + $('.v-level').text('Medium'); + } else if (1 <= data.level && data.level <= 2) { + $('.v-level').text('Low'); + } $('.v-type').text(data.rule_name); - $('.v-rule').text(data.match_result); + // $('.v-rule').text(data.match_result); } init_widget(); diff --git a/cobra/templates/result.html b/cobra/templates/result.html index a9d3b60d..e18c0be1 100644 --- a/cobra/templates/result.html +++ b/cobra/templates/result.html @@ -123,14 +123,7 @@

Cobra

alt="Commit Time">
  • - Status: () -
  • -
  • - Level: - By - -
  • -
  • - Repair AT: Repair: + Level:
  • Wow, no vulnerability was detected :)

  • '); - } else { - var list_html = ''; + var list = vul_list_origin.vulnerabilities; + sl = Number(sl); + var list_html = ''; - var id = 0; - for (var i = 0; i < list.length; i++) { - var line = ''; - if (list[i].line_number !== 0) { - line = ':' + list[i].line_number; + var id = 0; + for (var i = 0; i < list.length; i++) { + // search rule + if (sr !== null && sr > 0) { + if (list[i].id !== sr) { + continue; + } + } + // search level + if (sl !== null && sl > 0) { + if (sl === 4) { + if (list[i].level < 9) { + console.log(sl); + continue; + } + } else if (sl === 3) { + console.log(sl); + if (list[i].level < 6 || list[i].level > 8) { + continue; + } + } else if (sl === 2) { + if (list[i].level < 3 || list[i].level > 5) { + continue; + } + } else if (sl === 1) { + if (list[i].level < 1 || list[i].level > 2) { + continue; } - list_html = list_html + '
  • ' + - 'MVE-' + (i+1) + '
    ' + list[i].file_path + line + '
    ' + - '' + - '' + - list[i].match_result + ' => ' + list[i].commit_time + - '' + - '' + - '
  • '; - } + } + var line = ''; + if (list[i].line_number !== 0) { + line = ':' + list[i].line_number; + } + list_html = list_html + '
  • ' + + 'MVE-' + (i + 1) + '
    ' + list[i].file_path + line + '
    ' + + '' + + '' + + ' => ' + list[i].commit_time + + '' + + '' + + '
  • '; + } + if (list_html.length === 0) { + $(".vulnerabilities_list").html('
  • Wow, no vulnerability was detected :)

  • '); + } else { + $('.vulnerabilities_list').html(list_html); + } - $('.vulnerabilities_list').html(list_html); - - // current vulnerability - var vid = getParameterByName('vid'); - if (vid !== null && vid > 0) { - vulnerabilities_list.detail(vid); - } + // current vulnerability + var vid = getParameterByName('vid'); + if (vid !== null && vid > 0) { + vulnerabilities_list.detail(vid); + } - // vulnerabilities list detail - $('.vulnerabilities_list li').off('click').on('click', function () { - // loading - $('.CodeMirror').prepend($('.cm-loading').show().get(0)); + // vulnerabilities list detail + $('.vulnerabilities_list li').off('click').on('click', function () { + // loading + $('.CodeMirror').prepend($('.cm-loading').show().get(0)); - vulnerabilities_list.vid = $(this).attr('data-id'); - vulnerabilities_list.pushState(); + vulnerabilities_list.vid = $(this).attr('data-id'); + vulnerabilities_list.pushState(); - vulnerabilities_list.detail(vulnerabilities_list.vid); - }); - } - } else { - $(".vulnerabilities_list").html('
  • The project is deprecated :(

  • '); - } + vulnerabilities_list.detail(vulnerabilities_list.vid); + }); }, trigger_filter: function () { if ($(".filter").is(":visible") === true) { diff --git a/cobra/templates/result.html b/cobra/templates/result.html index e18c0be1..2e0eb1de 100644 --- a/cobra/templates/result.html +++ b/cobra/templates/result.html @@ -57,6 +57,7 @@

    Cobra

    +

    {{ project_name }}