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.
A simpler tapable alternative, which can be used to create hooks for plugins.
Using yarn:
yarn add hable
Using npm:
npm install hable
Extend your base class from Hable:
import Hookable from 'hable'
export default class Foo extends Hookable {
constructor() {
// Call to parent to initialize
super()
}
async someFunction() {
// Call and wait for `hook1` hooks (if any) sequential
await this.callHook('hook1')
// Call and wait for `hook2` hooks (if any) in paraller
await this.callHookAsync('hook2')
}
}
Inside plugins, register for any hook:
const lib = newFooLib()
// Register a handler for `hook2`
lib.hook('hook2', async () => { /* ... */ })
// Register multiply handlers at once
lib.hookObj({
hook1: async () => { /* ... */ },
hook2: [ /* can be also an array */ ]
})
private functions
async callHook(name, ...args)
: Used by class itself to sequentially call handlers of a specific hook.async callHookAsync(name, ...args)
: Same as callHook
but calls handlers in parallel.public functions
hook(name, fn)
: Used by plugins to register a handler for an specific hook. fn
can be a single function or an array.hookObj(hooksObj)
: Register many hooks using an object.private attributes
$hooks
: An object which maps from each hook name to it's handlers.Extracted from Nuxt.js hooks system. Original author: Sébastien Chopin.
MIT
FAQs
Awaitable hooks for Node.js
The npm package hable receives a total of 88,347 weekly downloads. As such, hable popularity was classified as popular.
We found that hable 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.