Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
A queue with a unique use case.
I created this queue data structure because of the unique use case I ran into. I needed to open files in an asynchronous way, to maximize efficiency. But I needed to read from them in order, including subdirectories. This queue helped me do that, although for now I can't think of other use cases for this.
I've also tried to think of a way to simplify this and possibly break it down into 2 type of queues. But since both workers depend on each other and share the same concurrency, I'm starting to think this is what the simplified solution is. :/
Creates a queue with the given workers and concurrency. Jobs will be executed asynchronously with no more than concurrency
running at once. worker1
will be alled the arguments which Queue2#push()
was called with plus a callback function that should be called with either an error or results when the task finishes.
function worker1(a, b, c, callback) {
someAsyncOp(a, b, c, callback);
}
The worker1
function is also called with a context which contains a method named inject
for placing additional tasks in place, in the same position, of the current running task. The context also includes an injected
key which will be true
if the current task was added using the inject
function.
function worker1(a, b, c, callback) {
this.inject([
[1, 2, 3],
[2, 3, 4],
[3, 4, 5]
]);
}
The callback
should not be called when inject
is used. Since the tasks injected are supposed to replace the current one.
Pushes a task onto the queue. If the last argument is a function and it corresponds with the position of the callback from the first worker, then it will be called once there is an error with the task, or the task finishes.
For example:
const q = new Queue2((a, callback) => {
// a === 1
callback(null);
}, worker2);
q.push(1, (err) => {
if (err) throw err;
// will be called once this finishes
});
q.push(1);
Number of active tasks that are running.
Kills the queue.
Error
Emitted when there is an error processing a task and a callback isn't given to the push
method.
Queue is full.
Queue is empty, with tasks still running.
Queue is empty and tasks have finished.
npm install queue2
Tests are written with mocha
npm test
FAQs
A unordered queue and ordered queue working together.
The npm package queue2 receives a total of 81 weekly downloads. As such, queue2 popularity was classified as not popular.
We found that queue2 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
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.