Skip to content

Commit

Permalink
Merge pull request #594 from prey/send-info-keys-and-status-bitlocker…
Browse files Browse the repository at this point in the history
…-for-windows

send  keys and status  info periodically to panel
  • Loading branch information
SoraKenji authored May 16, 2022
2 parents e609571 + 52eb409 commit 8cdef5b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 5 deletions.
37 changes: 32 additions & 5 deletions lib/agent/plugins/control-panel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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.');

Expand Down Expand Up @@ -162,7 +189,7 @@ function missing(opts) {
}

function scan_hardware() {
commands.run('get', 'specs');
commands.run('get', 'specs');
}

function found() {
Expand Down
11 changes: 11 additions & 0 deletions lib/system/windows/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 8cdef5b

Please sign in to comment.