Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions cve_bin_tool/output_engine/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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"]),
Expand Down
112 changes: 92 additions & 20 deletions cve_bin_tool/output_engine/html_reports/js/main.js
Original file line number Diff line number Diff line change
@@ -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";
}
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])
}
14 changes: 11 additions & 3 deletions cve_bin_tool/output_engine/html_reports/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,16 @@ <h5 class="font-weight-light p-t-5">Products Scanned
</div>

<div class="row m-b-10">
<div class="col-9">

<div class="list-group list-group-horizontal col-6 px-3" id="filter-products">
<a class="list-group-item list-group-item-action active" onclick="filterProductsByRemark(0)">All</a>
<a class="list-group-item list-group-item-action" onclick="filterProductsByRemark(1)">New</a>
<a class="list-group-item list-group-item-action" onclick="filterProductsByRemark(2)">Confirmed</a>
<a class="list-group-item list-group-item-action" onclick="filterProductsByRemark(3)">Mitigated</a>
<a class="list-group-item list-group-item-action" onclick="filterProductsByRemark(4)">Unexplored</a>
<a class="list-group-item list-group-item-action" onclick="filterProductsByRemark(5)">Ignored</a>
</div>

<div class="col-3">
</div>

<div class="col-3">
Expand Down Expand Up @@ -260,4 +268,4 @@ <h4>How to Contribute?</h4>
</script>
</body>

</html>
</html>
63 changes: 28 additions & 35 deletions cve_bin_tool/output_engine/html_reports/templates/row_product.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
<a onclick="resizeGraph(this)" class="list-group-item list-group-item-action" data-bs-toggle="modal"
data-bs-target="#modal{{ fix_id }}">
data-bs-target="#modal{{ fix_id }}" remarks="{{remarks}}">

<div class="row">
<div class="col-sm-5 ">
{{ vendor }}
</div>
<div class="col-sm-3">
{{ name }}&nbsp;
<span class="badge badge-pill badge-danger">{{ remark }}</span>
{% if new_cves %}
<span class="badge badge-pill badge-danger">NEW</span>
{% elif unexplored_cves %}
<span class="badge badge-pill badge-danger">UNEXPLORED</span>
{% endif %}
</div>
<div class="col-sm-2">
{{ version }}
</div>

<div class="col-sm-2">
<span class="badge badge-pill badge-primary">{{ cve_count }}</span>
<span class="badge badge-pill badge-primary cve-count" total-cve-count={{ cve_count }}>{{ cve_count }}</span>
<div class="float-right">
<svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-chevron-right" fill="currentColor"
xmlns="http://www.w3.org/2000/svg">
Expand Down Expand Up @@ -49,19 +53,12 @@ <h5 class="modal-title" id="exampleModalLabel"> Vendor: <span
<div class="col-12 m-t-10 m-b-5">
<h5>Filter by Remarks</h5>
<div id="list-cve{{fix_id}}" class="list-group list-group-horizontal">
<a class="list-group-item list-group-item-action active d-flex justify-content-between align-items-center"
href="#remark-new{{ fix_id }}">
New
<span class="badge badge-primary badge-pill">{{ new_cve_count }}</span>
</a>
<a class="list-group-item list-group-item-action"
href="#remark-confirmed{{fix_id}}">Confirmed</a>
<a class="list-group-item list-group-item-action"
href="#remark-mitigated{{fix_id}}">Mitigated</a>
<a class="list-group-item list-group-item-action"
href="#remark-unexplored{{fix_id}}">Unexplored</a>
<a class="list-group-item list-group-item-action"
href="#remark-ignored{{fix_id}}">Ignored</a>
<a class="list-group-item list-group-item-action active" onclick="filterByRemark(0, '{{fix_id}}')">All</a>
<a class="list-group-item list-group-item-action" onclick="filterByRemark(1, '{{fix_id}}')">New</a>
<a class="list-group-item list-group-item-action" onclick="filterByRemark(2, '{{fix_id}}')">Confirmed</a>
<a class="list-group-item list-group-item-action" onclick="filterByRemark(3, '{{fix_id}}')">Mitigated</a>
<a class="list-group-item list-group-item-action" onclick="filterByRemark(4, '{{fix_id}}')">Unexplored</a>
<a class="list-group-item list-group-item-action" onclick="filterByRemark(5, '{{fix_id}}')">Ignored</a>
</div>
</div>
<div class="col-12 m-t-5 m-b-10">
Expand All @@ -80,25 +77,21 @@ <h6><strong>Severity</strong></h6>
</div>
</div>
</div>
{{ new_cves }}
{% if confirmed_cves %}
<span id="remark-confirmed{{ fix_id}}"></span>
{{ confirmed_cves }}
{%endif%}
{% if mitigated_cves %}
<span id="remark-mitigated{{ fix_id}}"></span>
{{ mitigated_cves }}
{%endif%}

{% if unexplored_cves %}
<span id="remark-unexplored{{ fix_id}}"></span>
{{ unexplored_cves }}
{%endif%}

{% if ignored_cves %}
<span id="remark-ignored{{ fix_id}}"></span>
{{ ignored_cves }}
{%endif%}
<div class="new">
{{ new_cves }}
</div>
<div class="confirmed">
{{ confirmed_cves }}
</div>
<div class="mitigated">
{{ mitigated_cves }}
</div>
<div class="unexplored">
{{ unexplored_cves }}
</div>
<div class="ignored">
{{ ignored_cves }}
</div>
</ul>
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions doc/MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
Binary file added doc/images/html_filter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading