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.
var asyngleton = require('../'),
fs = require('fs');
//called ONCE
var readDir = asyngleton(function(callback) {
fs.readdir(__dirname, callback);
})
//initializes the singleton method above
readDir(function(err, files) {
//do stuff
})
//called after there's a result
readDir(function(err, files) {
//do stuff
});
Creates a new asyngleton function.
factory
- the factory method for creating the singleton. This is called ONCE.Resets the target asyngleton so the factory can be called again.
var fs = require('fs'),
asyngleton = require('asyngleton');
var readDir = asyngleton(function(callback) {
fs.readdir(__dirname, callback);
});
readDir(function(err, files) {
//make the readDir factory callable again
readDir.reset();
//do stuff...
});
creates a dictionary of singletons
var dict = require('asyngleton').dictionary(),
fs = require('fs');
var readThisDir = dict.get("readThisDir", function(onSingleton) {
fs.read(__dirname, onSingleton);
});
var readLibDir = dict.get("readLibDir", function(onSingleton) {
fs.read(__dirname + "/lib", onSingleton);
})
readThisDir(function(err, files) {
//do stuff
});
readLibDir(function(err, files) {
//do stuff
});
name
- the name of the singleton in the dictionaryfactory
- the factory method incase the singleton doesn't exist
var structr = require("structr");
structr.mixin(require("asyngleton"));
var TestClass = structr({
/**
*/
"singleton load": function(onLoad) {
fs.readFile(__dirname + "/config.json", onLoad);
}
});
var test = new TestClass();
test.load(function(config) {
});
//fs.readFile is NOT called again at this point
test.load(function(config) {
});
FAQs
asynchronously generate singletons
We found that asyngleton 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.