Guard-Deps is a lightweight, defensive security tool that scans Node.js projects for compromised NPM packages and automatically fixes them using intelligent remediation (upgrade first, downgrade when needed).
Following recent NPM supply-chain attacks that compromised popular packages like chalk
, debug
, simple-swizzle
, and others, Guard-Deps helps protect your projects by detecting known malware versions and providing intelligent remediation.
- π Recursive Project Discovery: Automatically finds all Node.js projects under a root directory
- π Multi-Format Lockfile Support: Parses
package-lock.json
,yarn.lock
,pnpm-lock.yaml
, and fallback topackage.json
- π― Smart Security Analysis: Detects known malware versions and intelligently remediates
- π§ Automatic Fix: Intelligent remediation - upgrades first, downgrades only when needed
- π Multiple Output Formats: Console tables, JSON reports, and Markdown reports
- β‘ Fast & Scalable: Handles 1000+ projects within ~60 seconds
- π Safe Operations: Read-only scanning with optional automated fixes
git clone <repository-url>
cd guard-deps
npm install
npm run build
npm install -g .
git clone <repository-url>
cd guard-deps
npm install
npm run build
npm link
# After making code changes, just rebuild:
npm run build # Global command uses latest code automatically
git clone <repository-url>
cd guard-deps
npm install
npm run build
# Use with node directly
node dist/cli.js scan
node dist/cli.js fix --dry-run
# Basic scanning
guard-deps scan # Scan current directory
guard-deps scan --cwd ./my-project # Scan specific directory
guard-deps scan --cwd /Users/name/Projects # Scan all projects under root
# Output formats
guard-deps scan --out report.json # Save JSON report
guard-deps scan --md report.md # Save Markdown report
guard-deps scan --format json # Output JSON to console
guard-deps scan --format table # Table to console (default)
# Risk level configuration
guard-deps scan --strict # Only confirmed compromised packages
guard-deps scan --fail-on compromised # Exit code 10 on compromised (default)
guard-deps scan --fail-on at_risk # Exit code 11 on at-risk packages
guard-deps scan --audit-all # Run npm audit on all projects
Always preview first with --dry-run
!
# Preview fixes (RECOMMENDED first step)
guard-deps fix --dry-run
# Apply fixes
guard-deps fix # Fix current directory
guard-deps fix --cwd ./my-project # Fix specific project
# Fix options
guard-deps fix --no-force # Disable force npm install & overrides
guard-deps fix --skip-node-modules # Don't remove node_modules (faster)
guard-deps fix --no-backup # Skip package.json backup creation
guard-deps fix --no-rescan # Skip automatic verification scan
Fix Process:
- π Scans for compromised packages (including in node_modules)
- ποΈ Removes
node_modules
andpackage-lock.json
- π Creates backup of
package.json
- π¦ Updates package versions to safe versions
- π Adds overrides/resolutions to force specific versions
- πΎ Runs npm install with force flag
- π Re-scans to verify fixes worked
guard-deps list # List discovered projects
guard-deps info # Show current configuration
guard-deps version # Show version information
guard-deps --help # Get help for any command
Package Manager | Lockfile | Overrides Support |
---|---|---|
NPM | package-lock.json |
overrides field |
Yarn | yarn.lock |
resolutions field |
PNPM | pnpm-lock.yaml |
pnpm.overrides field |
Fallback | package.json |
Direct dependency updates |
- 0: No issues found / successful fix
- 10: Compromised packages found
- 11: At-risk packages found (with
--fail-on at_risk
) - 2: Configuration error
- 3: Parse error
# Clone and install globally
git clone <repository-url>
cd guard-deps
npm install && npm run build && npm install -g .
# OR for development (recommended for contributors)
git clone <repository-url>
cd guard-deps
npm install && npm run build && npm link
cd ~/Projects
guard-deps scan --out security-report.json --md security-report.md
guard-deps fix --dry-run # Preview changes
guard-deps fix # Apply fixes
guard-deps scan # Verify results
src/
βββ types.ts # TypeScript interfaces
βββ env.ts # Environment configuration
βββ discover.ts # Project discovery (recursive scan)
βββ lock-parser/ # Lockfile parsers (npm, yarn, pnpm)
βββ advisory.ts # Advisory database management
βββ analyze.ts # Security analysis and risk assessment
βββ fix.ts # Automatic remediation logic
βββ report/ # Output formatters (table, JSON, markdown)
βββ cli.ts # Command-line interface
# Setup
git clone <repository-url>
cd guard-deps
npm install
# Development workflow
npm run build # Build TypeScript
npm link # Link globally (one-time)
# After code changes
npm run build # Rebuild - global command updates automatically
# Code quality
npm run typecheck # TypeScript validation
npm test # Run tests
- Fork the repository
- Create your feature branch
- Add tests for new functionality
- Ensure all tests pass:
npm test
- Build the project:
npm run build
- Submit a pull request
MIT License - see LICENSE file for details.
Guard-Deps v0.1.0 | Defensive Security for Node.js Dependencies | Built with TypeScript