Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function parseOneNum(data, type, format, opts, headType) {
if (format === 'ssh') {
try {
var buf = new SSHBuffer({buffer: data});
var head = buf.readString();
} catch (e) {
/* fall through */
}
if (head === headType) {
var sig = buf.readPart();
assert.ok(buf.atEnd(), 'extra trailing bytes');
sig.name = 'sig';
opts.parts.push(sig);
return (new Signature(opts));
}
}
opts.parts.push({name: 'sig', data: data});
return (new Signature(opts));
}
function dockerIdFromDigest(digest) {
assert.string(digest, 'digest');
var parts = digest.split(':');
assert.ok(parts.length === 2, 'digest should contain exactly one colon');
return parts[1];
}
})
assert.optionalBool(options.credentials, 'options.credentials')
assert.optionalArrayOfString(options.allowHeaders, 'options.allowHeaders')
assert.optionalArrayOfString(options.exposeHeaders,
'options.exposeHeaders')
assert.optionalNumber(options.preflightMaxAge, 'options.preflightMaxAge')
assert.optionalObject(options.preflightStrategy,
'options.preflightStrategy')
var opts = options
opts.origins = options.origins || ['*']
opts.credentials = options.credentials || false
opts.allowHeaders = options.allowHeaders || []
opts.exposeHeaders = options.exposeHeaders || []
assert.ok(options.origins.indexOf('*') === -1 ||
options.credentials === false,
'credentials not supported with wildcard')
constants['EXPOSE_HEADERS'].forEach(function (h) {
if (opts.exposeHeaders.indexOf(h) === -1) {
opts.exposeHeaders.push(h)
}
})
constants['ALLOW_HEADERS'].forEach(function (h) {
if (opts.allowHeaders.indexOf(h) === -1) {
opts.allowHeaders.push(h)
}
})
return {
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 ' +
'mutually exclusive');
/*
* For debugging, we keep track of the original short message (attached
* this Error particularly) separately from the complete message (which
* includes the messages of our cause chain).
*/
this.jse_shortmsg = parsed.shortmessage;
message = parsed.shortmessage;
/*
* If we've been given a cause, record a reference to it and update our
* message appropriately.
*/
cause = parsed.options.cause;
if (cause) {
mod_assertplus.ok(mod_isError(cause), 'cause is not an Error');
this.jse_cause = cause;
if (!parsed.options.skipCauseMessage) {
message += ': ' + cause.message;
}
}
/*
* If we've been given an object with properties, shallow-copy that
* here. We don't want to use a deep copy in case there are non-plain
* objects here, but we don't want to use the original object in case
* the caller modifies it later.
*/
this.jse_info = {};
if (parsed.options.info) {
for (k in parsed.options.info) {
SimPgClient.prototype.start = function (callback)
{
mod_assertplus.ok(this.spg_config !== null,
'cannot call start() before configured');
mod_assertplus.ok(!this.spg_transitioning,
'cannot call start() while transitioning');
mod_assertplus.ok(!this.spg_online,
'cannot call start() after started');
var client = this;
var log = this.spg_log;
var zkstate = this.spg_pgstate.mpg_zk.currentClusterState();
mod_assertplus.ok(this.spg_xlog_waiting === null);
this.spg_transitioning = true;
log.info('starting postgres');
setTimeout(function () {
log.info('postgres started');
client.spg_transitioning = false;
client.spg_online = true;
mod_assertplus.ok(client.spg_xlog_waiting === null);
function assertCompatible(obj, klass, needVer, name) {
if (name === undefined)
name = 'object';
assert.ok(obj, name + ' must not be null');
assert.object(obj, name + ' must be an object');
if (needVer === undefined)
needVer = klass.prototype._sshpkApiVersion;
if (obj instanceof klass &&
klass.prototype._sshpkApiVersion[0] == needVer[0])
return;
var proto = Object.getPrototypeOf(obj);
var depth = 0;
while (proto.constructor.name !== klass.name) {
proto = Object.getPrototypeOf(proto);
assert.ok(proto && ++depth <= MAX_CLASS_DEPTH,
name + ' must be a ' + klass.name + ' instance');
}
assert.strictEqual(proto.constructor.name, klass.name,
name + ' must be a ' + klass.name + ' instance');
var ver = proto._sshpkApiVersion;
function assertHrtime(a)
{
mod_assert.ok(a[0] >= 0 && a[1] >= 0,
'negative numbers not allowed in hrtimes');
mod_assert.ok(a[1] < 1e9, 'nanoseconds column overflow');
}
CloudAPI.prototype._cacheGet = function (key, expiry) {
assert.ok(key);
if (!this.cache)
return null;
var maxAge = expiry || this.cacheExpiry;
var obj = this.cache.get(key);
if (obj) {
assert.ok(obj.ctime);
assert.ok(obj.value);
var now = new Date().getTime();
if ((now - obj.ctime) <= maxAge) {
log.debug({obj: obj}, 'CloudAPI._cacheGet(%s): cache hit', key);
return obj.value;
}
}
log.debug('CloudAPI._cacheGet(%s): cache miss', key);
return null;
};
opts.hashAlgo = 'sha256';
break;
case 'rsa-sha2-512':
assert.strictEqual(type, 'rsa', msg);
opts.hashAlgo = 'sha512';
break;
case 'ssh-ed25519':
assert.strictEqual(type, 'ed25519', msg);
opts.hashAlgo = 'sha512';
break;
default:
throw (new Error('Unknown SSH signature ' +
'type: ' + head));
}
var sig = buf.readPart();
assert.ok(buf.atEnd(), 'extra trailing bytes');
sig.name = 'sig';
opts.parts.push(sig);
return (new Signature(opts));
}
}
opts.parts.push({name: 'sig', data: data});
return (new Signature(opts));
}