Skip to content

Commit

Permalink
Updated AJAX for Nessus listing
Browse files Browse the repository at this point in the history
  • Loading branch information
DaleBinghamSoteriaSoft committed Nov 3, 2023
1 parent 01e046d commit 9a5aa01
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 35 deletions.
40 changes: 7 additions & 33 deletions js/openrmf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2556,44 +2556,18 @@ async function getReportsBySystem() {
// run the Nessus report
async function getNessusPatchScanReport() {
var systemGroupId = $("#checklistSystemFilter").val();
if (!systemGroupId || systemGroupId.length == 0)
{
swal("Please choose a system for the report.", "Click OK to continue!", "error");
if (!systemGroupId || systemGroupId.length == 0) {
swal("Please choose a system package for the report.", "Click OK to continue!", "error");
return;
}
// call the report API /reports/nessus/xxxxxxxxxxxx
$.blockUI({ message: "Generating the Nessus ACAS Patch Report ...please wait" , css: { padding: '15px'} });
var url = reportAPI + "system/" + systemGroupId + "/acaspatchdata";
//var url = reportAPI + "system/" + systemGroupId + "/acaspatchdata";
// get back the data
let response = await fetch(url, {headers: {
'Authorization': 'Bearer ' + keycloak.token
}});
if (response.ok) {
// put into a datatable like the others
var table = $('#tblReportNessus').DataTable(); // the datatable reference to do a row.add() to
table.clear().draw();
var data = await response.json();
if (data && data.length > 0) {
// use the Report Name
$("#reportNessusReportName").html("Nessus Scan Report: " + data[0].reportName);
}
for (const item of data) {
// dynamically add to the datatable but only show main data, click the + for extra data
table.row.add( { "hostname": item.hostname, "pluginId": item.pluginId,
"pluginName": item.pluginName, "severity": item.severity + ' - ' + item.severityName,
"hostTotal": item.hostTotal, "total": item.total, "family": item.family,
"description": item.description, "publicationDate": item.publicationDate,
"pluginType": item.pluginType, "riskFactor": item.riskFactor, "synopsis": item.synopsis,
"severityNumber": item.severity
}).draw();
}
$.unblockUI();
}
else {
$.unblockUI();
swal("There was a problem running your report. Please check with the Application Administrator to see if all services are running.", "Click OK to continue!", "error");
throw new Error(response.status)
}

var table = $('#tblReportNessus').DataTable(); // the datatable reference to do a row.add() to
table.clear().draw();
table.ajax.url(reportAPI + "system/" + systemGroupId + "/acaspatchdata/").load(finalizeLoadingTable);
}
// run the area chart report by system
async function getSystemTotalsByTypeReport() {
Expand Down
2 changes: 1 addition & 1 deletion reports/controls.html
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,11 @@ <h3><i class="fa fa-table"></i> RMF Controls Listing</h3>
] //,order: [[ 1, 'asc' ], [2,'asc']]
});


$.fn.dataTable.ext.errMode = function(obj,param,err){
var tableId = obj.sTableId;
//console.log('Handling DataTable issue of Table '+tableId);
};

// Add event listener for opening and closing details
$('#tblReportControls tbody').on('click', 'td.details-control', function () {
var tr = $(this).closest('tr');
Expand Down
16 changes: 15 additions & 1 deletion reports/nessus.html
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,14 @@ <h3 id="reportNessusReportName"></h3>

// setup the table
var tableNessus = $('#tblReportNessus').DataTable({
"responsive": false,
"searching": true,
"pageLength": 25,
"autoWidth": false,
"deferRender": true,
"ajax": {
"dataSrc": ""
},
"columns": [
{
"className": 'details-control',
Expand All @@ -228,7 +235,7 @@ <h3 id="reportNessusReportName"></h3>
"className": 'text-center',
"data": null,
"render": function (data, type, full, meta) {
return '<span style="padding: 5px;" class="' + getPatchVulnerabilityClassName(data.severityNumber) + '">' + data.severity + '</span>';
return '<span style="padding: 5px;" class="' + getPatchVulnerabilityClassName(data.severity) + '">' + data.severity + ' - ' + data.severityName + '</span>';
}
}
],
Expand Down Expand Up @@ -259,6 +266,13 @@ <h3 id="reportNessusReportName"></h3>
tr.addClass('shown');
}
});

$.fn.dataTable.ext.errMode = function(obj,param,err){
var tableId = obj.sTableId;
//console.log('Handling DataTable issue of Table '+tableId);
};

$('#tblReportNessus').DataTable().clear().draw();
}
else {
alert('You are not logged in. Please check your setup with Keycloak.');
Expand Down

0 comments on commit 9a5aa01

Please sign in to comment.