diff --git a/.gitignore b/.gitignore index 7252ce999..20ad89590 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ npm-debug.log sandbox .DS_Store coverage +.vscode \ No newline at end of file diff --git a/lib/agent/providers/indicators/index.js b/lib/agent/providers/indicators/index.js index ad7ef235a..26de620f7 100644 --- a/lib/agent/providers/indicators/index.js +++ b/lib/agent/providers/indicators/index.js @@ -70,3 +70,8 @@ exports.get_battery_status = os_functions.get_battery_status; * Callsback an object with fields size_gb, free_gb, used **/ exports.get_remaining_storage = os_functions.get_remaining_storage; + +/** + * Callsback an object with lists of encrypted and unencrypted volumes + **/ +exports.get_storage_encryption_status = os_functions.get_storage_encryption_status; diff --git a/lib/agent/providers/indicators/linux.js b/lib/agent/providers/indicators/linux.js index c670951cb..3d04dd778 100644 --- a/lib/agent/providers/indicators/linux.js +++ b/lib/agent/providers/indicators/linux.js @@ -96,3 +96,25 @@ exports.get_remaining_storage = function(callback) { callback(null, info); }); }; + +exports.get_storage_encryption_status = function(callback) { + sudo("dmsetup status", function(err, stdout){ + if (err) return callback(err); + + var volumes = stdout.toString().trim().split(os.EOL); + var info = { + encrypted : [], + unencrypted: [] + }; + + volumes.forEach(v => { + if (v.includes("crypt")) { + info.encrypted.push(v.split(":")[0]) + } else { + info.unencrypted.push(v.split(":")[0]) + }; + }); + + callback(null, info); + }); +}; diff --git a/lib/agent/providers/indicators/mac.js b/lib/agent/providers/indicators/mac.js index ba099e783..c6a2b39e9 100644 --- a/lib/agent/providers/indicators/mac.js +++ b/lib/agent/providers/indicators/mac.js @@ -51,3 +51,7 @@ exports.get_remaining_storage = function(callback) { callback(null, info); }); }; + +exports.get_storage_encryption_status = function(callback) { + callback(new Error('TODO!')); +}; diff --git a/lib/agent/providers/indicators/windows.js b/lib/agent/providers/indicators/windows.js index ee3b1ea4d..060b91166 100644 --- a/lib/agent/providers/indicators/windows.js +++ b/lib/agent/providers/indicators/windows.js @@ -58,3 +58,26 @@ exports.get_battery_status = function(cb) { }); }; + +exports.get_storage_encryption_status = function(callback) { + exec("powershell.exe -Command \" Get-BitLockerVolume | foreach {$_.MountPoint + ' ' + $_.ProtectionStatus } \"", function(err, stdout){ + if (err) return callback(err); + + var volumes = stdout.toString().trim().split(os.EOL); + + var info = { + encrypted : [], + unencrypted: [] + }; + + volumes.forEach(v => { + if (v.includes("On")) { + info.encrypted.push(v.split(/\s+/)[0]) + } else { + info.unencrypted.push(v.split(/\s+/)[0]) + } + }); + + callback(null, info); + }); +}; \ No newline at end of file diff --git a/lib/agent/reports/specs.js b/lib/agent/reports/specs.js index 323a97ea6..42b255d6e 100644 --- a/lib/agent/reports/specs.js +++ b/lib/agent/reports/specs.js @@ -3,5 +3,6 @@ exports.includes = [ 'firmware_info', 'network_interfaces_list', 'ram_module_list', - 'storage_devices_list' + 'storage_devices_list', + 'storage_encryption_status' ];