
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Regent lets you query a data structure by asking true or false questions. Regent logic is written as single responsibility rules that are self-documenting, composable, and human readable. Let's look at an example.
import { equals } from 'regent';
// return a function that evaluates to true
// if prop `isRaining` is equal to true
const isRaining = equals('@isRaining', true);
// Define your data structure
const data = { isRaining: true };
// Evaluate the rule
const isUmbrellaNeeded = isRaining(data); // true
equals
predicate documentation
Taking the previous example a bit further, we can refine the scenario to be more precise. We can create and combine multiple rules to test this condition
If it is raining and the wind isn't so strong the umbrella will turn inside-out and blow out of our hands, we need an umbrella.
import { and, equals, lessThan } from 'regent';
// Define a rule for `isRaining` and a rule for `isCalm`.
// Use regent and to compose them together
const isRaining = equals('@isRaining', true);
const isCalm = lessThan('@windSpeedInMph', 25);
const isRainingAndCalm = and(isRaining, isCalm);
// Define your data structure
const data = { isRaining: true, windSpeedInMph: 20 };
// Evaluate the rule
isRainingAndCalm(data); // true
Regent also provides a simple way to find or filter array items based on a regent rule.
import { equals, lessThan, find, filter } from 'regent';
const isRaining = equals('@isRaining', true);
const isSunny = lessThan('@cloudCover', 10);
const isCold = lessThan('@temperature', 60);
const data = {
isRaining: false,
cloudCover: 0,
temperature: 42
};
const items = [
{ item: 'Winter hat', rule: isCold },
{ item: 'Sunglasses', rule: isSunny },
{ item: 'Umbrella', rule: isRaining },
]
// filter will return an array with the Winter Hat and Sunglasses objects
// because it is cold and sunny
// [{ item: 'Winter hat', rule: isCold }, { item: 'Sunglasses', rule: isSunny }]
filter(items, data)
npm install --save regent
MIT
FAQs
Javascript rules engine
The npm package regent receives a total of 299 weekly downloads. As such, regent popularity was classified as not popular.
We found that regent demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.