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.
The tx2 npm package is a lightweight library designed for inter-process communication (IPC) and monitoring in Node.js applications. It provides a simple API for sending and receiving messages between different parts of an application, as well as for monitoring various metrics and events.
Inter-Process Communication (IPC)
This feature allows different parts of an application to communicate with each other by sending and receiving messages through channels.
const tx2 = require('tx2');
// Create a channel
const channel = tx2.channel('my-channel');
// Send a message
channel.send('Hello, World!');
// Receive a message
channel.on('message', (msg) => {
console.log('Received message:', msg);
});
Metric Monitoring
This feature allows you to create and monitor custom metrics within your application. The metrics can be updated periodically and monitored in real-time.
const tx2 = require('tx2');
// Create a metric
const metric = tx2.metric({
name: 'my-metric',
value: () => Math.random() * 100
});
// Update the metric value
setInterval(() => {
metric.set(Math.random() * 100);
}, 1000);
Event Monitoring
This feature allows you to create and emit custom events within your application. Other parts of the application can listen for these events and react accordingly.
const tx2 = require('tx2');
// Create an event
const event = tx2.event('my-event');
// Emit the event
setInterval(() => {
event.emit('Event data');
}, 2000);
// Listen for the event
event.on('data', (data) => {
console.log('Event received:', data);
});
PM2 is a popular process manager for Node.js applications that also provides features for monitoring and managing applications. It includes built-in support for metrics and events, similar to tx2, but also offers additional features like process management, load balancing, and more.
node-ipc is a module for Node.js that provides a simple and flexible way to handle inter-process communication. It supports various communication methods, including TCP, UDP, and Unix sockets. While it focuses more on IPC, it does not provide built-in support for metrics and event monitoring like tx2.
eventemitter2 is an enhanced version of Node.js's built-in EventEmitter class. It provides additional features like wildcard event names and event namespaces. While it excels in event handling, it does not offer IPC or metric monitoring capabilities like tx2.
Report Events, Metrics, Issues, Actions to PM2 and PM2.io.
const tx2 = require('tx2')
let body = { calories : 20 }
tx2.metric('burnt calories', () => body.calories)
tx2.action('lift weights', (cb) => {
cb({ success: true })
})
Check API.md for full API doc.
Once you have created some metrics:
$ pm2 start app.js
Then run:
# Inspect primitive reported
$ pm2 show app
or go to pm2.io for web based interface + insights creation.
Generate documentation:
$ npm run doc
MIT
FAQs
Metrics, Issues, Actions, Events reporting library
We found that tx2 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.