Skip to content

Commit

Permalink
Merge pull request #170 from gavsto/dev
Browse files Browse the repository at this point in the history
NEW FEATURE: Domain Analyser
  • Loading branch information
gavsto authored Nov 2, 2021
2 parents 3469ce0 + 1322613 commit 091a147
Show file tree
Hide file tree
Showing 4 changed files with 351 additions and 2 deletions.
95 changes: 95 additions & 0 deletions DomainAnalyserList.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<main>
<header class="page-header page-header-compact page-header-light border-bottom bg-white mb-4">
<div class="container-fluid px-4">
<div class="page-header-content">
<div class="row align-items-center justify-content-between pt-3">
<div class="col-auto mb-3">
<h1 class="page-header-title">
<div class="page-header-icon"><i data-feather="user"></i></div>
Domain Analyser List
</h1>
</div>
<div class="col-12 col-xl-auto mb-3">
<a class="btn btn-sm btn-light text-primary" href="index.html?page=users.html">
<i class="me-1" data-feather="users"></i>
Manage Users
</a>
<a class="btn btn-sm btn-light text-primary" href="index.html?page=users.html">
<i class="me-1" data-feather="user-plus"></i>
Manage Groups
</a>
</div>
</div>
</div>
</div>
</header>
<!-- Main page content-->
<div class="container-fluid px-4">
<div class="card">
<div class="card-header">Domain Analyser</div>
<div class="card-body">
<table id="datatablesSimple">
<table cellpadding="0" cellspacing="0" class="datatable-1 table table-striped" width="100%">
<thead>
<tr>
<th>Domain</th>
<th>Security Score</th>
<th>Mail Provider</th>
<th>SPF Pass Test</th>
<th>MX Pass Test</th>
<th>DMARC Present</th>
<th>DMARC Action Policy</th>
<th>DMARC % Pass</th>
<th>DNSSec Enabled</th>
<th>DKIM Enabled</th>
<th>More Info</th>
</tr>
</thead>
<tbody id='AccountTable'>
</tbody>
<tfoot>
<tr>
<th>Domain</th>
<th>Security Score</th>
<th>Mail Provider</th>
<th>SPF Pass Test</th>
<th>MX Pass Test</th>
<th>DMARC Present</th>
<th>DMARC Action Policy</th>
<th>DMARC % Pass</th>
<th>DNSSec Enabled</th>
<th>DKIM Enabled</th>
<th>More Info</th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</main>
<script src="js/datatables/jquery.dataTables.js"></script>
<script src="js/datatables/datatablesDomainAnalyser.js"></script>

</body>

<button class="btn btn-primary" id="PopModal" type="button" data-bs-toggle="modal" data-bs-target="#exampleModal"
style="display:none;"></button>
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Results</h5>
</div>
<div class="modal-body">
<section id="APIContent">
<div class="spinner-border text-primary" role="status">
<span class="sr-only"></span>
</div></span>
</section>
</div>

</div>
</div>

</html>
3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ <h6 class="dropdown-header d-flex align-items-center">
<nav class="sidenav-menu-nested nav accordion" id="accordionSidenavPages">
<a class="nav-link" apilink="tenants" href="index.html?page=tenants">Tenants</a>
</nav>
<nav class="sidenav-menu-nested nav accordion" id="accordionSidenavPages">
<a class="nav-link" apilink="DomainAnalyserList" href="index.html?page=DomainAnalyserList">Domains</a>
</nav>
</div>
</section>

