Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return {};
}
Hoek.assert(typeof value === 'string', 'Invalid string');
// Encodings: 'base64json', 'base64', 'form', 'iron', 'none'
if (definition.encoding === 'iron') {
return await Iron.unseal(value, definition.password, definition.iron || Iron.defaults);
}
if (definition.encoding === 'base64json') {
const decoded = Buffer.from(value, 'base64').toString('binary');
try {
return Bourne.parse(decoded);
}
catch (err) {
throw Boom.badRequest('Invalid JSON payload');
}
}
if (definition.encoding === 'base64') {
return Buffer.from(value, 'base64').toString('binary');
}
// encoding: 'form'
return Querystring.parse(value);
};
const decryptOptions = Hoek.clone(options.encryption);
decryptOptions.salt = encryptionSalt;
try {
decryptOptions.iv = B64.base64urlDecode(encryptionIv, 'buffer');
}
catch (err) {
throw Boom.boomify(err);
}
const decrypted = await exports.decrypt(password.encryption, decryptOptions, encrypted);
// Parse JSON
try {
return Bourne.parse(decrypted);
}
catch (err) {
throw new Boom.Boom('Failed parsing sealed object JSON: ' + err.message);
}
};
method(value, helpers) {
if (typeof value !== 'string' ||
value[0] !== '[' && !/^\s*\[/.test(value)) {
return;
}
try {
return { value: Bourne.parse(value) };
}
catch (ignoreErr) { }
}
}
method (value, helpers) {
if (typeof value !== 'string') return
if (value[0] !== '{' && !/^\s*\{/.test(value)) return
try {
return { value: Bourne.parse(value) }
} catch (ignoreErr) { }
}
}
internals.tryParseBuffer = function (buffer, next) {
if (buffer.length === 0) {
return next(null, null);
}
let payload;
try {
payload = Bourne.parse(buffer.toString());
}
catch (err) {
return next(Boom.badGateway(err.message, { payload: buffer }));
}
return next(null, payload);
};
async [getValue](key) {
const serializedValue = await this[getAsync](key);
const value = Bourne.parse(serializedValue, null, 'remove');
return value;
}
module.exports = prototypeInjectionHandler = (req, res, next) => {
try {
if (req.body && typeof req.body === 'object') {
Bourne.scan(req.body);
}
next();
} catch (error) {
let OperationOutcome = require(resolveSchema('3_0_1', 'operationoutcome'));
let err = new OperationOutcome({
statusCode: 400,
issue: [
{
severity: 'error',
code: 'invalid',
details: {
text: error.message,
},
},
],
});