Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
The dezalgo npm package ensures that a callback is always called asynchronously, and not in the same tick of the event loop that it was added in, even if it is already complete. This is useful for preventing stack overflows and ensuring consistent asynchronous behavior.
Ensuring asynchronous callback execution
This feature wraps a callback function to ensure that it is always called on the next tick of the event loop, even if it could be called immediately.
const dezalgo = require('dezalgo')
const callback = dezalgo((err, data) => {
// This will always run asynchronously
console.log('Callback called asynchronously')
})
// Even if we call it synchronously, it will be deferred
callback(null, 'some data')
This package is similar to dezalgo in that it defers the execution of callbacks to the next tick of the event loop. It also allows for passing arguments to the callback, similar to how 'Function.prototype.apply' works.
The setimmediate package provides a way to execute a function asynchronously as soon as possible, but after the current event loop tick. It is similar to dezalgo but uses a different mechanism (setImmediate) which is a standard part of the Node.js and browser environments.
The async package offers a wide range of functions for working with asynchronous code. One of its utilities, 'async.nextTick', is similar to dezalgo in that it ensures a callback is called on the next tick of the event loop.
Contain async insanity so that the dark pony lord doesn't eat souls
See this blog post.
Pass a callback to dezalgo
and it will ensure that it is always
called in a future tick, and never in this tick.
var dz = require('dezalgo')
var cache = {}
function maybeSync(arg, cb) {
cb = dz(cb)
// this will actually defer to nextTick
if (cache[arg]) cb(null, cache[arg])
fs.readFile(arg, function (er, data) {
// since this is *already* defered, it will call immediately
if (er) cb(er)
cb(null, cache[arg] = data)
})
}
FAQs
Contain async insanity so that the dark pony lord doesn't eat souls
The npm package dezalgo receives a total of 7,646,407 weekly downloads. As such, dezalgo popularity was classified as popular.
We found that dezalgo demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.