Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Prevents bad commit or push (git hooks, pre-commit/precommit, pre-push/prepush, post-merge/postmerge and all that stuff...)
Husky is an npm package that allows you to manage Git hooks easily. It lets you run scripts at specific points in your Git workflow, such as before committing or pushing code. This helps in automating tasks like code linting, testing, and validation before these actions take place, ensuring code quality and consistency.
Pre-commit Hook
This feature allows you to run commands before a commit is made. In this example, `npm test` and `npm run lint` are executed before each commit, ensuring that tests pass and the code is linted.
"husky": {
"hooks": {
"pre-commit": "npm test && npm run lint"
}
}
Pre-push Hook
This feature allows you to run commands before code is pushed to the repository. In this example, `npm run build` is executed before each push, ensuring that the build is updated.
"husky": {
"hooks": {
"pre-push": "npm run build"
}
}
Commit-msg Hook
This feature allows you to run a script to validate the commit message. In this example, `validate-commit-msg.js` is a script that checks if the commit message follows a certain format.
"husky": {
"hooks": {
"commit-msg": "./validate-commit-msg.js"
}
}
Lint-staged is similar to Husky in that it is often used in conjunction with Husky to run linters on staged files in Git. It does not manage Git hooks itself but is designed to run scripts on files that are staged for commit.
Pre-commit is a framework for managing and maintaining multi-language pre-commit hooks. It is similar to Husky but is language-agnostic and can be used outside of the Node.js ecosystem. It requires a separate installation and configuration.
Git hooks made easy
Husky can prevent bad commit, push and more :dog: woof!
npm install husky --save-dev
// Edit package.json
{
"scripts": {
"precommit": "npm test",
"prepush": "npm test",
"...": "..."
}
}
git commit -m "Keep calm and commit"
Existing hooks aren't replaced and you can use any Git hook.
If you're migrating from ghooks
, simply run npm uninstall ghooks --save-dev && npm install husky --save-dev
and edit package.json
. Husky will automatically migrate ghooks
hooks.
npm uninstall husky --save-dev
If you need to debug hooks, simply use npm run <script-name>
. For example:
npm run precommit
If you've installed Node using the standard installer, nvm or homebrew, git hooks will be executed even in GUI applications.
In the case of nvm
, husky will try to use the default
installed version or use the project .nvmrc
.
Git params can be found in GIT_PARAMS
environment variable.
By default, husky will run scripts using --silent
to make the output more readable. If you want to override this, simply pass a different log level to your scripts:
"precommit": "npm run some-script -q"
-q/--quiet
is equivalent to --loglevel warn
which is npm default log level.
Yes
Yes
For Yarn, you currently need to pass --force
to be sure that hooks are going to be installed (yarn add husky --dev --force
). You can also manually install hooks using node node_modules/husky/bin/install
.
MIT - Typicode :cactus:
FAQs
Modern native Git hooks
The npm package husky receives a total of 12,236,465 weekly downloads. As such, husky popularity was classified as popular.
We found that husky demonstrated a healthy version release cadence and project activity because the last version was released less than 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
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.