
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.
creating spies for your functions
const spy = require('fn-spy')
spy.calledCount() integer, returns the number of times a function as called
spy.calledWith() array, returns the arguments passed to the function
spy.restore() function, restores the function to the initial state
const spyMyEmitter = spy.emitter() and will return the same methods as above
const spyMyEmitter = spy.callback() and will return the same methods as above
generic example
const spy = require('fn-spy')
function foo (...args) {
return args.length
}
let spiedFn = spy(foo)
// calledCount
spiedFn()
spiedFn()
spiedFn.calledCount()// will return 2
// calledWith
spiedFn(1, 2, 3)
spiedFn.calledWith()// will return [[1, 2, 3]]
// restore
spiedFn = spiedFn.restore()// now spiedFn is retored to the initial state
emitter example
const EE = require('events')
const spy = require('fn-spy')
const myEmitter = new EE()
const spyEmitter = spy.emitter()
myEmitter.on('hey', spyEmitter)
myEmitter.emit('hey')
spyEmitter.calledCount()// will return 1
spyEmitter.calledWith()// will return [[]]
callback example
const spy = require('fn-spy')
const spyCallback = spy.callback()
function someFunction (cb) {
cb()
}
someFunction(spyCallback)
spyCallback.calledCount()// will return 1
spyCallback.calledWith()// will return [[]]
FAQs
creating spies for your functions
The npm package fn-spy receives a total of 2 weekly downloads. As such, fn-spy popularity was classified as not popular.
We found that fn-spy 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.