Skip to content

Commit

Permalink
Fixed the binary icon
Browse files Browse the repository at this point in the history
  • Loading branch information
lkarlslund committed Feb 14, 2024
1 parent 7bb60bb commit 5a023f3
Show file tree
Hide file tree
Showing 4 changed files with 261 additions and 372 deletions.
111 changes: 58 additions & 53 deletions modules/analyze/html/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,67 +313,73 @@ function analyze(e) {
});
}

function refreshStatus() {
function refreshProgress() {
var lastwasidle = false
$.ajax({
type: "GET",
url: "/progress",
dataType: "json",
timeout: 5000,
success: function (progressbars) {
$("#offlineblur").hide()
if (progressbars.length > 0) {
lastwasidle = false
keepProgressbars = new Set()
for (i in progressbars) {
progressbar = progressbars[i]
if (progressbar.Done) {
continue
}
keepProgressbars.add(progressbar.ID)
var progressSocket = new WebSocket(location.origin.replace(/^http/, 'ws') + '/progress');

progressSocket.onerror = function (event) {
$("#backendstatus").html("Adalanche backend is still offline");
$("#upperstatus").show();
$("#progressbars").empty().hide();
$("#offlineblur").show();
setTimeout(refreshProgress, 3000);
};

progressSocket.onclose = function (event) {
$("#backendstatus").html("Adalanche backend is offline");
$("#upperstatus").show();
$("#progressbars").empty().hide();
$("#offlineblur").show();
setTimeout(refreshProgress, 3000);
}

// find progressbar
pb = $("#"+progressbar.ID)
if (pb.length == 0 && !progressbar.Done) {
$("#progressbars").append(`<div class="progress-group"><span class="progress-group-label">` + progressbar.Title + `</span><div class="progress"><div id="` + progressbar.ID + `" class="progress-bar rounded-0" role="progressbar" aria-valuemin="0" aria-valuemax="100"></div></div><span class="progress-group-label"></span></div>`)
pb = $("#" + progressbar.ID)
}
progressSocket.onmessage = function (progressbars) {
$("#offlineblur").hide()
if (progressbars.length > 0) {
lastwasidle = false
keepProgressbars = new Set()
for (i in progressbars) {
progressbar = progressbars[i]
if (progressbar.Done) {
continue
}
keepProgressbars.add(progressbar.ID)

// Update progressbar
pb.attr("aria-valuenow", progressbar.Percent.toFixed(0))
pb.css("width", progressbar.Percent.toFixed(0)+"%")
pb.parent().next().html(progressbar.Percent.toFixed(2)+"%")
// find progressbar
pb = $("#"+progressbar.ID)
if (pb.length == 0 && !progressbar.Done) {
$("#progressbars").append(`<div class="progress-group"><span class="progress-group-label">` + progressbar.Title + `</span><div class="progress"><div id="` + progressbar.ID + `" class="progress-bar rounded-0" role="progressbar" aria-valuemin="0" aria-valuemax="100"></div></div><span class="progress-group-label"></span></div>`)
pb = $("#" + progressbar.ID)
}
// remove old progressbars
$("#progressbars .progress-bar").each(function (index) {
id = $(this).attr('id')
if (!keepProgressbars.has(id)) {
$(this).parent().parent().slideUp("slow", function () { $(this).remove(); })
}
})

$("#upperstatus").show()
$("#progressbars").show()
$("#backendstatus").html("Adalanche is processing")
} else {
if (!lastwasidle) {
$("#progressbars").empty().hide()
$("#backendstatus").html("Adalanche backend is idle")
$("#upperstatus").fadeOut("slow")
// Update progressbar
pb.attr("aria-valuenow", progressbar.Percent.toFixed(0))
pb.css("width", progressbar.Percent.toFixed(0)+"%")
pb.parent().next().html(progressbar.Percent.toFixed(2)+"%")
}
// remove old progressbars
$("#progressbars .progress-bar").each(function (index) {
id = $(this).attr('id')
if (!keepProgressbars.has(id)) {
$(this).parent().parent().slideUp("slow", function () { $(this).remove(); })
}
lastwasidle = true
})

$("#upperstatus").show()
$("#progressbars").show()
$("#backendstatus").html("Adalanche is processing")
} else {
if (!lastwasidle) {
$("#progressbars").empty().hide()
$("#backendstatus").html("Adalanche backend is idle")
$("#upperstatus").fadeOut("slow")
}
},
error: function (xhr, status, error) {
$("#backendstatus").html("Adalanche backend is offline")
$("#progressbars").empty().hide()
$("#offlineblur").show()
lastwasidle = true
}
});
$()
};
};

setTimeout(refreshStatus, 1000);
}
refreshProgress();

function toast(title, contents) {
toastcontent = $(`<div id="live-toast" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
Expand Down Expand Up @@ -702,7 +708,6 @@ $(function () {
}
});

refreshStatus();
// End of on document loaded function
});

181 changes: 29 additions & 152 deletions modules/analyze/html/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,17 +306,16 @@ cytostyle = [{
}
},
{
selector: 'node[type="User"][!_disabled]',
selector: 'node[type="User"]',
style: {
"background-image": "icons/person-fill.svg",
"background-color": "green"
}
},
{
selector: 'node[type="User"][?_disabled]',
selector: 'node[tag="inactive"]',
style: {
"background-image": "icons/no_accounts_black_48dp.svg",
"background-color": "darkgreen"
}
},
{
Expand Down Expand Up @@ -368,7 +367,7 @@ cytostyle = [{
selector: 'node[type="Executable"]',
style: {
shape: "rectangle",
"background-image": "icons/binary-code-binary-svgrepo-com.svg",
"background-image": "icons/binary-code.svg",
"background-color": "lightgreen"
}
},
Expand Down Expand Up @@ -635,157 +634,35 @@ function rendermethods(ele) {
return s
}

function rendernode(ele) {
var s = '<div>';
icons = new Map(
[
["User", "<img src='icons/person-fill.svg' class='rounded-circle' width='24' height='24'>"],
["Group", "<img src='icons/people-fill.svg' class='rounded-circle' width='24' height='24'>"],
["Computer", "<img src='icons/computer-fill.svg' class='rounded-circle' width='24' height='24'>"],
["Machine", "<img src='icons/tv-fill.svg' class='rounded-circle' width='24' height='24'>"],
["ManagedServiceAccount", "<img src='icons/manage_accounts_black_24dp.svg' class='rounded-circle' width='24' height='24'>"],
["GroupManagedServiceAccount", "<img src='icons/manage_accounts_black_24dp.svg' class='rounded-circle' width='24' height='24'>"],
["ForeignSecurityPrincipal", "<img src='icons/badge_black_24dp.svg' class='rounded-circle' width='24' height='24'>"],
["Service", "<img src='icons/service.svg' class='rounded-circle' width='24' height='24'>"],
["Directory", "<img src='icons/source_black_24dp.svg' class='rounded-circle' width='24' height='24'>"],
["File", "<img src='icons/article_black_24dp.svg' class='rounded-circle' width='24' height='24'>"],
["Executable", "<img src='icons/binary-code.svg' class='rounded-circle' width='24' height='24'>"],
["GroupPolicyContainer", "<img src='icons/gpo.svg' class='rounded-circle' width='24' height='24'>"],
["OrganizationalUnit", "<img src='icons/source_black_24dp.svg' class='rounded-circle' width='24' height='24'>"],
["Container", "<img src='icons/folder_black_24dp.svg' class='rounded-circle' width='24' height='24'>"],
["CertificateTemplate", "<img src='icons/certificate.svg' class='rounded-circle' width='24' height='24'>"],
["DNSNode", "<img src='icons/dns.svg' class='rounded-circle' width='24' height='24'>"],
]
);

switch (ele.data("type")) {
case "User":
// selector: 'node[type="User"][!_disabled]',
// style: {
// "background-image": "icons/person-fill.svg",
// "background-color": "green"
// }
// selector: 'node[type="User"][?_disabled]',
// style: {
// "background-image": "icons/no_accounts_black_48dp.svg",
// "background-color": "darkgreen"
// }
s += '<img src="icons/person-fill.svg" class="rounded-circle bg-yellow" width="24" height="24">';
break;
case "Group":
// selector: 'node[type="Group"]',
// style: {
// shape: "cut-rectangle",
// "background-image": "icons/people-fill.svg",
// "background-color": "orange"
// }
s += '<img src="icons/people-fill.svg" class="rounded-circle" width="24" height="24">';
break;
case "ManagedServiceAccount":
// selector: 'node[type="ManagedServiceAccount"]',
// style: {
// "background-image": "icons/manage_accounts_black_24dp.svg",
// "background-color": "lightgreen"
// }
s += '<img src="icons/manage_accounts_black_24dp.svg" class="rounded-circle" width="24" height="24">';
break;
case "GroupManagedServiceAccount":
// selector: 'node[type="GroupManagedServiceAccount"]',
// style: {
// "background-image": "icons/manage_accounts_black_24dp.svg",
// "background-color": "lightgreen"
// }
s += '<img src="icons/manage_accounts_black_24dp.svg" class="rounded-circle" width="24" height="24">';
break;
case "ForeignSecurityPrincipal":
// selector: 'node[type="ForeignSecurityPrincipal"]',
// style: {
// "background-image": "icons/badge_black_24dp.svg",
// "background-color": "lightgreen"
// }
s += '<img src="icons/badge_black_24dp.svg" class="rounded-circle" width="24" height="24">';
break;
case "Service":
// selector: 'node[type="Service"]',
// style: {
// shape: "diamond",
// "background-image": "icons/service.svg",
// "background-color": "lightgreen"
// }
s += '<img src="icons/service.svg" class="rounded-circle" width="24" height="24">';
break;
case "Directory":
// selector: 'node[type="Directory"]',
// style: {
// shape: "diamond",
// "background-image": "icons/source_black_24dp.svg",
// "background-color": "lightblue"
// }
s += '<img src="icons/source_black_24dp.svg" class="rounded-circle" width="24" height="24">';
break;
case "File":
// selector: 'node[type="File"]',
// style: {
// shape: "diamond",
// "background-image": "icons/article_black_24dp.svg",
// "background-color": "lightblue"
// }
s += '<img src="icons/article_black_24dp.svg" class="rounded-circle" width="24" height="24">';
break;
case "Executable":
// selector: 'node[type="Executable"]',
// style: {
// shape: "rectangle",
// "background-image": "icons/binary-code-binary-svgrepo-com.svg",
// "background-color": "lightgreen"
// }
s += '<img src="icons/binary-code-binary-svgrepo-com.svg" class="rounded-circle" width="24" height="24">';
break;
case "GroupPolicyContainer":
// selector: 'node[type="GroupPolicyContainer"]',
// style: {
// shape: "rectangle",
// "background-image": "icons/gpo.svg",
// "background-color": "purple"
// }
s += '<img src="icons/gpo.svg" class="rounded-circle" width="24" height="24">';
break;
case "OrganizationalUnit":
// selector: 'node[type="OrganizationalUnit"]',
// style: {
// shape: "rectangle",
// "background-image": "icons/source_black_24dp.svg",
// "background-color": "lightgray"
// }
s += '<img src="icons/source_black_24dp.svg" class="rounded-circle" width="24" height="24">';
break;
case "Container":
// selector: 'node[type="Container"]',
// style: {
// shape: "rectangle",
// "background-image": "icons/folder_black_24dp.svg",
// "background-color": "lightgray"
// }
s += '<img src="icons/folder_black_24dp.svg" class="rounded-circle" width="24" height="24">';
break;
function rendericon(ele) {
return icons.get(ele.data("type"));
}

case "CertificateTemplate":
// selector: 'node[type="CertificateTemplate"]',
// style: {
// shape: "rectangle",
// "background-image": "icons/certificate.svg",
// "background-color": "pink"
// }
s += '<img src="icons/certificate.svg" class="rounded-circle" width="24" height="24">';
break;
case "DNSNode":
// selector: 'node[type="DNSNode"]',
// style: {
// shape: "rectangle",
// "background-image": "icons/dns.svg",
// }
s += '<img src="icons/dns.svg" class="rounded-circle" width="24" height="24">';
break;
case "Computer":
// selector: 'node[type="Computer"]',
// style: {
// shape: "round-octagon",
// "background-image": "icons/tv-fill.svg",
// "background-color": "lightgreen"
// }
s += '<img src="icons/tv-fill.svg" class="rounded-circle" width="24" height="24">';
break;
case "Machine":
// selector: 'node[type="Machine"]',
// style: {
// shape: "round-octagon",
// "background-image": "icons/tv-fill.svg",
// "background-color": "teal"
// }
s += '<img src="icons/tv-fill.svg" class="rounded-circle" width="24" height="24">';
break;
}
function rendernode(ele) {
var s = '<div>';

s += rendericon(ele);

s += nodelabel(ele);
if (ele.data("engine.downLevelLogonName")) {
Expand Down
Loading

0 comments on commit 5a023f3

Please sign in to comment.