Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function applyChanges(opts, log, callback) {
log.trace(opts, 'applyChanges: entry');
assert.object(opts, 'opts');
assert.optionalObject(opts.allRemoteVMs, 'opts.allRemoteVMs');
assert.optionalObject(opts.allVMs, 'opts.allVMs');
assert.optionalObject(opts.del, 'opts.del');
assert.optionalArrayOfObject(opts.rules, 'opts.rules');
assert.optionalObject(opts.vms, 'opts.vms');
assert.optionalObject(opts.save, 'opts.save');
pipeline({
funcs: [
// Generate the ipf files for each VM
function reloadPlan(res, cb) {
prepareIPFdata({
allVMs: opts.allVMs,
remoteVMs: opts.allRemoteVMs,
rules: opts.rules,
vms: opts.vms
}, log, cb);
},
function applyChanges(opts, log, callback) {
log.trace(opts, 'applyChanges: entry');
assert.object(opts, 'opts');
assert.optionalObject(opts.allRemoteVMs, 'opts.allRemoteVMs');
assert.optionalObject(opts.allVMs, 'opts.allVMs');
assert.optionalObject(opts.del, 'opts.del');
assert.optionalArrayOfObject(opts.rules, 'opts.rules');
assert.optionalObject(opts.vms, 'opts.vms');
assert.optionalObject(opts.save, 'opts.save');
pipeline({
funcs: [
// Generate the ipf files for each VM
function reloadPlan(res, cb) {
prepareIPFdata({
allVMs: opts.allVMs,
remoteVMs: opts.allRemoteVMs,
rules: opts.rules,
vms: opts.vms
}, log, cb);
function bodyParser(options) {
assert.optionalObject(options, 'options');
var opts = options || {};
opts.bodyReader = true;
var read = bodyReader(opts);
var parseForm = formParser(opts);
var parseJson = jsonParser(opts);
var parseMultipart = multipartParser(opts);
var parseFieldedText = fieldedTextParser(opts);
function parseBody(req, res, next) {
// #100 don't parse the body again if we've read it once
if (req._parsedBody) {
next();
return;
} else {
req._parsedBody = true;
function build(args, callback)
{
var error, config, dsname, log, ds;
var metrics;
mod_assertplus.object(args, 'args');
mod_assertplus.object(args.config, 'args.config');
mod_assertplus.string(args.dsname, 'args.dsname');
mod_assertplus.bool(args.dryRun, 'args.dryRun');
mod_assertplus.string(args.interval, 'args.interval');
mod_assertplus.optionalString(args.assetroot, 'args.assetroot');
mod_assertplus.optionalObject(args.timeAfter, 'args.timeAfter');
mod_assertplus.optionalObject(args.timeBefore, 'args.timeBefore');
config = args.config;
dsname = args.dsname;
log = args.log;
error = null;
if (args.timeBefore !== null && args.timeAfter !== null &&
args.timeBefore.getTime() < args.timeAfter.getTime())
error = new VError(
'"before" time cannot be before "after" time');
switch (args.interval) {
case 'hour':
case 'day':
case 'all':
function auditLogger(options) {
assert.object(options, 'options');
assert.object(options.log, 'options.log');
assert.optionalObject(options.server, 'options.server');
assert.optionalObject(options.logBuffer, 'options.logBuffer');
assert.optionalBool(options.printLog, 'options.printLog');
//use server object to emit log data
var server = options.server;
//use logMetrics ringbuffer to store certain period of log records
var logMetrics = options.logBuffer;
//default always print log
var printLog = options.printLog;
if (typeof printLog === 'undefined') {
printLog = true;
}
var errSerializer = bunyan.stdSerializers.err;
if (options.log.serializers && options.log.serializers.err) {
errSerializer = options.log.serializers.err;
}
PrivateKey.prototype.toBuffer = function (format, options) {
if (format === undefined)
format = 'pkcs1';
assert.string(format, 'format');
assert.object(formats[format], 'formats[format]');
assert.optionalObject(options, 'options');
return (formats[format].write(this, options));
};
function removeImageAcl(uuid, acl, account, options, callback) {
var self = this;
assert.string(uuid, 'uuid');
if (typeof (account) === 'function') {
callback = account;
options = {};
account = undefined;
} else if (typeof (options) === 'function') {
callback = options;
options = {};
}
assert.optionalString(account, 'account');
assert.arrayOfString(acl, 'acl');
assert.object(options, 'options');
assert.optionalObject(options.headers, 'options.headers');
assert.func(callback, 'callback');
var path = self._path(format('/images/%s/acl', uuid), {
channel: self.channel,
action: 'remove',
account: account
});
self._getAuthHeaders(function (hErr, headers) {
if (hErr) {
callback(hErr);
return;
}
if (options.headers) {
simpleMerge(headers, options.headers);
}
var reqOpts = {
function createSource(type, opts) {
assert.string(type, 'type');
assert.optionalObject(opts, 'opts');
var source;
switch (type) {
case 'imgapi':
source = new ImgapiSource(opts);
break;
case 'docker':
source = new DockerSource(opts);
break;
case 'dsapi':
source = new DsapiSource(opts);
break;
default:
throw new Error(format('invalid source type: "%s"', type));
};
function lagInSeconds(lag) {
assert.optionalObject(lag);
var seconds, unit;
if (!lag) {
return (null);
}
seconds = lag.seconds || 0;
for (unit in lag) {
switch (unit) {
case 'days':
seconds += lag[unit] * 24 * 60 * 60;
break;
case 'hours':
seconds += lag[unit] * 60 * 60;
break;
function DownloadError(cause, message) {
if (message === undefined) {
message = cause;
cause = undefined;
}
assert.optionalObject(cause);
assert.string(message);
ImgadmError.call(this, {
cause: cause,
message: message,
code: 'DownloadError'
});
}
util.inherits(DownloadError, ImgadmError);