Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var timerId = global.setTimeout(function() {
timerId = undefined; // Reset it before the close listener gets called.
try {
proc.kill();
} catch (e) {
logger.error('Error killing %s: %s', cmd, e);
}
// The kill() call normally triggers the close listener, but we reject
// the promise here instead of the close listener, because we don't really
// know if and when it's going to be killed at OS level.
// In the future we may want to restart the adb server here as a recovery
// for wedged adb connections, or use a relay board for device recovery.
done.reject(
newError(cmd + ' timeout after ' + (timeout / 1000) + ' seconds'));
}, timeout);
process.on('unhandledRejection', (reason, p) => {
logger.error('Possibly Unhandled Rejection at: Promise ', p, ' reason: ', reason);
// application specific logging here
});
exports.process.on('message', function(message) {
var cmd = (message ? message.cmd : '');
if ('run' === cmd) {
this.init(message);
this.connect();
} else if ('abort' === cmd) {
this.agentErrror_ = this.agentError_ || (new Error('abort'));
this.done_();
} else {
logger.error('Unrecognized IPC command %s, message: %j', cmd, message);
}
}.bind(this));
};
child_process.exec(command, function(error, stdout, stderr) {
if (error !== system_commands.get('command not found')) {
callback(stdout, stderr);
} else if (errback) {
errback(error, stdout, stderr);
} else {
logger.error(
'Command %s failed with error %s stdout:\n%s\nstderr:\n%s',
command, error, stdout, stderr);
}
});
};
Client.prototype.abortJob_ = function(job) {
'use strict';
logger.error('Aborting job %s: %s%s', job.id, (job.testError || ''),
(job.testError && job.agentError ? ' ' : ''),
(job.agentError ? '(' + job.agentError + ')' : ''));
if (this.onAbortJob) {
this.onAbortJob(job);
} else {
job.runFinished(/*isRunFinished=*/true);
}
};
fs.readFile('/proc/net/dev', function(err, buffer) {
if (err) {
logger.error(err.stack);
return;
}
const lines = buffer.toString('UTF-8').split('\n');
const sum = createEmpty();
const incr = createEmpty();
const curr = createEmpty();
lines.forEach((v, i) => {
const tmp = v.split(/\W+/);
if (!tmp[1]) {
return;
}
const key = tmp[1];
request.get({uri:config.lockerBase + '/Me/contacts/update'}, function(err, resp, body) {
if(err || resp.statusCode !== 200) {
logger.error("failed to call contacts update "+(err||resp.statusCode));
callback(false);
}
request.get({uri:config.lockerBase + '/Me/twitter/run?id=friends'}, function(err, resp, body) {
if(err || resp.statusCode !== 200) {
logger.error("failed to call twitter run "+(err||resp.statusCode));
callback(false);
}
callback(true);
})
});
});
request.get({uri:config.lockerBase + '/Me/contacts/update'}, function(err, resp, body) {
if ((err || resp.statusCode !== 200) && body !== "already running") {
if (resp && resp.statusCode !== 200)
logger.error("couldn't update contacts, response: " + body);
if (err)
logger.error(new Error(err).stack);
return callback(false);
}
callback(true);
});
};
request.get({uri:config.lockerBase + '/Me/github/run?id=repos'}, function(err, resp, body) {
if(err || resp.statusCode !== 200) {
if (resp.statusCode !== 200) logger.error("couldn't pull GitHub repos, response from connector: " + body);
if (err) logger.error(new Error(err).stack);
return callback(false);
}
callback(true);
});
});
exports.encrypt = function(data) {
if (!data) {
logger.error("Error encrypting " + data);
return "";
}
var cipher = crypto.createCipher("aes192", symKey);
var ret = cipher.update(data, "utf8", "hex");
ret += cipher.final("hex");
return ret;
}