Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
eb-patterns
Advanced tools
This module provides a local, synchronous implementation of the AWS EventBridge testEventPattern
API, allowing to test EventBridge event patterns without the need to hit AWS servers. It's designed to be quick, efficient, and easy to integrate.
npm install eb-patterns
import { testEventPattern } from 'eb-patterns';
const event = { /* your AWS event JSON string */ };
const pattern = { /* your AWS eventPattern JSON string */ };
/*
behaves same like AWS` testEventPattern method
https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/EventBridge.html#testEventPattern-property
*/
const result = testEventPattern({ Event: event, EventPattern: pattern });
console.log(result); // true or false based on pattern matching
import { testPattern } from 'eb-patterns';
const data = { contact: { name: 'John', age: 30, nationality: 'DE' } };
const pattern = { contact: { name: ['John'], age: [{ numeric: ['>=', 25] } };
// test any patterns
const result = testPattern(data, pattern);
console.log(result); // true or false based on pattern matching
testEventPattern(params)
params
: An object that contains the parameters for testEventPattern
.params.Event
: This should resemble an EventBridge event's format. It's a JSON string representing a valid object and must include these properties: id, detail-type, source, account, time, region, detail.params.EventPattern
: A JSON string that represents a valid JSON object. It must contain all of the following properties: detail
testPattern(data, pattern)
data
: The data object to test.pattern
: The pattern object against which the event is tested.Returns true
if the event matches the pattern, false
otherwise.
Comparison | Example | Rule syntax |
---|---|---|
Null | first_name is null | "first_name": [ null ] |
Empty | last_name is empty | "last_name": [""] |
Equals | email is "j.doe@email.com" | "email": [ "j.doe@email.com" ] |
Equals (ignore case) | first_name is "John" | "first_name": [ { "equals-ignore-case": "john" } ] |
And | fist_name is "John" and last_name is "Doe" | "first_name": [ "John" ], "last_name": ["Doe"] |
Or | payment_type is "Invoice" or "SEPA" | "payment_type": [ "invoice", "sepa"] |
Or (multiple fields) | first_name is "John", or last_name is "Doe". | "$or": [ { "first_name": [ "John" ] }, { "last_name": [ "Doe" ] } ] |
Not | status is anything but "cancelled" | "status": [ { "anything-but": [ "cancelled" ] } ] |
Numeric (equals) | price is 100 | "price": [ { "numeric": [ "=", 100 ] } ] |
Numeric (range) | price is more than 10, and less than or equal to 20 | "price": [ { "numeric": [ ">", 10, "<=", 20 ] } ] |
Exists | product_name exists | "product_name": [ { "exists": true } ] |
Does not exist | product_name does not exist | "product_name": [ { "exists": false } ] |
Begins with | product_name starts with PRO- | "product_name": [ { "prefix": "PRO-" } ] |
Ends with | filename ends with a .png extension | "filename": [ { "suffix": ".png" } ] |
Wildcard | search a string using a wildcard | "email": [ { "wildcard": "*@doe.com" } ] |
Wildcard in key | wildcard in the pattern key | "person.*.key": [ { "exists": true } ] |
FAQs
JS library to test event bridge patterns synchronously
The npm package eb-patterns receives a total of 2 weekly downloads. As such, eb-patterns popularity was classified as not popular.
We found that eb-patterns demonstrated a healthy version release cadence and project activity because the last version was released less than 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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.