Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Volumes+Bitlocker #5387

Merged
merged 6 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions agents/meshcore.js
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,21 @@ var meshCoreObj = { action: 'coreinfo', value: (require('MeshAgent').coreHash ?
// Get the operating system description string
try { require('os').name().then(function (v) { meshCoreObj.osdesc = v; meshCoreObjChanged(); }); } catch (ex) { }

// Get Volumes and BitLocker if Windows
try {
if (process.platform == 'win32'){
if (require('identifiers').volumes_promise != null){
var p = require('identifiers').volumes_promise();
p.then(function (res){
meshCoreObj.volumes = res;
meshCoreObjChanged();
});
}else if (require('identifiers').volumes != null){
meshCoreObj.volumes = require('identifiers').volumes();
meshCoreObjChanged();
}
}
} catch(e) { }

// Setup logged in user monitoring (THIS IS BROKEN IN WIN7)
try {
Expand Down Expand Up @@ -1814,10 +1829,10 @@ function getSystemInformation(func) {
results.hardware.agentvers = process.versions;
replaceSpacesWithUnderscoresRec(results);
var hasher = require('SHA384Stream').create();
results.hash = hasher.syncHash(JSON.stringify(results)).toString('hex');
func(results);
// results.hash = hasher.syncHash(JSON.stringify(results)).toString('hex');
// func(results);

/*

// On Windows platforms, get volume information - Needs more testing.
if (process.platform == 'win32')
{
Expand All @@ -1828,14 +1843,14 @@ function getSystemInformation(func) {
var p = require('identifiers').volumes_promise();
p.then(function (res)
{
results.volumes = res;
results.hardware.windows.volumes = res;
results.hash = hasher.syncHash(JSON.stringify(results)).toString('hex');
func(results);
});
}
else if (require('identifiers').volumes != null)
{
results.volumes = require('identifiers').volumes();
results.hardware.windows.volumes = require('identifiers').volumes();
results.hash = hasher.syncHash(JSON.stringify(results)).toString('hex');
func(results);
}
Expand All @@ -1850,7 +1865,7 @@ function getSystemInformation(func) {
results.hash = hasher.syncHash(JSON.stringify(results)).toString('hex');
func(results);
}
*/

} catch (ex) { func(null, ex); }
}

Expand Down
6 changes: 6 additions & 0 deletions meshagent.js
Original file line number Diff line number Diff line change
Expand Up @@ -1936,6 +1936,12 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
// TODO: Check that the agent has an interface that is the same as the one we got this websocket connection on. Only set if we have a match.
}

// Volumes and BitLocker
if(command.volumes != null){
if(!device.volumes) { device.volumes = {}; }
if (JSON.stringify(device.volumes) != JSON.stringify(command.volumes)) { /*changes.push('Volumes status');*/ device.volumes = command.volumes; change = 1; log = 1; }
}

// If there are changes, event the new device
if (change == 1) {
// Do some clean up if needed, these values should not be in the database.
Expand Down
11 changes: 9 additions & 2 deletions meshuser.js
Original file line number Diff line number Diff line change
Expand Up @@ -4928,7 +4928,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
if (type == 'csv') {
try {
// Create the CSV file
output = 'id,name,rname,host,icon,ip,osdesc,groupname,av,update,firewall,avdetails,cpu,osbuild,biosDate,biosVendor,biosVersion,boardName,boardVendor,boardVersion,productUuid,totalMemory,agentOpenSSL,agentCommitDate,agentCommitHash,agentCompileTime,netIfCount,macs,addresses,lastConnectTime,lastConnectAddr\r\n';
output = 'id,name,rname,host,icon,ip,osdesc,groupname,av,update,firewall,bitlocker,avdetails,cpu,osbuild,biosDate,biosVendor,biosVersion,boardName,boardVendor,boardVersion,productUuid,totalMemory,agentOpenSSL,agentCommitDate,agentCommitHash,agentCompileTime,netIfCount,macs,addresses,lastConnectTime,lastConnectAddr\r\n';
for (var i = 0; i < results.length; i++) {
const nodeinfo = results[i];

Expand All @@ -4939,14 +4939,21 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
if (typeof n.wsc == 'object') {
output += ',' + csvClean(n.wsc.antiVirus ? n.wsc.antiVirus : '') + ',' + csvClean(n.wsc.autoUpdate ? n.wsc.autoUpdate : '') + ',' + csvClean(n.wsc.firewall ? n.wsc.firewall : '')
} else { output += ',,,'; }
if (typeof n.volumes == 'object') {
var bitlockerdetails = '', firstbitlocker = true;
for (var a in n.volumes) { if (typeof n.volumes[a].protectionStatus !== 'undefined') { if (firstbitlocker) { firstbitlocker = false; } else { bitlockerdetails += '|'; } bitlockerdetails += a + '/' + n.volumes[a].volumeStatus; } }
output += ',' + csvClean(bitlockerdetails);
} else {
output += ',';
}
if (typeof n.av == 'object') {
var avdetails = '', firstav = true;
for (var a in n.av) { if (typeof n.av[a].product == 'string') { if (firstav) { firstav = false; } else { avdetails += '|'; } avdetails += (n.av[a].product + '/' + ((n.av[a].enabled) ? 'enabled' : 'disabled') + '/' + ((n.av[a].updated) ? 'updated' : 'notupdated')); } }
output += ',' + csvClean(avdetails);
}
else { output += ','; }
} else {
output += ',,,,,,,,,,,';
output += ',,,,,,,,,,,,';
}

// System infomation
Expand Down
15 changes: 15 additions & 0 deletions views/default-mobile.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -5840,6 +5840,21 @@
x += addDetailItem("Antivirus", y.join('<br />'));
}

// Volumes and Bitlocker
if (node.volumes){
var bitlocker = [];
for (var i in node.volumes) {
if (typeof node.volumes[i].protectionStatus !== 'undefined' && node.volumes[i].protectionStatus == 'On'){
bitlocker.push(i + ' - <span style=color:green>' + node.volumes[i].volumeStatus + '</span>');
}else if (typeof node.volumes[i].protectionStatus !== 'undefined'){
bitlocker.push(i + ' - <span style=color:red>' + node.volumes[i].volumeStatus + '</span>');
}
}
if(bitlocker.length > 0){
x += addDetailItem("BitLocker", bitlocker.join('<br />'));
}
}

if (x != '') { sections.push({ name: "Operating System", html: x, img: 'software' }); }
}

Expand Down
26 changes: 24 additions & 2 deletions views/default.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -5744,13 +5744,20 @@
meshserver.send({ action: 'getDeviceDetails', nodeids: chkNodeIds, tz: tz, tf: new Date().getTimezoneOffset(), l: getLang(), type: 'csv' }); // With details
} else {
// Without details
var csv = "id, name, rname, host, icon, ip, osdesc, state, groupname, conn, pwr, av, update, firewall, avdetails" + '\r\n', r = [];
var csv = "id,name,rname,host,icon,ip,osdesc,state,groupname,conn,pwr,av,update,firewall,bitlocker,avdetails" + '\r\n', r = [];
for (var i in chkNodeIds) {
var n = getNodeFromId(chkNodeIds[i]);
csv += '"' + n._id.split(',').join('') + '","' + n.name.split(',').join('') + '","' + (n.rname?(n.rname.split(',').join('')):'') + '","' + (n.host?(n.host.split(',').join('')):'') + '","' + n.icon + '","' + (n.ip?n.ip:'') + '","' + (n.osdesc?(n.osdesc.split(',').join('')):'') + '","' + n.state + '","' + meshes[n.meshid].name.split(',').join('') + '","' + (n.conn?n.conn:'') + '","' + (n.pwr?n.pwr:'') + '"';
if (typeof n.wsc == 'object') { csv += ',"' + csvClean(n.wsc.antiVirus) + '","' + csvClean(n.wsc.autoUpdate) + '","' + csvClean(n.wsc.firewall) + '"'; } else { csv += ',,,'; }
if (typeof n.volumes == 'object') {
var bitlockerdetails = '', firstbitlocker = true;
for (var a in n.volumes) { if (typeof n.volumes[a].protectionStatus !== 'undefined') { if (firstbitlocker) { firstbitlocker = false; } else { bitlockerdetails += '|'; } bitlockerdetails += a + '/' + n.volumes[a].volumeStatus; } }
csv += ',"' + csvClean(bitlockerdetails) + '"'; }
else {
csv += ',';
}
if (typeof n.av == 'object') {
var avdetails = '', firstav= true;
var avdetails = '', firstav = true;
for (var a in n.av) { if (typeof n.av[a].product == 'string') { if (firstav) { firstav = false; } else { avdetails += '|'; } avdetails += (n.av[a].product + '/' + ((n.av[a].enabled)?'enabled':'disabled') + '/' + ((n.av[a].updated)?'updated':'notupdated')); } }
csv += ',"' + csvClean(avdetails) + '"'; }
else {
Expand Down Expand Up @@ -7258,6 +7265,21 @@
x += addDeviceAttribute("Antivirus", y.join('<br />'));
}

// Volumes and Bitlocker
if (node.volumes){
var bitlocker = [];
for (var i in node.volumes) {
if (typeof node.volumes[i].protectionStatus !== 'undefined' && node.volumes[i].protectionStatus == 'On'){
bitlocker.push(i + ' - <span style=color:green>' + node.volumes[i].volumeStatus + '</span>');
}else if (typeof node.volumes[i].protectionStatus !== 'undefined'){
bitlocker.push(i + ' - <span style=color:red>' + node.volumes[i].volumeStatus + '</span>');
}
}
if(bitlocker.length > 0){
x += addDeviceAttribute("BitLocker", bitlocker.join(', '));
}
}

// Active Users
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(', '))); }

Expand Down