Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// sha256 is not set for macOS Java SE
if(reqs[attribute].sha256sum !== '') {
data[attribute] = reqs[attribute].url;
count++;
}
}
//to check if the url looks like it points to what it is supposed to
fileNames['cdk.zip'] = 'cdk';
fileNames['rhel-vagrant-virtualbox.box'] = 'vagrant-virtualbox.box';
fileNames['oc.zip'] = 'oc-origin-cli';
fileNames['cygwin.exe'] = 'cygwin';
fileNames['jbds.jar'] = 'devstudio';
fileNames['jdk.msi'] = 'openjdk';
fileNames['vagrant.msi'] = 'vagrant';
fileNames['virtualbox.exe'] = 'virtualbox';
fileNames['7zip.zip'] = '7-Zip';
fileNames['7zip-extra.zip'] = '7-Zip';
//to check if the files are rougly the size they should be
minSizes['cdk.zip'] = 50 * 1024;
minSizes['rhel-vagrant-virtualbox.box'] = 750 * 1024 * 1024;
minSizes['oc.zip'] = 10 * 1024 * 1024;
minSizes['cygwin.exe'] = 500 * 1024;
minSizes['jbds.jar'] = 400 * 1024 * 1024;
minSizes['jdk.msi'] = 50 * 1024 *1024;
minSizes['vagrant.msi'] = 80 * 1024 * 1024;
minSizes['virtualbox.exe'] = 85 * 1024 * 1024;
minSizes['7zip.zip'] = 200 * 1024;
minSizes['7zip-extra.zip'] = 400 * 1024;
console.log('-------------------------------');
fileNames['jbds.jar'] = 'devstudio';
fileNames['jdk.msi'] = 'openjdk';
fileNames['vagrant.msi'] = 'vagrant';
fileNames['virtualbox.exe'] = 'virtualbox';
fileNames['7zip.zip'] = '7-Zip';
fileNames['7zip-extra.zip'] = '7-Zip';
//to check if the files are rougly the size they should be
minSizes['cdk.zip'] = 50 * 1024;
minSizes['rhel-vagrant-virtualbox.box'] = 750 * 1024 * 1024;
minSizes['oc.zip'] = 10 * 1024 * 1024;
minSizes['cygwin.exe'] = 500 * 1024;
minSizes['jbds.jar'] = 400 * 1024 * 1024;
minSizes['jdk.msi'] = 50 * 1024 *1024;
minSizes['vagrant.msi'] = 80 * 1024 * 1024;
minSizes['virtualbox.exe'] = 85 * 1024 * 1024;
minSizes['7zip.zip'] = 200 * 1024;
minSizes['7zip-extra.zip'] = 400 * 1024;
console.log('-------------------------------');
console.log('Checking download URLs');
for (var key in data) {
checkFileName(key);
checkUrl(key);
}
}
VirtualBoxManager.stopVM(function (err, result)
{
if (isNull(err))
{
virtualbox.snapshotRestore(VirtualBoxManager.vmName, checkpointName, function (err, output)
{
if (isNull(err))
{
VirtualBoxManager.startVM(function (err, result)
{
if (isNull(err))
{
console.log("Snapshot has been restored!");
console.log("UUID: ", output);
callback(null, true);
}
else
{
Logger.log("error", err);
Logger.log("error", result);
callback(err);
VirtualBoxManager.createCheckpoint = function (checkpointName, callback, dontAddPrefix)
{
if (!dontAddPrefix)
{
checkpointName = VirtualBoxManager.snapshotPrefix + checkpointName;
}
if (Config.virtualbox && Config.virtualbox.active && Config.virtualbox.create_snapshots)
{
const virtualbox = require("virtualbox");
virtualbox.snapshotTake(VirtualBoxManager.vmName, checkpointName, function (error, uuid)
{
if (error)
{
callback(1, "Error taking snapshot!");
}
else
{
if (uuid)
{
console.log("Snapshot has been taken!");
console.log("UUID: ", uuid);
callback(null);
}
else
{
callback(2, "Null checkpoint id returned when creating a new checkpoint!");
function exec(vm, username, passwd, path, params, callback){
virtualbox.start(vm, function(error){
if(error){
logging.error('Failed to start VM "%s"', vm);
callback && callback(error);
return;
}
logging.debug('Executing VirtualBox command on VM "%s". Username: %s Password: %s', vm, username, passwd);
virtualbox.exec({ 'vm': vm, 'username': username, 'passwd': passwd, 'cmd': path, 'params': params }, function(error, stdout){
if(error){
logging.error(error);
}
callback && callback(error, stdout);
virtualbox.poweroff(VirtualBoxManager.vmName, function (error)
{
if (error)
{
Logger.log("error", "Virtual Machine " + VirtualBoxManager.vmName + "failed to stop");
Logger.log("error", error);
callback(error);
}
else
{
Logger.log("Virtual Machine " + VirtualBoxManager.vmName + "has stopped");
virtualbox.start(VirtualBoxManager.vmName, function (error)
{
if (!isNull(error))
{
Logger.log("error", "Virtual Machine " + VirtualBoxManager.vmName + " failed to stop");
Logger.log("error", error);
callback(error);
}
else
{
Logger.log("Virtual Machine " + VirtualBoxManager.vmName + " restarted. ");
callback(null);
}
});
}
});
};
virtualbox.isRunning(VirtualBoxManager.vmName, function startCallback (error, running)
{
if (isNull(error))
{
if (!running)
{
virtualbox.start(VirtualBoxManager.vmName, function startCallback (error)
{
if (isNull(error))
{
Logger.log("Started VM");
callback(null);
}
else
{
Logger.log("Failed to start VM");
Logger.log("error", error);
callback(error);
}
});
}
else
{
virtualbox.isRunning(VirtualBoxManager.vmName, function (error, running)
{
if (isNull(error))
{
if (running)
{
Logger.log("Stopping Virtualbox VM.");
virtualbox.stop(VirtualBoxManager.vmName, function startCallback (error)
{
if (isNull(error))
{
Logger.log("Stopped VM");
}
else
{
Logger.log("Failed to stop VM");
Logger.log("error", error);
}
callback(error);
});
}
else
{
function stop(vm, callback){
virtualbox.stop(vm, function(vmError){
if(vmError) {
logging.error('Failed to stop VM "%s"', vm);
callback(vmError);
return;
}
server.stop();
callback();
});
}
VirtualBoxManager.stopVM = function (callback)
{
if (Config.virtualbox && Config.virtualbox.active)
{
const virtualbox = require("virtualbox");
virtualbox.isRunning(VirtualBoxManager.vmName, function (error, running)
{
if (isNull(error))
{
if (running)
{
Logger.log("Stopping Virtualbox VM.");
virtualbox.stop(VirtualBoxManager.vmName, function startCallback (error)
{
if (isNull(error))
{
Logger.log("Stopped VM");
}
else
{
Logger.log("Failed to stop VM");
Logger.log("error", error);