Skip to content

Commit

Permalink
change modal for downloading report
Browse files Browse the repository at this point in the history
  • Loading branch information
yogeshojha committed Aug 28, 2024
1 parent 0a634e7 commit e3e6409
Showing 1 changed file with 109 additions and 74 deletions.
183 changes: 109 additions & 74 deletions web/startScan/templates/startScan/history.html
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ <h4 class="headline-title">Filters</h4>
<div class="dropdown-divider"></div>
{% endif %}
{% if scan.scan_status != -1%}
<a href="#" class="dropdown-item text-dark" onclick="initiate_report({{scan_history.id}}, '{% if 'subdomain_discovery' in scan_history.scan_type.tasks %}True{% endif %}', '{% if 'vulnerability_scan' in scan_history.scan_type.tasks %}True{% endif %}', '{{ scan_history.domain.name }}')">
<a href="#" class="dropdown-item text-dark" onclick="initiate_report(id={{scan_history.id}}, has_subdomain_scan={% if 'subdomain_discovery' in scan_history.scan_type.tasks %}true{% else %}false{% endif %}, has_vulnerability_scan={% if 'vulnerability_scan' in scan_history.scan_type.tasks %}true{% else %}false{% endif %}, domain_name='{{ scan_history.domain.name }}')">
<i class="fe-download"></i>&nbsp;Scan Report</a>
{% endif %}
</div>
Expand All @@ -213,30 +213,87 @@ <h4 class="headline-title">Filters</h4>
</div>
</div>
</div>
<div class="modal fade" id="generateReportModal" tabindex="-1" style="display: none;" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="myCenterModalLabel">Download Report</h4>
<div class="modal fade" id="generateReportModal" tabindex="-1" aria-labelledby="modalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered">
<div class="modal-content border-0 shadow">
<div class="modal-header bg-light border-bottom-0">
<h5 class="modal-title" id="modalLabel">Generate Report</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="alert alert-light-primary border-0 mb-4" role="alert">
<div id='report_alert_message'></div>
</div>
<div class="form-group mb-4">
<label for="reportTypeForm">Report Type</label>
<select class="form-control" id="report_type_select" name="report_type">
</select>
<div class="container-fluid">
<h6 class="text-primary mb-3">Select Report Type</h6>
<div class="row g-3 mb-4">
<div class="col-md-4">
<div class="card h-100 border-0 shadow-sm">
<div class="card-body">
<div class="form-check">
<input class="form-check-input" type="radio" name="reportType" id="report_type_checkbox" value="full" checked>
<label class="form-check-label w-100" for="fullScan">
<h6 class="mb-2">Full Scan</h6>
<p class="text-muted small mb-0">Comprehensive analysis including Recon and Vulnerabilities</p>
</label>
</div>
</div>
<div class="card-footer border-0 text-primary bg-soft-primary"> Complete Overview </div>
</div>
</div>
<div class="col-md-4">
<div class="card h-100 border-0 shadow-sm">
<div class="card-body">
<div class="form-check">
<input class="form-check-input" type="radio" name="reportType" id="report_type_checkbox" value="recon" disabled>
<label class="form-check-label w-100" for="reconReport">
<h6 class="mb-2">Reconnaissance</h6>
<p class="text-muted small mb-0">Report containing detailed overview of discovered assets only</p>
</label>
</div>
</div>
<div class="card-footer border-0 text-info bg-soft-info"> Asset Mapping </div>
</div>
</div>
<div class="col-md-4">
<div class="card h-100 border-0 shadow-sm">
<div class="card-body">
<div class="form-check">
<input class="form-check-input" type="radio" name="reportType" id="report_type_checkbox" value="vuln" disabled>
<label class="form-check-label w-100" for="vulnReport">
<h6 class="mb-2">Vulnerability</h6>
<p class="text-muted small mb-0">Report focused on the identified vulnerabilities and remediation</p>
</label>
</div>
</div>
<div class="card-footer border-0 text-danger bg-soft-danger"> Risk Assessment </div>
</div>
</div>
</div>
<div class="row g-3">
<div class="col-md-6">
<h6 class="text-primary mb-3">Report Template</h6>
<select id="templateSelect" class="form-select" aria-label="Select report template">
<option value="modern">Modern Template</option>
<option value="default">Default Template</option>
</select>
</div>
<div class="col-md-6">
<h6 class="text-primary mb-3">Additional Options</h6>
<div class="form-check form-switch" id="report_info_vuln_div">
<input class="form-check-input" type="checkbox" id="excludeInfoFindings" name="excludeInfoFindings" checked>
<label class="form-check-label" for="excludeInfoFindings"> Exclude Informational Findings </label>
</div>
</div>
</div>
</div>
<div class="form-group mb-4">
<div class="form-check" id="report_info_vuln_div">
<input type="checkbox" class="form-check-input" id="report_ignore_info_vuln" checked="">
<label class="form-check-label" for="report_ignore_info_vuln">Ignore Informational Vulnerabilities</label>
</div>
<div class="modal-footer bg-light border-top-0">
<div class="container-fluid">
<div class="row justify-content-end">
<div class="col-auto">
<button type="button" class="btn btn-outline-primary me-2" id="previewReportBtn">Preview Report</button>
<button type="button" class="btn btn-primary" id="generateReportBtn">Download Report</button>
</div>
</div>
</div>
<a id='generateReportButton' href="#" class="btn btn-primary float-end m-2">Download Report</a>
<a id='previewReportButton' href="#" class="btn btn-secondary float-end m-2">Preview Report</a>
</div>
</div>
</div>
Expand Down Expand Up @@ -572,67 +629,45 @@ <h4 class="modal-title" id="myCenterModalLabel">Download Report</h4>
}
}

