Automated dependency security scanning, patching, testing, and Pull Request creation for Node.js/npm projects.
npm-audit-fix automates the repetitive process of identifying known vulnerabilities in npm dependencies, applying available patch updates, verifying the project with its test suite, and creating a GitHub Pull Request with the changes.
The goal is simple: find vulnerable dependencies → apply safe updates → run tests → create a PR.
🔍 Automated Security Audit
Runs npm audit --json to identify known vulnerabilities.
📦 Dependency Patching Updates vulnerable dependencies to available patched versions.
🧪 Test Verification
Runs the target project's native npm test command after dependency updates.
🌿 Automatic Git Branching Creates a dedicated branch for security fixes.
💾 Automatic Commits Commits updated dependency files with a descriptive commit message.
🚀 Automatic Push Pushes the security-fix branch to GitHub.
🔀 Automatic Pull Requests Creates a GitHub Pull Request containing the updated packages and vulnerability information.
🔄 Retry Workflow If tests fail, the repository state is preserved so fixes can be made manually before resuming the process.
🛡️ Safe Failure Handling The tool stops when dependency installation or tests fail instead of automatically creating a PR with unverified changes.
┌─────────────────────┐
│ GitHub Repository │
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ Clone Repository │
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ npm audit │
│ Find vulnerabilities│
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ Update Dependencies │
│ to patched versions│
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ npm install │
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ npm test │
└──────────┬──────────┘
│
┌───────┴───────┐
│ │
FAIL PASS
│ │
▼ ▼
Manual Fix Commit Changes
│ │
│ ▼
└──────────► Push Branch
│
▼
Create GitHub PR
npm audit --json.npm install.npm test script.Before using npm-audit-fix, make sure you have:
package.jsonThe target project must use npm.
git clone https://github.com/faisalalidoka-stack/npm-audit-fix.git
cd npm-audit-fix
pip install -r requirements.txt
You can optionally install the project as a command-line application:
pip install -e .
After installation, the following command becomes available:
npm-audit-fix
The tool requires a GitHub Personal Access Token.
.env fileCopy the example environment file:
cp .env.example .env
Then add your token:
GITHUB_TOKEN=your_github_personal_access_token
Never commit your
.envfile or expose your GitHub token publicly.
The token must have sufficient permissions to:
For private repositories, the token needs appropriate repository access.
npm-audit-fix https://github.com/owner/repository
For example:
npm-audit-fix https://github.com/faisalalidoka-stack/example-project
You can specify the branch that will contain the security fixes:
npm-audit-fix https://github.com/owner/repository --branch fix/security-updates
Instead of using .env, you can provide the token through the CLI:
npm-audit-fix https://github.com/owner/repository --token YOUR_GITHUB_TOKEN
Using an environment variable or
.envfile is generally preferable so that the token is not exposed in shell history.
If dependency updates cause the project's tests to fail, the tool preserves the modified repository so you can investigate and fix the problem manually.
After fixing the issue, resume the workflow with:
npm-audit-fix https://github.com/owner/repository --retry
The retry workflow resumes from the testing stage and can continue to commit, push, and create the Pull Request once the tests pass.
Suppose a project contains:
{
"dependencies": {
"lodash": "^4.17.15"
}
}
and npm audit reports a vulnerability with an available patched version.
The tool may produce a workflow similar to:
Step 1: Cloning repository
✓ Repository cloned
Step 2: Creating branch
✓ Created branch: fix/vulnerabilities-20260822-132500
Step 3: Scanning for vulnerabilities
✓ Found vulnerabilities with available patches
Step 4: Updating dependencies
✓ Updated lodash
Step 5: Running tests
✓ All tests passed
Step 6: Committing changes
✓ Changes committed
Step 7: Pushing branch
✓ Branch pushed to GitHub
Step 8: Creating pull request
✓ Pull Request created
The resulting Pull Request contains information about:
The tool automatically detects whether the target project contains an npm test script.
If package.json contains:
{
"scripts": {
"test": "..."
}
}
the tool executes:
npm test
If no test script exists, testing is skipped and the workflow continues.
The tool does not automatically create the Pull Request.
Instead, it:
--retry.This prevents unverified dependency changes from being automatically submitted.
npm-audit-fix/
│
├── cli.py
├── main.py
├── config.py
│
├── scanner.py
├── updater.py
├── test_runner.py
│
├── git_operations.py
├── github_manager.py
├── pr_creator.py
│
├── requirements.txt
├── pyproject.toml
├── .env.example
├── .gitignore
└── README.md
| Module | Responsibility |
|---|---|
cli.py | Command-line interface |
main.py | Main vulnerability-fixing workflow |
scanner.py | Runs and parses npm audit |
updater.py | Updates vulnerable dependencies |
test_runner.py | Runs the target project's tests |
git_operations.py | Handles branches, commits, and pushes |
github_manager.py | Handles GitHub authentication and repository operations |
pr_creator.py | Creates and formats Pull Requests |
config.py | Application configuration |
npm-audit-fix is intentionally conservative, but there are some limitations:
npm test script cannot have their tests verified.GITHUB_TOKEN environment variable is requiredMake sure you have either:
GITHUB_TOKEN=your_token_here
in your .env file, or provide the token using:
npm-audit-fix https://github.com/owner/repository --token YOUR_TOKEN
npm audit failedCheck that:
package.json.Try:
node --version
npm --version
npm install failedThe target repository may already contain dependency problems.
Try cloning the repository manually and running:
npm install
to investigate the issue.
Review the test output displayed by the tool.
After fixing the issue manually, resume with:
npm-audit-fix https://github.com/owner/repository --retry
Check that:
Contributions are welcome.
If you would like to improve npm-audit-fix:
git checkout -b feature/my-improvement
Because this tool works with GitHub credentials and modifies repositories, security should be taken seriously.
Never:
.env to version control.Always review automatically generated Pull Requests before merging them.
This project is licensed under the MIT License.
See the LICENSE file for details.
npm-audit-fix is provided as-is for automating dependency vulnerability remediation.
Automated dependency updates can occasionally introduce compatibility issues or unexpected behavior. Always review generated Pull Requests and run your project's complete test suite before merging security updates into production.
2 commits
Python
100.0%
Automated dependency security scanning, patching, testing, and Pull Request creation for Node.js/npm projects.
npm-audit-fix automates the repetitive process of identifying known vulnerabilities in npm dependencies, applying available patch updates, verifying the project with its test suite, and creating a GitHub Pull Request with the changes.
The goal is simple: find vulnerable dependencies → apply safe updates → run tests → create a PR.
🔍 Automated Security Audit
Runs npm audit --json to identify known vulnerabilities.
📦 Dependency Patching Updates vulnerable dependencies to available patched versions.
🧪 Test Verification
Runs the target project's native npm test command after dependency updates.
🌿 Automatic Git Branching Creates a dedicated branch for security fixes.
💾 Automatic Commits Commits updated dependency files with a descriptive commit message.
🚀 Automatic Push Pushes the security-fix branch to GitHub.
🔀 Automatic Pull Requests Creates a GitHub Pull Request containing the updated packages and vulnerability information.
🔄 Retry Workflow If tests fail, the repository state is preserved so fixes can be made manually before resuming the process.
🛡️ Safe Failure Handling The tool stops when dependency installation or tests fail instead of automatically creating a PR with unverified changes.
┌─────────────────────┐
│ GitHub Repository │
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ Clone Repository │
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ npm audit │
│ Find vulnerabilities│
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ Update Dependencies │
│ to patched versions│
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ npm install │
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ npm test │
└──────────┬──────────┘
│
┌───────┴───────┐
│ │
FAIL PASS
│ │
▼ ▼
Manual Fix Commit Changes
│ │
│ ▼
└──────────► Push Branch
│
▼
Create GitHub PR
npm audit --json.npm install.npm test script.Before using npm-audit-fix, make sure you have:
package.jsonThe target project must use npm.
git clone https://github.com/faisalalidoka-stack/npm-audit-fix.git
cd npm-audit-fix
pip install -r requirements.txt
You can optionally install the project as a command-line application:
pip install -e .
After installation, the following command becomes available:
npm-audit-fix
The tool requires a GitHub Personal Access Token.
.env fileCopy the example environment file:
cp .env.example .env
Then add your token:
GITHUB_TOKEN=your_github_personal_access_token
Never commit your
.envfile or expose your GitHub token publicly.
The token must have sufficient permissions to:
For private repositories, the token needs appropriate repository access.
npm-audit-fix https://github.com/owner/repository
For example:
npm-audit-fix https://github.com/faisalalidoka-stack/example-project
You can specify the branch that will contain the security fixes:
npm-audit-fix https://github.com/owner/repository --branch fix/security-updates
Instead of using .env, you can provide the token through the CLI:
npm-audit-fix https://github.com/owner/repository --token YOUR_GITHUB_TOKEN
Using an environment variable or
.envfile is generally preferable so that the token is not exposed in shell history.
If dependency updates cause the project's tests to fail, the tool preserves the modified repository so you can investigate and fix the problem manually.
After fixing the issue, resume the workflow with:
npm-audit-fix https://github.com/owner/repository --retry
The retry workflow resumes from the testing stage and can continue to commit, push, and create the Pull Request once the tests pass.
Suppose a project contains:
{
"dependencies": {
"lodash": "^4.17.15"
}
}
and npm audit reports a vulnerability with an available patched version.
The tool may produce a workflow similar to:
Step 1: Cloning repository
✓ Repository cloned
Step 2: Creating branch
✓ Created branch: fix/vulnerabilities-20260822-132500
Step 3: Scanning for vulnerabilities
✓ Found vulnerabilities with available patches
Step 4: Updating dependencies
✓ Updated lodash
Step 5: Running tests
✓ All tests passed
Step 6: Committing changes
✓ Changes committed
Step 7: Pushing branch
✓ Branch pushed to GitHub
Step 8: Creating pull request
✓ Pull Request created
The resulting Pull Request contains information about:
The tool automatically detects whether the target project contains an npm test script.
If package.json contains:
{
"scripts": {
"test": "..."
}
}
the tool executes:
npm test
If no test script exists, testing is skipped and the workflow continues.
The tool does not automatically create the Pull Request.
Instead, it:
--retry.This prevents unverified dependency changes from being automatically submitted.
npm-audit-fix/
│
├── cli.py
├── main.py
├── config.py
│
├── scanner.py
├── updater.py
├── test_runner.py
│
├── git_operations.py
├── github_manager.py
├── pr_creator.py
│
├── requirements.txt
├── pyproject.toml
├── .env.example
├── .gitignore
└── README.md
| Module | Responsibility |
|---|---|
cli.py | Command-line interface |
main.py | Main vulnerability-fixing workflow |
scanner.py | Runs and parses npm audit |
updater.py | Updates vulnerable dependencies |
test_runner.py | Runs the target project's tests |
git_operations.py | Handles branches, commits, and pushes |
github_manager.py | Handles GitHub authentication and repository operations |
pr_creator.py | Creates and formats Pull Requests |
config.py | Application configuration |
npm-audit-fix is intentionally conservative, but there are some limitations:
npm test script cannot have their tests verified.GITHUB_TOKEN environment variable is requiredMake sure you have either:
GITHUB_TOKEN=your_token_here
in your .env file, or provide the token using:
npm-audit-fix https://github.com/owner/repository --token YOUR_TOKEN
npm audit failedCheck that:
package.json.Try:
node --version
npm --version
npm install failedThe target repository may already contain dependency problems.
Try cloning the repository manually and running:
npm install
to investigate the issue.
Review the test output displayed by the tool.
After fixing the issue manually, resume with:
npm-audit-fix https://github.com/owner/repository --retry
Check that:
Contributions are welcome.
If you would like to improve npm-audit-fix:
git checkout -b feature/my-improvement
Because this tool works with GitHub credentials and modifies repositories, security should be taken seriously.
Never:
.env to version control.Always review automatically generated Pull Requests before merging them.
This project is licensed under the MIT License.
See the LICENSE file for details.
npm-audit-fix is provided as-is for automating dependency vulnerability remediation.
Automated dependency updates can occasionally introduce compatibility issues or unexpected behavior. Always review generated Pull Requests and run your project's complete test suite before merging security updates into production.
2 commits
Python
100.0%