Advanced NPM Package Security Analysis Tool with AI-Powered Intelligence
Soft Awake is a comprehensive CLI tool that leverages Large Language Models (LLMs) to analyze NPM packages for security vulnerabilities, malware detection, and dependency risks. It provides intelligent recommendations for safer alternatives and helps developers make informed decisions about their project dependencies.
npm install -g soft-awake
git clone https://github.com/ktfth/soft-awake.git
cd soft-awake
npm install
npm run build
npm link
Configure your OpenRouter API key:
soft-awake config set api-key sk-or-v1-your-api-key-here
Analyze a single package:
soft-awake analyze express
Scan your project's dependencies:
soft-awake scan package.json --include-dev
analyze - Analyze NPM PackagesAnalyze one or more NPM packages for security vulnerabilities and malware.
soft-awake analyze <packages...> [options]
Arguments:
<packages...> - One or more NPM package names to analyzeOptions:
-v, --version <version> - Specific package version to analyze (default: latest)-f, --format <format> - Output format: json|text|html (default: text)-o, --output <file> - Output file path (default: stdout)-d, --depth <number> - Maximum dependency tree depth 1-15 (default: 5)--no-cache - Disable caching-s, --severity <level> - Minimum severity: low|medium|high|critical (default: medium)-t, --timeout <seconds> - Analysis timeout per package 5-300s (default: 30)Examples:
# Analyze latest version of express
soft-awake analyze express
# Analyze specific version with high severity filter
soft-awake analyze react@18.2.0 --severity high
# Analyze multiple packages with JSON output
soft-awake analyze lodash axios moment --format json
# Deep analysis with custom timeout
soft-awake analyze webpack --depth 10 --timeout 60
scan - Scan package.json FilesScan a package.json file and analyze all dependencies.
soft-awake scan [package-json-path] [options]
Arguments:
[package-json-path] - Path to package.json file (default: ./package.json)Options:
-f, --file <path> - Path to package.json file (default: ./package.json)--include-dev - Include devDependencies in analysis-e, --exclude <patterns...> - Package names to exclude from analysis-o, --format <format> - Output format: json|text|html (default: text)--output <file> - Output file path (default: stdout)Examples:
# Scan current directory's package.json
soft-awake scan
# Scan with dev dependencies included
soft-awake scan --include-dev
# Scan specific file excluding test packages
soft-awake scan ./frontend/package.json --exclude "@types/*" "jest"
# Generate HTML report
soft-awake scan --format html --output security-report.html
cache - Manage Analysis CacheManage the analysis result cache for improved performance.
soft-awake cache <subcommand> [options]
Subcommands:
clear - Clear all cached analysis resultsinfo - Display cache statistics and informationclean - Remove expired cache entriesOptions:
-f, --force - Force operation without confirmation (for clear command)Examples:
# View cache information
soft-awake cache info
# Clean expired entries
soft-awake cache clean
# Clear all cache (with confirmation)
soft-awake cache clear
# Force clear all cache
soft-awake cache clear --force
config - Manage ConfigurationManage tool configuration settings.
soft-awake config <subcommand> [key] [value]
Subcommands:
set <key> <value> - Set a configuration valueget <key> - Get a configuration valuelist - List all configuration settingsConfiguration Keys:
api-key - OpenRouter API key for LLM analysiscache-ttl - Cache time-to-live in hours (1-8760)Examples:
# Set OpenRouter API key
soft-awake config set api-key sk-or-v1-your-api-key-here
# Set cache TTL to 24 hours
soft-awake config set cache-ttl 24
# Get current API key
soft-awake config get api-key
# List all settings
soft-awake config list
withdrawn - Analyze Withdrawn VersionsAnalyze potentially withdrawn or removed package versions due to security vulnerabilities.
soft-awake withdrawn <package> [options]
Arguments:
<package> - NPM package name to analyze for withdrawn versionsOptions:
-f, --format <format> - Output format: text|json (default: text)-o, --output <file> - Output file path (default: stdout)-v, --verbose - Show detailed analysis informationExamples:
# Analyze debug package for withdrawn versions
soft-awake withdrawn debug
# Verbose analysis with detailed gap information
soft-awake withdrawn express --verbose
# JSON output for programmatic processing
soft-awake withdrawn lodash --format json
# Save report to file
soft-awake withdrawn react --output withdrawn-analysis.txt
What This Command Detects:
Soft Awake requires an OpenRouter API key for LLM-powered analysis:
soft-awake config set api-key sk-or-v1-your-keyYou can also set configuration via environment variables:
export SOFT_AWAKE_API_KEY="sk-or-v1-your-api-key"
export SOFT_AWAKE_CACHE_TTL="168" # 7 days in hours
# Quick security check
soft-awake analyze express
# Detailed analysis with full dependency tree
soft-awake analyze express --depth 15 --severity low
# Check specific version
soft-awake analyze react@17.0.2
# Full project audit including dev dependencies
soft-awake scan --include-dev --format json --output audit.json
# Production dependencies only
soft-awake scan --exclude "@types/*" "eslint*" "jest"
# Analyze multiple related packages
soft-awake analyze react react-dom react-router
# Check all testing frameworks
soft-awake analyze jest mocha chai --severity high
# Generate comprehensive HTML report
soft-awake scan --format html --output security-report.html --include-dev
# JSON output for CI/CD integration
soft-awake analyze $PACKAGE_NAME --format json --severity critical
Human-readable format with color coding and clear sections:
📊 SECURITY REPORT
==================================================
Package: express@4.18.2
Risk Level: MEDIUM
Overall Score: 45/100
🔴 Critical Issues (2):
• Potential ReDoS vulnerability in path-to-regexp
• Outdated dependency with known CVE
🟡 Medium Issues (3):
• Missing security headers configuration
• Deprecated dependency usage
• Insufficient input validation
💡 Recommendations:
• Update to express@4.19.0 or later
• Consider fastify as a more secure alternative
• Implement helmet middleware for security headers
⏱ Analysis time: 2.3s | Cached: No
--------------------------------------------------
Structured data for programmatic processing:
{
"package": {
"name": "express",
"version": "4.18.2",
"analyzedAt": "2024-01-15T10:30:00Z"
},
"security": {
"overallScore": 45,
"riskLevel": "MEDIUM",
"issues": [
{
"severity": "CRITICAL",
"type": "vulnerability",
"title": "Potential ReDoS vulnerability",
"description": "...",
"cve": "CVE-2024-1234"
}
]
},
"recommendations": [
{
"type": "update",
"current": "4.18.2",
"recommended": "4.19.0",
"reason": "Security patches"
}
]
}
Complete web report with interactive elements and visualizations.
Soft Awake uses specific exit codes to indicate analysis results:
Use exit codes for automated security gates:
# Fail CI if critical issues found
soft-awake analyze $PACKAGE --severity critical
if [ $? -eq 1 ]; then
echo "Critical security issues found!"
exit 1
fi
Soft Awake integrates with OpenRouter for LLM-powered analysis:
Direct integration with the NPM registry for package metadata:
We welcome contributions! Please see our Contributing Guide for details.
git clone https://github.com/ktfth/soft-awake.git
cd soft-awake
npm install
npm run dev
# Run all tests
npm test
# Run contract tests
npm run test:contract
# Run with coverage
npm run test:coverage
# Build for production
npm run build
# Build and watch for changes
npm run build:watch
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ for a more secure JavaScript ecosystem