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.
callback-loader
Advanced tools
Webpack loader that parse your JS-file, call specified functions and replace their call expressions with results
Webpack loader that parse your JS-file, call specified functions and replace their call expressions with the results.
npm install callback-loader
Source file:
var a = multBy2(10);
var b = mult(10, 3);
var c = concat("foo", "bar");
Webpack config:
{
...
callbackLoader: {
multBy2: function(num) {
return num * 2;
},
mult: function(num1, num2) {
return num1 * num2;
},
concat: function(str1, str2) {
return '"' + str1 + str2 + '"';
}
}
}
Result:
var a = 20;
var b = 30;
var c = "foobar";
Notice that quotes was added in concat function.
You can choose which functions will be processed in your query:
'callback?mult&multBy2!example.js'
Result for this query will be this:
var a = 20;
var b = 30;
var c = concat("foo", "bar");
Webpack config:
{
...
callbackLoader: {
concat: function(str1, str2) {
return '"' + str1 + str2 + '"';
}
},
anotherConfig: {
concat: function(str1, str2) {
return '"' + str1 + str2 + '-version2"';
}
}
}
Loader query:
'callback?config=anotherConfig!example.js'
Result for this query will be this:
var a = multBy2(10);
var b = mult(10, 3);
var c = "foobar-version2";
No expressions in function arguments, sorry. Only raw values.
FAQs
Webpack loader that parses your JS, calls specified functions and replaces their with the results.
The npm package callback-loader receives a total of 196 weekly downloads. As such, callback-loader popularity was classified as not popular.
We found that callback-loader 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.