Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Produces a compact module exporting JSON-schema validation functions compiled by Ajv
Produces a compact module exporting JSON-schema validation functions compiled by Ajv
This package allows to create standalone modules for validation functions that are pre-compiled and can be used without Ajv. It can be necessary for several reasons:
Please note: there are many cases when Ajv works as expected and ajv-pack does not. Some of these cases are listed in Limitations. It is recommended to test schemas compiled with this package more thoroughly than you would when using Ajv (which is very stable and well tested). Please submit issues with cases that fail.
In most cases you would use this package via ajv-cli (>= 1.0.0) to generate module that exports validation function.
npm install -g ajv-cli
ajv compile -s schema.json -o validate_schema.js
validate_schema.js
will contain the module exporting validation function that can be bundled into your application.
npm install ajv-pack
var Ajv = require('ajv'); // version >= 4.7.4
var ajv = new Ajv({sourceCode: true}); // this option is required
var pack = require('ajv-pack');
var schema = {
type: 'object',
properties: {
foo: {
type: 'string',
pattern: '^[a-z]+$'
}
}
};
var validate = ajv.compile(schema);
var moduleCode = pack(ajv, validate);
// now you can
// 1. write module code to file
var fs = require('fs');
var path = require('path');
fs.writeFileSync(path.join(__dirname, '/validate.js'), moduleCode);
// 2. require module from string
var requireFromString = require('require-from-string');
var packedValidate = requireFromString(moduleCode);
Ajv should still be a run-time dependency, but generated modules will only depend on some parts of it, the whole Ajv will not be included in the bundle if you require these modules from your code.
At the moment ajv-pack does not support schemas with:
{ "$ref": "#" }
is supported).FAQs
Produces a compact module exporting JSON-schema validation functions compiled by Ajv
We found that ajv-pack 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.