Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function parseLong(input) {
assert.number(input);
if (input !== Math.floor(input)) {
throw new Error('Value must be integer');
}
if (input < 0 || input > 0xffffffff) {
throw new Error('Value must be 32 bit');
}
var out = new Addr();
out._fields[7] = input & 0xffff;
out._fields[6] = (input >>> 16);
/* this is ipv4-mapped */
out._fields[5] = 0xffff;
out._attrs.ipv4Bare = true;
out._attrs.ipv4Mapped = true;
return out;
}
'triton._test.number': function validateTritonTestNumber(val) {
assert.number(val, 'val');
return null;
},
'triton._test.boolean': function validateTritonTestBoolean(val) {
function reindexBucket(moray, bucket, callback) {
assert.object(moray, 'moray');
assert.object(bucket, 'bucket');
assert.string(bucket.desc, 'bucket.desc');
assert.string(bucket.name, 'bucket.name');
assert.object(bucket.schema, 'bucket.schema');
assert.number(bucket.version, 'bucket.version');
var rowsPerCall = 100;
var processed = rowsPerCall;
async.whilst(
function () { return processed > 0; },
function (cb) {
moray.reindexObjects(bucket.name, rowsPerCall, { noCache: true },
function (err, res) {
if (err) {
return cb(err);
}
processed = res.processed;
cb();
});
ServerUpgradeResponse.prototype.status = function status(code) {
assert.number(code, 'code');
this.statusCode = code;
return code;
};
function loadConfig(input)
{
var dc, error;
mod_assertplus.object(input);
error = mod_jsprim.validateJsonObject(dnConfigSchemaBase, input);
if (error instanceof Error)
return (new VError(error, 'failed to load config'));
mod_assertplus.number(input.vmaj);
mod_assertplus.number(input.vmin);
if (input.vmaj !== dnConfigMajor)
return (new VError('failed to load config: major ' +
'version ("%s") not supported', input.vmaj));
error = mod_jsprim.validateJsonObject(dnConfigSchemaCurrent, input);
if (error instanceof Error)
return (new VError(error, 'failed to load config'));
dc = new DragnetConfig();
input.datasources.forEach(function (dsconfig) {
dc.dc_datasources[dsconfig.name] = {
'ds_backend': dsconfig.backend,
'ds_backend_config': dsconfig.backend_config,
'ds_filter': dsconfig.filter,
'ds_format': dsconfig.dataFormat
function parseInteger(str, uopts)
{
mod_assert.string(str, 'str');
mod_assert.optionalObject(uopts, 'options');
var baseOverride = false;
var options = PI_DEFAULTS;
if (uopts) {
baseOverride = hasKey(uopts, 'base');
options = mergeObjects(options, uopts);
mod_assert.number(options.base, 'options.base');
mod_assert.ok(options.base >= 2, 'options.base >= 2');
mod_assert.ok(options.base <= 36, 'options.base <= 36');
mod_assert.bool(options.allowSign, 'options.allowSign');
mod_assert.bool(options.allowPrefix, 'options.allowPrefix');
mod_assert.bool(options.allowTrailing,
'options.allowTrailing');
mod_assert.bool(options.allowImprecise,
'options.allowImprecise');
mod_assert.bool(options.trimWhitespace,
'options.trimWhitespace');
mod_assert.bool(options.leadingZeroIsOctal,
'options.leadingZeroIsOctal');
if (options.leadingZeroIsOctal) {
mod_assert.ok(!baseOverride,
'"base" and "leadingZeroIsOctal" are ' +
function le(context, policy) {
assert.number(context, 'context');
return (context <= +policy);
}
function Image(params) {
assert.object(params, 'image params');
assert.number(params.created, 'params.created');
assert.string(params.docker_id, 'params.docker_id');
assert.string(params.image_uuid, 'params.image_uuid');
assert.string(params.owner_uuid, 'params.owner_uuid');
assert.optionalArrayOfString(params.heads, 'params.heads');
assert.number(params.size, 'params.size');
assert.number(params.virtual_size, 'params.virtual_size');
assert.optionalString(params.architecture, 'params.architecture');
assert.optionalString(params.comment, 'params.comment');
assert.optionalObject(params.config, 'params.config');
assert.optionalObject(params.container_config, 'params.container_config');
assert.optionalString(params.parent, 'params.parent');
assert.optionalBool(params.private, 'params.private');
assert.optionalString(params.author, 'params.author');
this.params = params;
if (!this.params.heads)
this.params.heads = [];
if (this.params.architecture === undefined) {
this.params.architecture = '';
}
if (this.params.comment === undefined) {
this.params.comment = '';
function opensslKeyDeriv(cipher, salt, passphrase, count) {
assert.buffer(salt, 'salt');
assert.buffer(passphrase, 'passphrase');
assert.number(count, 'iteration count');
var clen = CIPHER_LEN[cipher];
assert.object(clen, 'supported cipher');
salt = salt.slice(0, PKCS5_SALT_LEN);
var D, D_prev, bufs;
var material = new Buffer(0);
while (material.length < clen.key + clen.iv) {
bufs = [];
if (D_prev)
bufs.push(D_prev);
bufs.push(passphrase);
bufs.push(salt);
D = Buffer.concat(bufs);
for (var j = 0; j < count; ++j)
function zeroPadToLength(buf, len) {
assert.buffer(buf);
assert.number(len);
while (buf.length > len) {
assert.equal(buf[0], 0x00);
buf = buf.slice(1);
}
while (buf.length < len) {
var b = Buffer.alloc(buf.length + 1);
b[0] = 0x00;
buf.copy(b, 1);
buf = b;
}
return (buf);
}