Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const Joi = require('joi');
const MailParser = require('mailparser');
const SmtpServer = require('smtp-server');
const Teamwork = require('teamwork');
const Wreck = require('wreck');
// Declare internals
const internals = {};
internals.schema = Joi.object({
host: Joi.string().default('0.0.0.0'),
port: Joi.number().integer().min(0).default(0),
onMessage: Joi.func().required(),
smtp: Joi.object({
onData: Joi.forbidden()
})
.unknown()
});
exports.Server = internals.Server = function (options) {
options = Joi.attempt(options, internals.schema, 'Invalid server options');
this._settings = Hoek.clone(options);
this._settings.smtp = this._settings.smtp || {};
this._settings.smtp.disabledCommands = this._settings.smtp.disabledCommands || ['AUTH'];
this._settings.smtp.logger = (this._settings.smtp.logger !== undefined ? this._settings.smtp.logger : false);
this._settings.smtp.onData = (stream, session, callback) => this._onMessage(stream, session, callback);
shared: Joi.boolean()
})
.options({ allowUnknown: true }); // Catbox validates other keys
internals.method = Joi.object({
bind: Joi.object().allow(null),
generateKey: Joi.func(),
cache: internals.cachePolicy,
callback: Joi.boolean()
});
internals.methodObject = Joi.object({
name: Joi.string().required(),
method: Joi.func().required(),
options: Joi.object()
});
internals.register = Joi.object({
once: Joi.boolean(),
routes: Joi.object({
prefix: Joi.string().regex(/^\/.+/),
vhost: internals.vhost
})
.default({}),
select: Joi.array().items(Joi.string()).single()
});
internals.plugin = internals.register.keys({
root: is.string(),
is_dependency: is.boolean(),
dependants: is.array(),
key: '_id',
seed: 0,
data: {
min: 0,
max: 0,
count: 1,
dependencies: is.array().items(is.string()).length(1),
inputs: is.array().items(is.string()).length(1),
pre_run: is.func(),
post_build: is.func(),
},
properties: {
_id: utils.check('string', 'The document id', { post_build: is.func(), }),
doc_type: utils.check('string', 'The document type', { value: is.string(), }),
airline_id: utils.check('integer', 'The airlines id', { pre_build: is.func(), }),
airline_name: utils.check('string', 'The name of the airline', { build: is.func(), }),
airline_iata: utils.check('string', 'The airlines iata code if availabe, otherwise null', { build: is.func(), }),
airline_icao: utils.check('string', 'The airlines icao code if available, otherwise null', { build: is.func(), }),
callsign: utils.check('string', 'The airlines callsign if available', { build: is.func(), }),
iso_country: utils.check('string', 'The ISO country code the airline is based in', { build: is.func(), }),
active: utils.check('boolean', 'Whether or not the airline is active', { pre_build: is.func(), post_build: is.func(), }),
},
});
module.exports = function validateOptions(options, cb) {
let optionsSchema = joi.object({
blacklist: joi.array().items(joi.string()).single().default([]),
id: joi.alternatives().try(
joi.string(),
joi.func()
),
processCollection: joi.func(),
processResource: joi.func(),
relationships: joi.object().pattern(/.+/, joi.object({
type: joi.string().required(),
include: joi.boolean().default(true)
})).default({}).description('the relationships definition for this resource type'),
topLevelLinks: joi.object().default({}),
topLevelMeta: joi.object().default({}),
whitelist: joi.array().items(joi.string()).single().default([])
}).required();
joi.validate(options, optionsSchema, {allowUnknown: true, convert: true}, function(err, validated) {
if (err) {
return cb(errors.generateError('1003', err.message, {error: err}));
}
cb(null, validated);
});
};
'use strict';
const Joi = require('joi');
exports.options = Joi.object({
models: Joi.array().items(Joi.func().class()),
migrationsDir: Joi.string().required(),
knex: Joi.func().required(),
mode: Joi.string().allow('create', 'alter').default('alter'),
migrationName: Joi.string().required()
});
spacing: joi.alternatives()
.try(
joi
.number()
.min(0)
.max(4),
joi
.string()
.min(0)
.max(4),
),
count: joi.alternatives()
.try(null, joi.number()
.min(1)),
output: joi.alternatives()
.try(joi.func(), joi.string()),
models: joi.array()
.items(joi.string()),
threads: joi
.number()
.min(1)
.max(max_threads),
limit: joi
.number()
.min(1)
.max(1000),
plugins: joi
.alternatives()
.try(
null,
joi.string(),
joi.func(),
function StrategyInterface (opts) {
var validatedOptions = Joi.validate(opts || {}, Joi.object().keys({
logFunction: Joi.func().default(function noop () {})
, strategyOptions: Joi.object()
, channel: Joi.object()
, id: Joi.string()
}).requiredKeys('id'))
if (validatedOptions.error != null) {
throw new Error(prettifyJoiError(validatedOptions.error))
}
this.id = validatedOptions.value.id
this._logFunction = validatedOptions.value.logFunction
this._closed = false
}
},
getStatsKeyPrefix: function(type) {
return `marketplace:stats:${type}.`;
},
getStatsKey: function(type, name) {
return this.getStatsKeyPrefix(type) + name;
},
};
const redisConfigSchema = Joi.object().keys({
connectionUrl: Joi.string()
.required(),
getUsedKey: Joi.func()
.arity(1)
.required(),
getIndexKey: Joi.func()
.arity(1)
.required(),
getTemplateKeyPrefix: Joi.func()
.arity(1)
.required(),
getTemplateKey: Joi.func()
.arity(2)
.required(),
getStatsKeyPrefix: Joi.func()
.arity(1)
.required(),
getStatsKey: Joi.func()
.arity(2)
.required(),
});
function generateSchema() {
const topLevelKeys = {
servers: joi.object(),
app: joi.object(),
plugins: joi.array(),
_origionalConfig: joi.object(),
hooks: joi.object().pattern(/.*/, joi.alternatives(joi.object({
localCommand: joi.string(),
remoteCommand: joi.string(),
method: joi.func()
}),
joi.func()
))
};
Object.keys(_pluginValidators).forEach(key => {
topLevelKeys[key] = joi.any();
});
return joi.object().keys(topLevelKeys);
}
then: proc.required()
},
forceGc: {
args: Joi.array().sparse().ordered(
context.required(),
Joi.string().label('script name').required()
),
then: Joi.any().forbidden()
},
fetchHeapSnapshot: {
args: Joi.array().sparse().ordered(
context.required(),
Joi.string().label('script name').required(),
Joi.string().label('snapshot id').required(),
Joi.func().label('on details callback').required(),
Joi.func().label('on data callback').required()
),
then: Joi.any().forbidden()
},
listHeapSnapshots: {
args: Joi.array().sparse().ordered(
context.required(),
Joi.string().label('script name').required()
),
then: Joi.array().items(heapSnapshot).label('snapshot list')
},
removeHeapSnapshot: {
args: Joi.array().sparse().ordered(
context.required(),
Joi.string().label('script name').required(),
Joi.string().label('snapshot id').required()
),