
Research
/Security News
9 Malicious NuGet Packages Deliver Time-Delayed Destructive Payloads
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.
Observe the object property getter, setter or method calls and add custom behavior.
Observe the object property getter, setter or method calls and add custom behavior.
ghostrap can intercept object on any timing (e.g. property value change, assignment, function invocation, etc).
<script src="ghostrap.js"></script>
or
<script src="ghostrap.min.js"></script>
Function object ghostrap will defined in the global scope.
npm install ghostrap
var ghostrap = require('ghostrap');
bower install ghostrap
ghostrap is a handy constructor.
new operator is not needed.
In this example, outputs a log when the object message has change.
var myModel = {
id: 1,
message: 'Hello'
};
var ghost = ghostrap(myModel);
ghost.on('change:message', function() {
console.log('message changed!');
});
myModel.message = 'Good evening';
// message changed!
myModel.message = 'Good night';
// message changed!
Add new handler.
The first argument type separates by a colon.
'when:propName' e.g. 'get:myPropName'
The second argument func is a handler function. On callback arguments are following.
function(target, key, value, args) { ... }
Example:
var myData = {
data: '',
maxLength: 20
};
var ghost = ghostrap(myData);
ghost.on('set:data', function(target, key, value) {
// Truncate data value to the maximum length when set new data.
if (value.length > myData.maxLength) {
value = value.substr(0, myData.maxLength - 3) + '...';
}
return value;
});
myData.data = 'Lorem ipsum dolor sit amet';
console.log(myData.data); // 'Lorem ipsum dolor...'
Add a new handler. Just like on, but handler is called only once.
Remove a handler. If argument type is specified, same types handlers are removed. If argument func is specified, same handlers are removed. If arguments is omitted, all handlers are removed.
Example:
var myModel = {
id: 1,
message: 'Hello'
};
function onMessageChange(target, key, value) {
console.log('message changed!', value);
}
var ghost = ghostrap(myModel);
ghost.on('change:message', onMessageChange);
myModel.message = 'Good evening';
// message changed!
myModel.message = 'Good night';
// message changed!
ghost.off('change:message', onMessageChange);
myModel.message = 'Good morning';
// no console logs.
Clear all handlers and release the target object reference.
MIT
FAQs
Observe the object property getter, setter or method calls and add custom behavior.
We found that ghostrap 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 researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.