
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
json-expression-eval
Advanced tools
evaluate a json described boolean expression using dynamic functions
A Node.js module that evaluates a json described boolean expression using dynamic functions
npm install json-expression-eval --save
yarn add json-expression-eval
This module enables you to evaluate boolean expressions which are described using a JSON structure and can utilize user defined 'functions'.
There are 4 types op operators you can use:
Example expressions, assuming we have the user and maxCount user defined functions in place can be:
{
"or":[
{
"not":{
"user":"a@b.com"
}
},
{
"maxCount":1
}
]
}
const evaluator = require('json-expression-eval');
const functionsTable = {
user: (user, context) => {
return context.userId === user;
},
maxCount: (maxCount, context) => {
return context.times < maxCount;
}
};
const result = evaluator.evaluate({or:[{user: 'a@b.com'},{not: {and: [{maxCount: 1},{user: 'a2@b.com'}]}}]},{userId:'a@b.com', times: 1},functionsTable);
Output should be 'true'
import { evaluate } from 'json-expression-eval';
const functionsTable : FunctionsTable = {
user: (user :string , context : { userId: string }): boolean => {
return context.userId === user;
},
maxCount: (maxCount: number, context: { times: number }): boolean => {
return context.times < maxCount;
}
};
const result = evaluate({or:[{user: 'a@b.com'},{not: {and: [{maxCount: 5},{user: 'a2@b.com'}]}}]},{userId:'a2@b.com', times: 1},functionsTable);
Output should be 'false'
npm run test
FAQs
json serializable rule engine / boolean expression evaluator
The npm package json-expression-eval receives a total of 413 weekly downloads. As such, json-expression-eval popularity was classified as not popular.
We found that json-expression-eval 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
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.