
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).
batching-queue
Advanced tools
A batching queue for items that need to be enqueued one by one, but dequeued in batches
npm install batching-queue
import { BatchingQueue, MemoryStore } from 'batching-queue'
const queue = new BatchingQueue({
store: new MemoryStore(),
batchSize: 12
})
const drain = async (batchesWaiting) => {
const result = await batchesWaiting
console.log(result, 'batches waiting')
for (let i = 0; i < result; i++) {
const batch = await queue.dequeue()
console.log(batch, 'batch')
}
}
(async () => {
// drain remaining batches immediately
drain(queue.length)
// drain batches every 12 items
queue.on('drain', drain)
for (var i = 0; i < 1000; i++) {
await queue.enqueue(i)
}
})()
Config:
store
(require) Storage backend for the queue (see src/stores/memory.js for a reference implementation)batchSize
(required) Batch sizeAdds an item to the queue. Returns true
if a batch is full, otherwise returns false
.
Dequeues the first [batchSize] number of items. If there are not enough items to satisfy batchSize, all the items available will be returned.
Property reports the number of batches waiting in the queue.
Note: if the storage backend is not initialized, this will return null.
You may to implement your own storage backend to interface your database or cache. See the bundled MemoryStore or AsyncMemoryStore for a reference.
Initialize and set up the storage backend. Establish connections, create database collections, etc.
This will be called before calling enqueue()
or dequeue()
when ready === false
.
Destroy the storage backend (optional).
Store an item in the queue.
The store must return the exact number of items in the store subsequent to the storage operation.
Retrieve and delete [batchSize] items from the storage backend.
Return the set of items retrieved.
Return the number of items in the store.
Return true
if ready and setup, otherwise, return false
.
The RedisStore class has the following additional methods:
Config:
redisClient
(required) Instance of node-redisname
Queue list key name, will be randomized if omittedThe RedisStore class has the following additional methods:
Config:
redisClient
(required) Instance of ioredisname
Queue list key name, will be randomized if omittedMIT License
FAQs
Batching queue
The npm package batching-queue receives a total of 0 weekly downloads. As such, batching-queue popularity was classified as not popular.
We found that batching-queue 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.