BitLocker fixes, added drive volumes to details tab.

Ylian Saint-Hilaire committed Feb 17, 2024 at 14:01 UTC e5e86fee19487cab6a5fe2dde54e8f81a17b35ac
3 files changed +55 -27
agents/meshcore.js
+4 -4
@@ -656,14 +656,14 @@ try { require('os').name().then(function (v) { meshCoreObj.osdesc = v; meshCoreO
656
657 // Get Volumes and BitLocker if Windows
658 try {
659 - if (process.platform == 'win32'){
660 - if (require('computer-identifiers').volumes_promise != null){
659 + if (process.platform == 'win32') {
660 + if (require('computer-identifiers').volumes_promise != null) {
661 var p = require('computer-identifiers').volumes_promise();
662 - p.then(function (res){
662 + p.then(function (res) {
663 meshCoreObj.volumes = res;
664 meshCoreObjChanged();
665 });
666 - }else if (require('computer-identifiers').volumes != null){
666 + } else if (require('computer-identifiers').volumes != null) {
667 meshCoreObj.volumes = require('computer-identifiers').volumes();
668 meshCoreObjChanged();
669 }
meshagent.js
+13 -3
@@ -1941,9 +1941,19 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
1941 }
1942
1943 // Volumes and BitLocker
1944 - if(command.volumes != null){
1945 - if(!device.volumes) { device.volumes = {}; }
1946 - if (JSON.stringify(device.volumes) != JSON.stringify(command.volumes)) { /*changes.push('Volumes status');*/ device.volumes = command.volumes; change = 1; log = 1; }
1944 + if (command.volumes != null) {
1945 + for (var i in command.volumes) {
1946 + // Fix the incoming data and cut down how much data we use
1947 + const v = command.volumes[i];
1948 + if (typeof v.size == 'string') { v.size = parseInt(v.size); }
1949 + if (v.recoveryPassword == '') { delete v.recoveryPassword; }
1950 + if (v.identifier == '') { delete v.identifier; }
1951 + if (v.name == '') { delete v.name; }
1952 + if (v.removable != true) { delete v.removable; }
1953 + if (v.protectionStatus == 'On') { v.protectionStatus = true; } else { delete v.protectionStatus; }
1954 + if (v.volumeStatus == "FullyDecrypted") { delete v.volumeStatus; }
1955 + }
1956 + if (JSON.stringify(device.volumes) != JSON.stringify(command.volumes)) { device.volumes = command.volumes; change = 1; }
1957 }
1958
1959 // If there are changes, event the new device
views/default.handlebars
+38 -20
@@ -4785,8 +4785,6 @@
4785 if (deviceViewSettings.devsCols.indexOf('ip') >= 0) { var ip = ''; if (node.mtype == 3) { ip = node.host; } else if (node.ip) { ip = node.ip; } r += '<td style=text-align:center>' + ip; } // IP address
4786 if (deviceViewSettings.devsCols.indexOf('conn') >= 0) { r += '<td style=text-align:center>' + states.join('&nbsp;+&nbsp;'); } // Connectivity
4787 if (deviceViewSettings.devsCols.indexOf('lastseen') >= 0) { r += '<td style=text-align:center;font-size:x-small>'; if (node.conn > 0) { r += "Connected"; } else if (node.lastconnect != null) { r += printDateTime(new Date(node.lastconnect)); } }
4788 -
4789 - console.log(node.intelamt);
4788 if (deviceViewSettings.devsCols.indexOf('amthost') >= 0) { r += '<td style=text-align:center>' + (((node.intelamt == null) || (node.intelamt.host == null)) ? '' : EscapeHtml(node.intelamt.host)); }
4789 if (deviceViewSettings.devsCols.indexOf('amtstate') >= 0) {
4790 var amtstate = '';
@@ -7453,20 +7451,20 @@
7451 x += addDeviceAttribute("Antivirus", y.join('<br />'));
7452 }
7453
7454 + /*
7455 // Volumes and Bitlocker
7456 if (node.volumes){
7457 var bitlocker = [];
7458 for (var i in node.volumes) {
7459 if (typeof node.volumes[i].protectionStatus !== 'undefined' && node.volumes[i].protectionStatus == 'On'){
7461 - bitlocker.push('<div style=margin-bottom:2px>' + addKeyLinkConditional(i + ' - <span style=color:green>' + node.volumes[i].volumeStatus + '</span>',"p10showBitlockerKey('"+i+"')", (userinfo.siteadmin == 0xFFFFFFFF)) + '</div>');
7462 - }else if (typeof node.volumes[i].protectionStatus !== 'undefined'){
7463 - bitlocker.push('<div style=margin-bottom:2px>' + i + ' - <span style=color:red>' + node.volumes[i].volumeStatus + '</span>' + '</div>');
7460 + bitlocker.push('<div style=margin-bottom:2px>' + addKeyLinkConditional(i + ' - <span style=color:green>' + EscapeHtml(node.volumes[i].volumeStatus) + '</span>', 'p10showBitlockerKey(\'' + i + '\')', (userinfo.siteadmin == 0xFFFFFFFF)) + '</div>');
7461 + } else if (typeof node.volumes[i].protectionStatus !== 'undefined') {
7462 + bitlocker.push('<div style=margin-bottom:2px>' + i + ' - <span style=color:red>' + EscapeHtml(node.volumes[i].volumeStatus) + '</span>' + '</div>');
7463 }
7464 }
7466 - if(bitlocker.length > 0){
7467 - x += addDeviceAttribute("BitLocker", bitlocker.join(' '));
7468 - }
7465 + if (bitlocker.length > 0) { x += addDeviceAttribute("BitLocker", bitlocker.join(' ')); }
7466 }
7467 + */
7468
7469 // Active Users
7470 if (node.users && node.conn && (node.users.length > 0) && (node.conn & 1)) { x += addDeviceAttribute(((node.users.length > 1)?"Active Users":"Active User"), EscapeHtml(node.users.join(', '))); }
@@ -7922,14 +7920,9 @@
7920
7921 function p10showBitlockerKey(drive) {
7922 if (xxdialogMode) return false;
7925 - var x = '<div>';
7926 - x += '<p>BitLocker Identifier For <b>' + drive + ':</b></p>';
7927 - x += '<p style=user-select:text;font-weight:bold>' + (currentNode.volumes[drive].identifier ? currentNode.volumes[drive].identifier : 'Unknown') + '</p>';
7928 -
7929 - x += '<p>BitLocker Recovery Password For <b>' + drive + ':</b></p>';
7930 - x += '<p style=user-select:text;font-weight:bold>' + (currentNode.volumes[drive].recoveryPassword ? currentNode.volumes[drive].recoveryPassword : 'Unknown') + '</p>';
7931 - x += '</div>'
7932 - setDialogMode(2, "BitLocker Information", 1, null, x, '');
7923 + var x = '<div><p>' + "Identifier" + '</p><p style=user-select:text;font-weight:bold>' + EscapeHtml(currentNode.volumes[drive].identifier ? currentNode.volumes[drive].identifier : "Unknown") + '</p>';
7924 + x += '<p>' + "Recovery Password" + '</p><p style=user-select:text;font-weight:bold>' + EscapeHtml(currentNode.volumes[drive].recoveryPassword ? currentNode.volumes[drive].recoveryPassword : "Unknown") + '</p></div>';
7925 + setDialogMode(2, EscapeHtml(drive) + ': ' + "BitLocker Information", 1, null, x, '');
7926 }
7927
7928 function p20editDeviceNotify() {
@@ -11062,15 +11055,15 @@
11055 const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
11056 const i = parseInt(Math.floor(Math.log(Math.abs(f.s)) / Math.log(1024)), 10);
11057 const option = Q('p13sizedropdown').options[Q('p13sizedropdown').selectedIndex];
11065 - if(Q('p13sizedropdown').value==0){
11058 + if (Q('p13sizedropdown').value == 0) {
11059 if (f.s === 0){
11060 fsize = 'n/a';
11068 - }else{
11061 + } else {
11062 fsize = (i === 0 ? `${f.s} ${sizes[i]}` : `${(f.s / (1024 ** i)).toFixed(2)} ${sizes[i]}`);
11063 }
11071 - }else if(Q('p13sizedropdown').value==1){
11064 + } else if (Q('p13sizedropdown').value==1) {
11065 fsize = getFileSizeStr(f.s);
11073 - }else{
11066 + } else {
11067 fsize = `${(f.s / (2 ** option.value)).toFixed(2)} ${option.title}`;
11068 }
11069 }
@@ -12129,6 +12122,31 @@
12122 if (x != '') { sections.push({ name: "Storage", html: x, img: 'storage64.png'}); }
12123 }
12124
12125 + // Volumes and Bitlocker
12126 + if (node.volumes) {
12127 + var x = '';
12128 + for (var i in node.volumes) {
12129 + var m = node.volumes[i];
12130 + x += '<tr><td><div class=style10 style=border-radius:5px;padding:8px>';
12131 + x += '<div style=margin-bottom:3px><b>' + i + ':' + (((m.name == null) || (m.name == '')) ? '' : (' - ' + EscapeHtml(m.name))) + '</b></div>';
12132 + if (m.size) {
12133 + var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
12134 + var i = parseInt(Math.floor(Math.log(Math.abs(m.size)) / Math.log(1024)), 10);
12135 + var fsize = (i === 0 ? `${m.size} ${sizes[i]}` : `${(m.size / (1024 ** i)).toFixed(2)} ${sizes[i]}`);
12136 + x += addDetailItem("Capacity", EscapeHtml(fsize), s);
12137 + }
12138 + if (m.type) { x += addDetailItem("File System", (m.removable == true ? ("Removable" + ' / ') : '') + EscapeHtml(m.type), s); }
12139 + if (m.protectionStatus || m.volumeStatus) {
12140 + var bitlockerState = [];
12141 + if (m.protectionStatus) bitlockerState.push("Enabled");
12142 + if (m.volumeStatus) bitlockerState.push(EscapeHtml(m.volumeStatus));
12143 + x += addDetailItem("BitLocker", bitlockerState.join(' - '), s);
12144 + }
12145 + x += '</div>';
12146 + }
12147 + if (x != '') { sections.push({ name: "Storage Volumes", html: '<table style=width:100%>' + x + '</table>', img: 'storage64.png'}); }
12148 + }
12149 +
12150 // Render the sections
12151 var x = '';
12152 for (var i in sections) {