Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
};
const itemsValid = Joi.object().keys({
type: Joi.valid('Symbol', 'Link').required(),
linkType: enforceDependency({
valid: Joi.valid('Asset', 'Entry'),
when: 'type',
is: 'Link'
}),
validations: Joi.array().unique().items(fieldValidations)
});
const fieldSchema = Joi.object().keys({
id: Joi.string().required(),
newId: Joi.string()
.invalid(Joi.ref('id'))
.max(64)
// the empty case will be caught by joi by default, we don't want duplicate errors
.regex(/^$|^[a-zA-Z][a-zA-Z0-9_]*$/),
name: Joi.string().required(),
type: Joi.valid(
'Symbol',
'Text',
'Integer',
'Number',
'Date',
'Boolean',
'Object',
'Link',
'Array',
'Location'
).required(),
};
// valid namespace options
internals.nsSchema = {
// the namespace name, will default to dir basename if available
name: joi.string()
.required(),
// a path to a directory containing rel descriptors. all rels will automatically be added
dir: joi.string()
.optional(),
// the namespace prefix for shorthand rel addressing (e.g. 'prefix:relname')
prefix: joi.string()
.optional()
.default(joi.ref('name')),
// a short description
description: joi.string()
.optional(),
// a map of rel objects, keyed by name
rels: joi.object()
.optional(),
// validates and adds a rel to the namespace
rel: joi.func()
.optional()
.default(function (rel) {
this.rels = this.rels || {};
if (_.isString(rel)) rel = { name: rel };
submissionId: Joi.string().hex().length(32, 'hex').required(),
submissionDate: Joi.date(),
count: Joi.number().integer().min(0),
/** credential:
* complicated JSON BLOB from anonize2, come back to this later
**/
credential: Joi.string(),
/** surveyorIds:
* an array of random 32-byte ids (base64-encoded).
* length should equal sibling value `count`
**/
surveyorIds: Joi.array().items(Joi.string().length(32, 'base64')), // ideally something like .length(Joi.ref('count'))
satoshis: Joi.ref('contribution.satoshis'),
votes: Joi.ref('count'),
ballots: Joi.object().pattern(VALID_HOSTNAME_REGEX, Joi.number().integer().min(0))
})
const validateTransaction = function (tx) {
return Joi.validate(tx, transactionSchema)
}
const generateTransaction = function () {
const count = Math.round(Math.random() * 100)
const viewingId = generateViewingId()
const surveyorId = generateSurveyorId()
const contribution = generateContribution()
const submissionStamp = generateSubmissionStamp()
const submissionDate = new Date(submissionStamp)
submissionDate: Joi.date(),
count: Joi.number().integer().min(0),
/** credential:
* complicated JSON BLOB from anonize2, come back to this later
**/
credential: Joi.string(),
/** surveyorIds:
* an array of random 32-byte ids (base64-encoded).
* length should equal sibling value `count`
**/
surveyorIds: Joi.array().items(Joi.string().length(32, 'base64')), // ideally something like .length(Joi.ref('count'))
satoshis: Joi.ref('contribution.satoshis'),
votes: Joi.ref('count'),
ballots: Joi.object().pattern(VALID_HOSTNAME_REGEX, Joi.number().integer().min(0))
})
const validateTransaction = function (tx) {
return Joi.validate(tx, transactionSchema)
}
const generateTransaction = function () {
const count = Math.round(Math.random() * 100)
const viewingId = generateViewingId()
const surveyorId = generateSurveyorId()
const contribution = generateContribution()
const submissionStamp = generateSubmissionStamp()
const submissionDate = new Date(submissionStamp)
const submissionId = generateSubmissionId()
}
const itemsValid = Joi.object().keys({
type: Joi.string().valid('Symbol', 'Link').required(),
linkType: enforceDependency({
valid: Joi.string().valid('Asset', 'Entry'),
when: 'type',
is: 'Link'
}),
validations: Joi.array().unique().items(fieldValidations)
})
const fieldSchema = Joi.object().keys({
id: Joi.string().required(),
newId: Joi.string()
.invalid(Joi.ref('id'))
.max(64)
// the empty case will be caught by joi by default, we don't want duplicate errors
.regex(/^$|^[a-zA-Z][a-zA-Z0-9_]*$/),
name: Joi.string().required(),
type: Joi.string().valid(
'Symbol',
'Text',
'Integer',
'Number',
'Date',
'Boolean',
'Object',
'Link',
'Array',
'Location',
'RichText'
import { isFunction } from 'lodash/fp';
import { updateSignal } from '../alerts/update_signals';
import { UpdateSignalsRequest } from '../alerts/types';
import { updateSignalSchema } from './schemas';
export const createUpdateSignalsRoute: Hapi.ServerRoute = {
method: 'PUT',
path: '/api/siem/signals/{id?}',
options: {
tags: ['access:signals-all'],
validate: {
options: {
abortEarly: false,
},
params: {
id: Joi.when(Joi.ref('$payload.id'), {
is: Joi.exist(),
then: Joi.string().optional(),
otherwise: Joi.string().required(),
}),
},
payload: updateSignalSchema,
},
},
async handler(request: UpdateSignalsRequest, headers) {
const {
description,
enabled,
false_positives: falsePositives,
filter,
from,
immutable,
.email()
.required(),
token: Joi.string()
.trim()
.hex()
.required(),
password: Joi.string()
.min(8)
.max(256)
.label('Password')
.required(),
password2: Joi.string()
.min(8)
.max(256)
.label('Password confirmation')
.valid(Joi.ref('password'))
.options({
language: {
any: {
allowOnly: '!!Passwords do not match'
}
}
})
.required()
});
const result = Joi.validate(req.body, schema, {
abortEarly: false,
convert: true,
stripUnknown: true
});
module.exports = () => Joi.object({
pkg: Joi.object({
version: Joi.string().default(Joi.ref('$version')),
buildNum: Joi.number().default(Joi.ref('$buildNum')),
buildSha: Joi.string().default(Joi.ref('$buildSha')),
}).default(),
env: Joi.object({
name: Joi.string().default(Joi.ref('$env')),
dev: Joi.boolean().default(Joi.ref('$dev')),
prod: Joi.boolean().default(Joi.ref('$prod'))
}).default(),
pid: Joi.object({
file: Joi.string(),
exclusive: Joi.boolean().default(false)
}).default(),
server: Joi.object({
host: Joi.string().hostname().default('0.0.0.0'),
module.exports = () => Joi.object({
pkg: Joi.object({
version: Joi.string().default(Joi.ref('$version')),
buildNum: Joi.number().default(Joi.ref('$buildNum')),
buildSha: Joi.string().default(Joi.ref('$buildSha')),
}).default(),
env: Joi.object({
name: Joi.string().default(Joi.ref('$env')),
dev: Joi.boolean().default(Joi.ref('$dev')),
prod: Joi.boolean().default(Joi.ref('$prod'))
}).default(),
pid: Joi.object({
file: Joi.string(),
exclusive: Joi.boolean().default(false)
}).default(),
server: Joi.object({
const Promise = require('bluebird')
const Joi = require('joi')
const validate = Promise.promisify(Joi.validate)
const Channel = Joi.object().keys({
name: Joi.string().required(),
topic: Joi.string(),
})
const User = Joi.object().keys({
id: Joi.array().required().items(Joi.ref('channel'), Joi.ref('nick')),
channel: Joi.string().required(),
nick: Joi.string().required(),
isOp: Joi.boolean(),
isVoiced: Joi.boolean(),
})
const Message = Joi.object().keys({
kind: Joi.any().valid([
'message',
'notice',
'action',
'join',
'quit',
'part',
'kick',
'nick',