
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
@geoblink/ajv-extra
Advanced tools
Ajv extra is a drop in replacement for ajv with extra goods.
const Ajv = require('@geoblink/ajv-extra')
const ajv = new Ajv({ allErrors: true })
const schema = { /*** a valid JSON schema ***/ }
validator = ajv.compile(schema)
const isValid = validator({ /*** JSON object to be validated ***/})
Sometimes the schema is parametrized by some information. For example:
const schema = {
type: 'object',
required: ['data'],
properties: {
data: {
oneOf: [
{
type: 'object',
properties: {
origin: {
enum: ['external']
},
/** some external properties **/
}
},
{
type: 'object',
properties: {
origin: {
enum: ['internal']
},
/** some external properties **/
}
},
]
}
}
}
In the previous example, we receive data that can be either internal or external with a schema that depends on origin. This schema is nice to work with because data is always present. Depending on the origin we'll have one or the other.
However, there is a big hindrance. Logs are really ugly. If we are given:
const obj = {
data: {
origin: 'internal',
/** wrong properties for internal **/
}
}
ajv has will show the logs for internal and external, although we are only interested in the internal properties. To solve this problem, we can use oneOfByKey
which has a very similar syntax
const schema = {
type: 'object',
required: ['data'],
properties: {
data: {
oneOfByKey: {
key: 'origin',
oneOf: [
{
type: 'object',
properties: {
origin: {
enum: ['external']
},
/** some external properties **/
}
},
{
type: 'object',
properties: {
origin: {
enum: ['internal']
},
/** some external properties **/
}
},
]
}
}
}
}
Now the validator knows that we are only interested in errors for internal properties
FAQs
Extra goods for ajv
We found that @geoblink/ajv-extra 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
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.