Research
Security News
Malicious PyPI Package ‘pycord-self’ Targets Discord Developers with Token Theft and Backdoor Exploit
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
@hapi/joi - v16.1.8 Making the most powerful schema description language and data validator for JavaScript slightly more powerful.
Joi.string().escape()
&
, >
, <
, "
, '
, \
, /
and `
with HTML entities.Joi.string().unescape()
&
| >
| <
| "
| $
| /
| \
| `
HTML entities with characters.Joi.string().sanitize(function)
Joi.string().alpha()
Joi.string().numeric()
Joi.string().base32()
Joi.string().countryCode(type)
alpha-2
or ISO alpha-3
country code.Joi.string().password(rules)
Joi.string().match(reference)
Joi.string().contain(seed, [index])
Joi.array().inList(list, [label])
$ npm i joi-plus
const Joi = require('joi-plus');
const schema = Joi.object({
username: Joi.string()
.min(8)
.max(20)
.alpha()
.required(),
email: Joi.string()
.email()
.required(),
password: Joi.string()
.password({
min: 8,
max: 120,
lowercase: true,
uppercase: true,
number: true,
special: true
})
.required(),
repeat_password: Joi.string()
.match('password')
.required(),
base32_encoded: Joi.string()
.base32()
.required(),
country: Joi.string()
.countryCode('alpha-2')
.required(),
contact_number: Joi.string()
.min(2)
.max(20)
.numeric()
.required(),
fav_animals: Joi.array()
.inList(['dog', 'cat', 'lion', 'tiger', 'elephant', 'hippo'], 'animals')
.required()
});
The above schema defines the following constraints:
username
email
password
repeat_password
password
base32_encoded
country
contact_number
fav_animals
Using Joi.string().sanitize() with sanitization libraries such as sanitize-html
const sanitizeHtml = require('sanitize-html');
const schema = Joi.object({
escape: Joi.string()
.escape(),
unescape: Joi.string()
.unescape(),
sanitize: Joi.string()
.sanitize(sanitizeHtml)
});
let { error, value } = schema.validate({
escape: '<escape>',
unescape: '<unescape>',
sanitize: 'Hello,<script>evil()</script> I am Good.'
});
console.log(value);
/*
{
escape: '<escape>',
unescape: '<unescape>',
sanitize: 'Hello, I am Good.'
}
*/
1.1.3
Add contain validation
Joi.string().contain('abc')
Joi.string().contain('suffix', -1)
Joi.string().contain('prefix', 0)
FAQs
Joi with extra rules for string and array.
The npm package joi-plus receives a total of 108 weekly downloads. As such, joi-plus popularity was classified as not popular.
We found that joi-plus demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.