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.
Creates a "gate" with "locks." When all locks are open, the gate is open, useful for dealing with semi-random async events.
Creates a "Gate" object with multiple "locks" that can be locked and unlocked. Useful for controlling async events.
In addition to using this to determine when multiple async events have completed, this is also useful when something needs to happen only when multiple things are all true, particularly when interacting with the real world, such as for IoT devices.
It was originally developed to help control VISCA cameras where the command buffer needed to wait until multiple things were true before issuing the next command:
Another example imagines an IoT device that does something like opening/closing a valve, but only under these circumstances:
Only when all 4 of these things are true will the update take place.
var Gate = require('./gate');
var gate = new Gate.Gate(
['time','request','safe','ready'],
true //it's locked to start
);
gate.on('unlocked', function() {
//Send the cycle valve command
cycleValve();
//re-lock the user request lock
gate.lock('request',true);
//re-lock the ready lock
gate.lock('ready', true);
//Start a time delay and lock the 'time' lock
gate.lock('time', true);
setTimeout(function() {
gate.lock('time', false); //after 10 mins the time lock is unlocked
}, 10000);
});
//Imagine the following functions:
function listenForUserRequest() {
//since a user requested an update, unlock the request lock
gate.lock('request', false);
}
function listenForSafeState(safe) {
if (safe) {
//the valve has notified us that it's safe to operate
gate.lock('safe', false);
} else {
//not safe to operate, lock the "safe" lock
gate.lock('safe', true);
}
}
function listenForCycleComplete() {
//the update is complete so unlock the ready lock
gate.lock('ready', false);
}
function cycleValve() {
//send the command to cycle the valve
}
It might actually make more sense to reverse the lock states in this example and listen for
gate.on('locked');
because then you would be writing things like:
function theValveIsReady() {
gate.lock('ready',true);
}
instead of:
function theValveIsReady() {
gate.lock('ready',false); //false? that's confusing!
}
and it makes more logical sense to think in terms of ready=true meaning it's ready but that's not how the paradigm was imagined.
You could in theory rename your locks:
var oldNames = ['time','request','safe','ready']
var newNames = ['wait','noRequest','notSafe,'notReady']
and then gate.state() would return something like:
{
wait: true, //not enough time has passed
noRequest: false, //there was in fact a request, so this is false
notSafe: true, //it's not in a safe state
notReady: false //the valve has completed it's last cycle and is ready
}
looking at that output it's easy to see that we need to wait until wait=false and notSafe=false before sending the cycle command.
This is all just convention and semantics though... either way it has the same effect.
FAQs
Creates a "gate" with "locks." When all locks are open, the gate is open, useful for dealing with semi-random async events.
The npm package jw-gate receives a total of 1 weekly downloads. As such, jw-gate popularity was classified as not popular.
We found that jw-gate 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.