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.
Create real thread in Node Js from a lambda, file or external app
npm install --save nthread-js
const nthread = require('nthread-js')( /* options */ ); // Initialize with option
nthread.ready(async (mthread) => // Waiting of the starting process [Parent in Main Thread]
{
// create a new thread from lambda [Child in Main Thread]
let child = await mthread.create(async (thread) => {
let params = thread.params;
thread.send(`Now I'm sending child params : ${JSON.stringify(params)}`);
let pres = await thread.response();
console.log('CHILD', pres);
}, 'testOne', 'testTwo');
// Listen stdout of child
child.stdout((data) => {
console.log('child stdout', data);
});
// Process main thread
await child.ready();
let cres = await child.response();
console.log('ROOT', cres);
child.send(`Now I'm sending a message to my child`);
setTimeout(() => { console.log('Exit system'),mthread.exit() }, 3000);
}).catch(err => console.log(err));
Options
from Main ThreadName | Type | Description |
---|---|---|
tmpFolder = 'generated' | String | Name of folder who's all temporary files is saved |
protocol = 'http://' | String | Protocol |
enableSocket = true | Boolean | If enable socket is false so only connect function is available in parent |
port = random | Number | Port |
Name | Type | Description |
---|---|---|
ip | String | Get public ip |
localIp | String | Get local ip |
port | String | Get port |
address | String | Get public uri |
localAddress | String | Get local uri |
connect(string: uri, any: param1, ...) : Promise | Function: Promise | Create a new connection to an external app |
create(function: callback, any: param1, ...) : Promise | Function: Promise | Create a new thread from the callback |
load(string: filePath, any: param1, ...) : Promise | Function: Promise | Create a new thread from the file |
connection(function: callback) : Promise | Function: Promise | Event called for each new external connection |
exit(number: code = 0) | Function | Close all thread and all connection |
Name | Type | Description |
---|---|---|
guid | String | Get guid of child |
params | String | Recover your initial parameters set from child thread |
send(any: data) | Function | Send data to the child thread |
response(function: callback) : Promise | Function: Promise | Event called for each response from child thread |
ready(function: callback) : Promise | Function: Promise | Event called when the child has finished to initialised |
stdout(function: callback) : Promise | Function: Promise | Event called when the child thread write in process (ex: console.log) |
stderr(function: callback) : Promise | Function: Promise | Event called when the child thread have an error in process (ex: console.error) |
exit(function: callback) : Promise | Function: Promise | Event called when the child thread process has exit |
disconnect() | Function | Close child connection |
Name | Type | Description |
---|---|---|
params | Array | Recover your initial parameters sent from main thread |
send(any: data) | Function | Send data to the main thread |
response(function: callback) : Promise | Function: Promise | Wait response from the main thread |
FAQs
Create easily children thread (process) in NodeJs. The purpose is to delegate some part of your code in another process.
The npm package nthread-js receives a total of 0 weekly downloads. As such, nthread-js popularity was classified as not popular.
We found that nthread-js 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.