diff --git a/lib/agent/plugins/control-panel/index.js b/lib/agent/plugins/control-panel/index.js index bc35829c0..3c5a42096 100644 --- a/lib/agent/plugins/control-panel/index.js +++ b/lib/agent/plugins/control-panel/index.js @@ -5,9 +5,12 @@ var setup = require('./setup'), prompt = require('./prompt'), bus = require('./bus'), reports = require('./../../reports'), - hardware = require('./../../providers/hardware'), + hardware = require('./../../providers/hardware'), long_polling = require('./long-polling'), - lp_conf = require('./../../../conf/long-polling'); + lp_conf = require('./../../../conf/long-polling'), + os_name = process.platform.replace('win32', 'windows').replace('darwin', 'mac'), + join = require('path').join, + system = require(join('./../../../system', os_name)); var common, hooks, @@ -57,9 +60,15 @@ var wait_for_config = function(cb) { }, 10000); // 10 seconds } +exports.timeout = 8 * 60 * 60 * 1000; // Every 8 hours function boot(cb) { load_hooks(); sync(); + + var status_interval = setInterval(() => { + send_info_encrypt(); + },exports.timeout) + long_polling.load.call(common, function(err, emitter) { if (!emitter) return; emitter.on('command', commands.perform); @@ -73,7 +82,7 @@ function load_hooks() { hooks.on('event', sender.notify_event) hooks.on('data', sender.send_data) hooks.on('report', (name, data) => { - let data_to_send_panel = {  + let data_to_send_panel = { ...data } if (name == 'specs') hardware.track_hardware_changes(data); @@ -100,10 +109,28 @@ function handle_response(what, err, resp) { commands.process(resp.body); } +function send_info_encrypt() { + let data = {}; + if(os_name == 'windows'){ + system.get_os_edition(function(err, os_edition) { + if (err) return new Error('Error to get os_edition information'); + data.os_edition = os_edition; + system.get_winsvc_version(function(err, winsvc_version) { + if (err) return new Error('Error to get winsvc_version information'); + data.winsvc_version = winsvc_version; + if (config.get('api_key') && config.get('device_key') && (system.compatible_with_module_tpm(data))) { + commands.run('get', 'encryption_status'); + commands.run('get', 'encryption_keys'); + } + }) + }) + } +} + function sync() { api.devices.get.status(function(err, response) { var result = response && response.body; - + if (!result || (response && response.statusCode > 300)) return logger.warn('Unable to sync settings.'); @@ -162,7 +189,7 @@ function missing(opts) { } function scan_hardware() { - commands.run('get', 'specs'); + commands.run('get', 'specs'); } function found() { diff --git a/lib/system/windows/index.js b/lib/system/windows/index.js index 82fdc0049..d7c009e66 100644 --- a/lib/system/windows/index.js +++ b/lib/system/windows/index.js @@ -256,4 +256,15 @@ exports.get_python_version = (callback) => { } function bin_path(executable) { return path.join(__dirname, 'bin', executable); +} + +exports.compatible_with_module_tpm = function (data) { + var editions = ["Pro", "Education", "Enterprise"]; + var common = require('./../../agent/common'), + gte = common.helpers.is_greater_or_equal; + if (os_name == 'windows' && gte(common.os_release, "10.0.0") && + data.os_edition && editions.includes(data.os_edition) && + data.winsvc_version && gte(data.winsvc_version, "2.0.0")) + return true; + return false; } \ No newline at end of file