Expand Down
251 changes: 251 additions & 0 deletions js/datatables/datatablesDomainAnalyser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
$(document).ready(function () {
let searchParams = new URLSearchParams(window.location.search)
var TenantID = '';
if (searchParams.has('Tenantfilter')) {
TenantID = searchParams.get('Tenantfilter')
}

var todayDate = new Date().toISOString().slice(0, 10);
$('.datatable-1').dataTable(
{
"scrollX": true,
language: {
paginate: {
next: '<i class="fas fa-arrow-right"></i>',
previous: '<i class="fas fa-arrow-left"></i>'
}
},
"columnDefs": [
{ "className": "dt-center", "targets": [-1] },

],
"deferRender": true,
"pageLength": 50,
responsive: true,
"ajax": {

"url": "/api/DomainAnalyser_List",
"dataSrc": ""
},
dom: 'fBlrtip',
buttons: [
{ extend: 'copyHtml5', className: 'btn btn-primary btn-sm' },
{ extend: 'excelHtml5', className: 'btn btn-primary btn-sm', title: 'Domain Analyser - ' + todayDate, exportOptions: { orthogonal: "export" } },
{ extend: 'csvHtml5', className: 'btn btn-primary btn-sm', title: 'Domain Analyser - ' + todayDate, exportOptions: { orthogonal: "export" } },
{ extend: 'pdfHtml5', className: 'btn btn-primary btn-sm', pageSize: 'A2', orientation: 'landscape', title: 'Domain Analyser - ' + todayDate, exportOptions: { columns: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], orthogonal: "export" } },
{
text: 'Force Refresh All Data',
className: 'btn btn-primary btn-sm',
action: function (e, dt, button, config) {
$('#APIContent').html('<center><label class="form-check-label" >Are you sure you want to force the Domain Analysis to run? This will slow down normal usage considerably. Please note: this runs at midnight automatically every day. <br /><br /></label><br><nothing class="APIConfirmed"><a href="/api/DomainAnalyser_OrchestrationStarter"><button id="Confirmed" class="btn btn-primary APIConfirmed">Yes</button></a></nothing><nothing class="APIDenied"> <button data-bs-dismiss="modal" class="btn btn-primary APIDenied">No</button></center>');

document.getElementById("PopModal").click();
}
}
],
"columns": [
{ "data": "Domain" },
{
"data": "Score",
"render": function (data, type, row) {
if (type === "export") {
return data + ' / ' + row.MaximumScore;
}
if (type === "sort" || type === "filter") {
return row.ScorePercentage;
}
if (data === "") { return '<h5><span class="badge bg-secondary">No Data</span></h5>' }
if (row.ScorePercentage <= 40) { var colourCalculation = "bg-danger" }
if (row.ScorePercentage > 40 && row.ScorePercentage <= 75) { var colourCalculation = "bg-warning" }
if (row.ScorePercentage > 75) { var colourCalculation = "bg-success" }
return '<div class="progress"><div class="progress-bar ' + colourCalculation + '" role="progressbar" style="width: ' + row.ScorePercentage + '%" aria-valuenow="' + data + '" aria-valuemin="0" aria-valuemax="' + row.MaximumScore + '">' + row.ScorePercentage + '%</div></div>'
}
},
{ "data": "MailProvider" },
{
"data": "SPFPassTest",
"render": function (data, type, row) {
if (type === "export" || type === "sort" || type === "filter") {
if (data === true) {
return 'PASS: SPF Present'
} else if (data === false) {
return 'FAIL: SPF Missing or Misconfigured'
} else {
return 'No Data'
}
}
if (data === true) {
if (row.SPFPassAll === true) {
return '<h5><span class="badge bg-success">SPF Pass</span></h5>';
}
else
{
return '<h5><span class="badge bg-danger">SPF Soft Fail</span></h5>';
}
}
if (data === false) {
return '<h5><span class="badge bg-danger">SPF Fail</span></h5>';
} else {
return '<h5><span class="badge bg-secondary">No Data</span></h5>'
}
}
},
{
"data": "MXPassTest",
"render": function (data, type, row) {
if (type === "export" || type === "sort" || type === "filter") {
if (data === true) {
return 'PASS: MX Match Present'
} else if (data === false) {
return 'FAIL: MX Not Matching MS Recommendations'
} else {
return 'No Data'
}
}
if (data === true) {
return '<h5><span class="badge bg-success">MX Pass</span></h5>';
}
if (data === false) {
return '<h5><span class="badge bg-danger">MX Fail</span></h5>';
} else {
return '<h5><span class="badge bg-secondary">No Data</span></h5>'
}
}
},
{
"data": "DMARCPresent",
"render": function (data, type, row) {
if (type === "export" || type === "sort" || type === "filter") {
if (data === true) {
return 'PASS: DMARC Record Present'
} else if (data === false) {
return 'FAIL: DMARC Not Present'
} else {
return 'No Data'
}
}
if (data === true) {
return '<h5><span class="badge bg-success">DMARC Present</span></h5>';
}
if (data === false) {
return '<h5><span class="badge bg-danger">DMARC Missing</span></h5>';
} else {
return '<h5><span class="badge bg-secondary">No Data</span></h5>'
}
}
},
{
"data": "DMARCActionPolicy",
"render": function (data, type, row) {
if (type === "export" || type === "sort" || type === "filter") {
if (data === "Reject") {
return 'PASS: DMARC Set to Reject'
} else if (data === "Quarantine") {
return 'WARN: DMARC Quarantining Only'
} else if (data === "None") {
return 'FAIL: DMARC Reporting Only'
} else {
return 'No DMARC'
}
}
if (data === "Reject") {
return '<h5><span class="badge bg-success">Reject</span></h5>'
} else if (data === "Quarantine") {
return '<h5><span class="badge bg-warning">Quarantine Only</span></h5>'
} else if (data === "None") {
return '<h5><span class="badge bg-danger">Report Only</span></h5>'
} else {
return '<h5><span class="badge bg-secondary">No DMARC</span></h5>'
}
}
},
{
"data": "DMARCPercentagePass",
"render": function (data, type, row) {
if (type === "export" || type === "sort" || type === "filter") {
if (data === true) {
return 'PASS: DMARC All Mail Fully Reported'
} else if (data === false) {
return 'FAIL: DMARC All Mail Not Considered'
} else {
return 'No DMARC'
}
}
if (data === true) {
return '<h5><span class="badge bg-success">All Mail Analysed</span></h5>';
}
if (data === false) {
return '<h5><span class="badge bg-danger">Partial or None Analysed</span></h5>';
} else {
return '<h5><span class="badge bg-secondary">No DMARC</span></h5>'
}
}
},
{
"data": "DNSSECPresent",
"render": function (data, type, row) {
if (type === "export" || type === "sort" || type === "filter") {
if (data === true) {
return 'PASS: DNSSEC Present'
} else if (data === false) {
return 'FAIL: DNSSEC Not Enabled or Configured'
} else {
return 'No Data'
}
}
if (data === true) {
return '<h5><span class="badge bg-success">DNSSEC Enabled</span></h5>';
}
if (data === false) {
return '<h5><span class="badge bg-danger">DNSSEC Disabled</span></h5>';
} else {
return '<h5><span class="badge bg-secondary">No Data</span></h5>'
}
}
},
{
"data": "DKIMEnabled",
"render": function (data, type, row) {
if (type === "export" || type === "sort" || type === "filter") {
if (data === true) {
return 'PASS: DKIM Enabled'
} else if (data === false) {
return 'FAIL: DKIM not Present'
} else {
return 'No Data'
}
}
if (data === true) {
return '<h5><span class="badge bg-success">DKIM Enabled</span></h5>';
}
if (data === false) {
return '<h5><span class="badge bg-danger">DKIM Disabled</span></h5>';
} else {
return '<h5><span class="badge bg-secondary">No Data</span></h5>'
}
}
},
{
"data": "ActualMXRecord",
"render": function (data, type, row) {
if (type === "export" || type === "sort" || type === "filter") {
return 'No Data'
}
return '<button type="button" class="btn btn-warning btn-sm" data-bs-toggle="modal" data-bs-target="#' + row.GUID + 'MoreInfo">More</button><!-- Modal --><div class="modal fade" id="' + row.GUID + 'MoreInfo" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true"><div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h5 class="modal-title" id="exampleModalLabel">More Information</h5><button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button></div><div class="modal-body"><h3>Tenant: ' + row.Tenant + '</h3><br /><br /><strong>Score Explanation: </strong>' + row.ScoreExplanation + '<br /><br /><strong>Expected SPF Record: </strong> ' + row.ExpectedSPFRecord + '<br /><strong>Actual SPF Record: </strong>' + row.ActualSPFRecord + '<br /><br /><strong>DMARC Full Policy: </strong>' + row.DMARCFullPolicy + '<br /><br /><strong>Expected MX Record: </strong>' + row.ExpectedMXRecord + '<br /><strong>Actual MX Record: </strong>' + row.ActualMXRecord + '<br /><br /><strong>Supported Services: </strong>' + row.SupportedServices + '<br /><strong>Is Default Domain: </strong>' + row.IsDefault + '<br /><strong>Data Last Refreshed:</strong>' + row.LastRefresh + '</div><div class="modal-footer"><button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button></div></div></div></div>'
}
}
],
'columnDefs': [
{
"targets": [1, 2, 3, 4, 5, 6, 7, 8, 9], // your case first column
"className": "text-center align-middle"
}
],
"order": [[0, "asc"]],
}
);


$('.dataTables_paginate').addClass("btn-group datatable-pagination");
$('.dataTables_paginate > a').wrapInner('<span />');
});
Loading

0 comments on commit 091a147

Please sign in to comment.