diff --git a/cve_bin_tool/output_engine/html.py b/cve_bin_tool/output_engine/html.py index 4a721a3f39..e558900dbf 100644 --- a/cve_bin_tool/output_engine/html.py +++ b/cve_bin_tool/output_engine/html.py @@ -303,12 +303,18 @@ def output_html( # paper_bgcolor="LightSteelBlue", ) + remarks = "" + if new_cves: - remark = "NEW" - elif unexplored_cves: - remark = "UNEXPLORED" - else: - remark = "" + remarks += "new " + if mitigated_cves: + remarks += "mitigated " + if confirmed_cves: + remarks += "confirmed " + if unexplored_cves: + remarks += "unexplored " + if ignored_cves: + remarks += "ignored " products_found.append( product_row.render( @@ -321,7 +327,7 @@ def output_html( severity_analysis=analysis_pie.to_html( full_html=False, include_plotlyjs=False ), - remark=remark, + remarks=remarks, fix_id=hid, paths=cve_data["paths"], len_paths=len(cve_data["paths"]), diff --git a/cve_bin_tool/output_engine/html_reports/js/main.js b/cve_bin_tool/output_engine/html_reports/js/main.js index 3818c63df7..d0e868f62a 100644 --- a/cve_bin_tool/output_engine/html_reports/js/main.js +++ b/cve_bin_tool/output_engine/html_reports/js/main.js @@ -1,40 +1,112 @@ function searchProductsScanned() { - let input = document.getElementById('searchInput'); - let filter = input.value.toLowerCase(); - let ul = document.getElementById('listProducts'); + let input = document.getElementById('searchInput') + let filter = input.value.toLowerCase() + let ul = document.getElementById('listProducts') let li = ul.getElementsByClassName('list-group-item-action') for (let i = 0; i < li.length; i++) { - let txtValue = li[i].textContent || li[i].innerText; + let txtValue = li[i].textContent || li[i].innerText if (txtValue.toLowerCase().indexOf(filter) > -1) { - li[i].style.display = ""; + li[i].style.display = '' } else { - li[i].style.display = "none"; + li[i].style.display = 'none' } } } function analysisShadowToggle(ele) { - ele.classList.toggle("shadow-lg"); + ele.classList.toggle('shadow-lg') } function resizeGraph(ele) { setTimeout(() => { - let modalId = ele.getAttribute('data-bs-target').substr(1); + let modalId = ele.getAttribute('data-bs-target').substr(1) eval(document.getElementById(modalId).querySelector('script').innerHTML) - }, 240); + }, 240) } -function modeInteractive(){ - var div_interactive = document.getElementById("interactive_mode"); - var div_print = document.getElementById("print_mode") - div_interactive.style.display = "block"; - div_print.style.display = "none"; +function modeInteractive() { + var div_interactive = document.getElementById('interactive_mode') + var div_print = document.getElementById('print_mode') + div_interactive.style.display = 'block' + div_print.style.display = 'none' } -function modePrint(){ - var div_interactive = document.getElementById("interactive_mode"); - var div_print = document.getElementById("print_mode") - div_interactive.style.display = "none"; - div_print.style.display = "block"; -} \ No newline at end of file +function modePrint() { + var div_interactive = document.getElementById('interactive_mode') + var div_print = document.getElementById('print_mode') + div_interactive.style.display = 'none' + div_print.style.display = 'block' +} + +function handleActive(key, id) { + document + .getElementById(id) + .getElementsByClassName('active')[0] + .classList.remove('active') + document.getElementById(id).children[key].classList.add('active') +} + +function filterCVEs(remark, id) { + const classes = ['new', 'confirmed', 'mitigated', 'unexplored', 'ignored'] + for (let i = 0; i < 5; i++) { + let ele = document + .getElementById(`listCVE${id}`) + .getElementsByClassName(classes[i])[0] + if (remark == 'all' || classes[i] === remark) ele.style.display = '' + else ele.style.display = 'none' + } +} + +function filterByRemark(key, id) { + const classes = [ + 'all', + 'new', + 'confirmed', + 'mitigated', + 'unexplored', + 'ignored', + ] + handleActive(key, `list-cve${id}`) + filterCVEs(classes[key], id) +} + +function updateCount(ele, remark) { + if (remark === 'all') { + ele.getElementsByClassName('cve-count')[0].innerHTML = ele + .getElementsByClassName('cve-count')[0] + .getAttribute('total-cve-count') + return + } + ele.getElementsByClassName('cve-count')[0].innerHTML = + ele.nextElementSibling.getElementsByClassName(remark)[0].childElementCount +} + +function filterProducts(remark) { + let ul = document.getElementById('listProducts') + let li = ul.getElementsByClassName('list-group-item-action') + + for (let i = 0; i < li.length; i++) { + let remarks = li[i].getAttribute('remarks') + if (remarks === null) continue + if (remark === 'all' || remarks.indexOf(remark) > -1) { + li[i].style.display = '' + updateCount(li[i], remark) + } else { + li[i].style.display = 'none' + } + } +} + +function filterProductsByRemark(key) { + const classes = [ + 'all', + 'new', + 'confirmed', + 'mitigated', + 'unexplored', + 'ignored', + ] + handleActive(key, 'filter-products') + filterProducts(classes[key]) +} diff --git a/cve_bin_tool/output_engine/html_reports/templates/base.html b/cve_bin_tool/output_engine/html_reports/templates/base.html index e9c88e2293..33d575efc3 100644 --- a/cve_bin_tool/output_engine/html_reports/templates/base.html +++ b/cve_bin_tool/output_engine/html_reports/templates/base.html @@ -98,8 +98,16 @@
Products Scanned
-
- + + +
@@ -260,4 +268,4 @@

How to Contribute?

- \ No newline at end of file + diff --git a/cve_bin_tool/output_engine/html_reports/templates/row_product.html b/cve_bin_tool/output_engine/html_reports/templates/row_product.html index e334247fb5..72b3c59e7d 100644 --- a/cve_bin_tool/output_engine/html_reports/templates/row_product.html +++ b/cve_bin_tool/output_engine/html_reports/templates/row_product.html @@ -1,5 +1,5 @@ + data-bs-target="#modal{{ fix_id }}" remarks="{{remarks}}"> - {{ new_cves }} - {% if confirmed_cves %} - - {{ confirmed_cves }} - {%endif%} - {% if mitigated_cves %} - - {{ mitigated_cves }} - {%endif%} - - {% if unexplored_cves %} - - {{ unexplored_cves }} - {%endif%} - - {% if ignored_cves %} - - {{ ignored_cves }} - {%endif%} +
+ {{ new_cves }} +
+
+ {{ confirmed_cves }} +
+
+ {{ mitigated_cves }} +
+
+ {{ unexplored_cves }} +
+
+ {{ ignored_cves }} +
diff --git a/doc/MANUAL.md b/doc/MANUAL.md index 6f8d9eb7b6..56090930cb 100644 --- a/doc/MANUAL.md +++ b/doc/MANUAL.md @@ -643,6 +643,10 @@ The unexplored and new CVEs will be highlighted, it will look something like thi ![image](/images/html_highlight.png) +You can also filter scanned products by remark: + +![image](/images/html_filter.png) + 5. `--format pdf` - creates a report in PDF format. If you wish to use PDF support, you will need to install the `reportlab` diff --git a/doc/images/html_filter.png b/doc/images/html_filter.png new file mode 100644 index 0000000000..b60090e15b Binary files /dev/null and b/doc/images/html_filter.png differ diff --git a/test/sample_report/html_report.html b/test/sample_report/html_report.html index 0fd866ad5a..69316ad916 100644 --- a/test/sample_report/html_report.html +++ b/test/sample_report/html_report.html @@ -283,8 +283,16 @@
Products Scanned
-
- + + +
@@ -324,7 +332,7 @@
Products Scanned
+ data-bs-target="#modalvendor0product010" remarks="new "> -
  • +
    +
  • CVE-1234-1234 NEW @@ -450,12 +454,19 @@
    Severity
    target="_blank" rel="noopener noreferrer">..read more

  • - - - - - - +
    +
    + +
    +
    + +
    +
    + +
    +
    + +
    @@ -472,7 +483,7 @@
    Severity Analysis of product0 1.0
    -
    +
    @@ -502,7 +513,7 @@
    + data-bs-target="#modalvendor0product0286" remarks="new ">
    @@ -510,14 +521,16 @@
    product0  + NEW +
    2.8.6
    - 1 + 1
    @@ -583,7 +589,8 @@
    Severity
    -
  • +
    +
  • CVE-1234-1234 NEW @@ -606,12 +613,19 @@
    Severity
    target="_blank" rel="noopener noreferrer">..read more

  • - - - - - - + +
    + +
    +
    + +
    +
    + +
    +
    + +
    @@ -628,7 +642,7 @@
    Severity Analysis of product0 2.8.6
    -
    +
    @@ -658,7 +672,7 @@
    + data-bs-target="#modalvendor1product13210" remarks="new ">
    @@ -666,14 +680,16 @@
    product1  + NEW +
    3.2.1.0
    - 1 + 1
    @@ -739,7 +748,8 @@
    Severity
    -
  • +
    +
  • CVE-1234-1234 NEW @@ -762,12 +772,19 @@
    Severity
    target="_blank" rel="noopener noreferrer">..read more

  • - - - - - - + +
    + +
    +
    + +
    +
    + +
    +
    + +
    @@ -784,7 +801,7 @@
    Severity Analysis of product1 3.2.1.0
    -
    +
    @@ -1157,44 +1174,116 @@

    How to Contribute?

    diff --git a/test/test_output_engine.py b/test/test_output_engine.py index c8a90307e1..b041ff0b98 100644 --- a/test/test_output_engine.py +++ b/test/test_output_engine.py @@ -990,8 +990,7 @@ def test_output_html(self): # Test highlight new/unexplored feature assert ( - """ product1  - NEW""" + """product1 \n \n NEW""" in result )