
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).
run-callback
Advanced tools
Run async or sync callbacks, such as gulp tasks.
The main ideas are borrowed from orchestrator.
Run the callback with arguments after callback
.
Type: Function
callback
can be asynchronous if it does one of the following:
var run = require('run-callback');
run(
function (a, b, done) {
return new Promise(function (rs) {
rs(a + b);
});
},
2, 1,
function (err, sum) {
console.log('Expected:', 3);
console.log('Actual:', sum);
}
);
var run = require('run-callback');
var Stream = require('stream');
var res = [];
run(
function (a, b) {
var rs = Stream.Readable({ objectMode: true });
var data = [a, b];
rs._read = function () {
if (data.length) {
this.push(data.pop());
} else {
this.push(null);
}
};
process.nextTick(function () {
rs.on('data', function (d) {
res.push(d);
});
});
return rs;
},
1,
2,
function (err) {
console.log('Expected:', [2, 1]);
console.log('Actual:', res);
}
);
That extra argument should be a function.
var run = require('run-callback');
run(
function (a, b, done) {
process.nextTick(function () {
done(null, a + b, a - b);
});
},
2, 1,
function (err, sum, diff) {
console.log('Expected:', 3, 1);
console.log('Actual:', sum, diff);
}
);
Type: Function
Signature: done(err, val1, val2,...)
done
will be called when callback
finishes.
Errors thrown when executing callback
will be passed to done
as the first argument,
and the return value as the second.
var run = require('run-callback');
run(
function (a, b) {
return a + b;
},
1, 2,
function (err, res) {
console.log('Expected:', 3);
console.log('Actual:', res);
}
);
done
will be called when the returned promise resolves.
Any rejected values will be passed as the first arugment, and any fulfilled values as the second.
done
will be called when the returned stream ends (readable, transforms, duplex) or finishes (writable).
Errors will be passed as the only arugment.
done
will be called when callback
invokes the last argument with a possible error object and more values.
done
will be called with the same arguments.
FAQs
Run async & sync callbacks
The npm package run-callback receives a total of 140 weekly downloads. As such, run-callback popularity was classified as not popular.
We found that run-callback 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.