// select option listener for report_type_select
var report_type = document.getElementById("report_type_select");
report_type.addEventListener("change", function() {
if(report_type.value == "recon")
{
$("#report_info_vuln_div").hide();
}
else{
$("#report_info_vuln_div").show();
}
$('input[name="reportType"]').on('change', function() {
if (this.value === 'recon') {
$('input[name="excludeInfoFindings"]').prop('disabled', true);
} else {
$('input[name="excludeInfoFindings"]').prop('disabled', false);
}
});

function initiate_report(id, is_subdomain_scan, is_vulnerability_scan, domain_name) {
$('#generateReportModal').modal('show');
$('#report_alert_message').empty();
$('#report_type_select').empty();
if (is_subdomain_scan == 'True' && is_vulnerability_scan == 'True') {
$('#report_alert_message').append(`
<b>Full Scan</b> will include both Reconnaissance and Vulnerability Report.<br>
`);

$('#report_type_select').append($('<option>', {
value: 'full',
text: 'Full Scan Report'
}));
}

if (is_subdomain_scan == 'True') {
// eligible for reconnaissance report
$('#report_alert_message').append(`
<b>Reconnaissance Report</b> will only include Assets Discovered Section.<br>
`);
$('#report_type_select').append($('<option>', {
value: 'recon',
text: 'Reconnaissance Report'
}));
}
function initiate_report(id, has_subdomain_scan, has_vulnerability_scan, domain_name) {
console.log(has_subdomain_scan, has_vulnerability_scan, domain_name);
//select full report type by default
$('input[name="reportType"][value="full"]').prop('checked', true);
$('input[name="excludeInfoFindings"]').prop('checked', true);
$('#generateReportModal').modal('show');
if (has_subdomain_scan) {
$('input[name="reportType"][value="recon"]').prop('disabled', false);
} else {
$('input[name="reportType"][value="recon"]').prop('disabled', true);
}

if (is_vulnerability_scan == 'True'){
// eligible for vulnerability report
$('#report_alert_message').append(`
<b>Vulnerability Report</b> will only include details of Vulnerabilities Identified.
`);
$('#report_type_select').append($('<option>', {
value: 'vulnerability',
text: 'Vulnerability Report'
}));
}
$('#generateReportButton').attr('onClick', `generate_report(${id}, '${domain_name}')`);
$('#previewReportButton').attr('onClick', `preview_report(${id}, '${domain_name}')`);
if (has_vulnerability_scan) {
$('input[name="reportType"][value="vuln"]').prop('disabled', false);
} else {
$('input[name="reportType"][value="vuln"]').prop('disabled', true);
}

function preview_report(id, domain_name){
var report_type = $("#report_type_select option:selected").val();
var url = `/scan/create_report/${id}?report_type=${report_type}`;
if ($('#report_ignore_info_vuln').is(":checked")) {
url += `&ignore_info_vuln`
}
$('#generateReportModal').modal('hide');
window.open(url, '_blank').focus();
$('#generateReportBtn').attr('onClick', `generate_report(${id}, '${domain_name}')`);
$('#previewReportBtn').attr('onClick', `preview_report(${id}, '${domain_name}')`);
}

function preview_report(id, domain_name){
var report_type = $("#report_type_select option:selected").val();
var url = `/scan/create_report/${id}?report_type=${report_type}`;
if ($('#report_ignore_info_vuln').is(":checked")) {
url += `&ignore_info_vuln`
}
$('#generateReportModal').modal('hide');
window.open(url, '_blank').focus();
}

function generate_report(id, domain_name) {
var report_type = $("#report_type_select option:selected").val();
Expand Down

0 comments on commit e3e6409

Please sign in to comment.