
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
ynn-http-assert
Advanced tools
Like http-assert, but has more features for using in some web frameworks, such as Koa.
$ npm i --save ynn-http-assert
const koa = require( 'koa' );
const assert = require( 'ynn-http-assert' );
const app = new Koa();
app.use( async ( ctx, next ) => {
const id = assert( ctx.query.id, 400, 'id is required' )
.is( 'int', 'invalid id' )
.between( [ 100, 1000 ] )
.value();
const pn = assert( ctx.query.pn )
.default( 1 )
.is( 'int' )
.gt( 0 )
.value();
const email = assert( ctx.query.email, 400, 'email is required' )
.is( 'email' )
.custom( v => v.startWith( 'abc' ) )
.value();
const username = await assert( ctx.query.username )
.custom( v => {
return Promise.reject();
}, 400, 'username is invalid' )
.value();
return next();
} );
assert(value, [status], [message], [properties])
default(value)
To set a default value if the value doesn't pass any of the assertions, and then all the assertions rest will be ignored.
const x = assert( ctx.query.x ) // if the ctx.query.x is not truthy, the value will be set to 100
.default( 100 )
.is( 'int' ) // if the value is not an integer, the value will be set to 100
.value();
value([v])
To set/get the value of Assertion instance.
const x = assert( ctx.query.x )
.custom( function( v ) {
this.value( 'new-value' ); // to set the value to 'new-value'
} ).
value(); // to get the value
equal(data, [status], [message], [properties])
notEqual(data, [status], [message], [properties])
strictEqual(data, [status], [message], [properties])
notStrictEqual(data, [status], [message], [properties])
deepEqual(data, [status], [message], [properties])
notDeepEqual(data, [status], [message], [properties])
is(type, [status], [message], [properties])
gt(n, [status], [message], [properties])
gte(n, [status], [message], [properties])
lt(n, [status], [message], [properties])
lte(n, [status], [message], [properties])
between(interval, [status], [message], [properties])
length(interval, [status], [message], [properties])
regex(regex, [status], [message], [properties])
json(fn, [status], [message], [properties])
custom(fn, [status], [message], [properties])
FAQs
A more powerful http assertion library.
The npm package ynn-http-assert receives a total of 1 weekly downloads. As such, ynn-http-assert popularity was classified as not popular.
We found that ynn-http-assert 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 uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.