
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
extend-function
Advanced tools
The easiest way to overwrite other functions with additional functionality
Example: Let's modify alert to keep a history array of the logs:
window.alertHistory = [];
extendFunction('alert', function(args) {
var message = args[0];
alertHistory.push(message);
});
Test it:
alert('a message');
if (alertHistory[0] === 'a message') {
alert('oh geez this function is powerful!');
}
Now let's add ' from DevinRhode2' to every alert message
extendFunction('alert', function(args, nativeAlert) {
//...
nativeAlert(message + ' from DevinRhode2')
});
Works for methods too:
extendFunction('console.log', function(args, nativeConsoleLog) {
//omg console.log was called!
});
For non-global functions, you assign back like this:
localFunction = extendFunction(localFunction, function(args, originalLocalFunction){
//your magic here!
});
Modify return values:
extendFunction('strangeModule.strangeMethod', function(args, prevFunc) {
var returnValue = prevFunc.apply(this, args);
returnValue.extraInfo = 'idk';
return returnValue;
});
Or promises:
extendFunction('$.ajax', function(args, prevFunc) {
var stackOnSend = new Error().stack;
//prevFunc is the original $.ajax
//call that and store the value to return
var ret = prevFunc.apply(this, args);
ret.fail = extendFunction(ret.fail, function(args) {
if (offlineArgs(args)) {
//ignore, failure b/c of being offline
} else {
//report
var e = new Error(args[0]);
e.stack = stackOnSend;
onuncaughtException(e);
}
//nothing returned, so extendFunction calls
//the original fail function and returns
//the value returned from it
});
return ret;
});
MIT licensed
FAQs
extendFunction.js =================
The npm package extend-function receives a total of 2 weekly downloads. As such, extend-function popularity was classified as not popular.
We found that extend-function 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.