Skip to main content

Advanced NPM Security Scanner for supply chain analysis

Project description

Crimson7 NPM Security Scanner

Advanced supply chain security analysis for NPM repositories with comprehensive threat detection capabilities.

Features

  • Advanced Pattern Detection: Crypto mining, credential harvesting, data exfiltration, anti-debugging
  • Behavioral Analysis: Package metadata, network behavior, file operations
  • Vulnerability Assessment: CVE database integration, version analysis
  • Dependency Chain Analysis: Typosquatting detection, circular dependencies
  • Risk Scoring: Multi-layered risk assessment with weighted scoring
  • Threat Intelligence: Enhanced malware signatures and patterns

Installation from Source

# Clone the repository
git clone https://github.com/crimson7-security/npm-scanner.git
cd npm-scanner

# Install dependencies
pip install -r requirements.txt

# Verify installation
python main.py --help

Installation via PyPI

pip install npmscanner

# Verify installation
npmscanner --help

Usage

Local Project Scanning

# Basic scan
python main.py --local-path "/path/to/project"

# Deep scan with HTML report
python main.py --local-path "/path/to/project" --deep-scan --generate-html

Remote Repository Scanning

# Scan JFrog Artifactory
python main.py --repository-url "https://artifactory.company.com/artifactory/npm-repo/" --api-key "your-key"

# Scan NPM registry
python main.py --repository-url "https://registry.npmjs.org" --deep-scan

Report Generation

# Generate HTML report
python main.py --local-path "/path/to/project" --generate-html

# Convert JSON to HTML
python main.py --json-report scan_results.json --html-report dashboard.html

Command Line Options

Option Description Required
--repository-url NPM repository URL to scan No*
--local-path Local directory path to scan No*
--api-key API key for authenticated access No
--output-path Base directory for reports (saved in /report subfolder) No
--deep-scan Enable deep content analysis No
--all Scan ALL packages (requires --deep-scan) No
--generate-html Generate HTML report after scanning No
--json-report Path to existing JSON scan report to convert to HTML No
--html-report Output HTML file path No

*Either --repository-url or --local-path must be specified.

Output Files

All reports are automatically saved in a /report folder:

project/
├── report/
│   ├── npm_scan_report_YYYYMMDD_HHMMSS.json    # Detailed JSON report
│   ├── npm_scan_report_YYYYMMDD_HHMMSS.html    # Interactive HTML dashboard
│   └── npm_scan_critical_YYYYMMDD_HHMMSS.csv   # Critical findings export
└── ...

Patterns

File Purpose Key Features
source_code.py Source code heuristics 11 detection methods
metadata.py Metadata analysis 9 detection methods
npm_specific.py NPM-specific patterns 6 detection methods
unified_analyzer.py Combined analysis Risk scoring + categorization

Exit Codes

Code Status Meaning
0 ✅ CLEAN No malicious packages found
1 ⚠️ SUSPICIOUS Suspicious packages found
2 🚨 CRITICAL Malicious packages detected

Troubleshooting

Common Issues

# "malicious_packages.json not found"
# Solution: Ensure enhanced database is in project root
ls -la malicious_packages.json

# "Could not download package for deep scan"
# Solution: Check network connectivity and repository access
python main.py --repository-url "https://registry.npmjs.org" --deep-scan

Performance Tips

  • Use --deep-scan only when necessary (resource intensive)
  • Avoid --all flag unless comprehensive scanning is required
  • For CI/CD, use focused scanning with custom output paths

🔗 Enterprise Integration

CI/CD Pipeline Integration

# GitHub Actions workflow
- name: NPM Security Scan
  run: |
    python main.py --local-path . --deep-scan --generate-html
    if [ $? -eq 2 ]; then
      echo "🚨 CRITICAL: Malicious packages detected!"
      exit 1
    fi

Support

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


🛡️ Protect your NPM supply chain with enterprise-grade security analysis!

Visit crimson7.io for more security tools

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

npmscanner-0.1.0.tar.gz (29.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

npmscanner-0.1.0-py3-none-any.whl (32.8 kB view details)

Uploaded Python 3

File details

Details for the file npmscanner-0.1.0.tar.gz.

File metadata

  • Download URL: npmscanner-0.1.0.tar.gz
  • Upload date:
  • Size: 29.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for npmscanner-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bf0fd0f157322e0c18655125fabea4ca31f3ab8e5b7744e6a175caa27db1d0e1
MD5 83cdbe61d73d9bb14afec00e9b418592
BLAKE2b-256 0a913877dd147a7922af7cdaa57c13e22ba411b588618d95210119d43232393f

See more details on using hashes here.

File details

Details for the file npmscanner-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: npmscanner-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 32.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for npmscanner-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2730d029419f2f3e20e73c0dc4d4d4947e9a1a829bf7f7e79ef59d76cd108388
MD5 4432bbfde4aa2650a1447c927e8ffd4c
BLAKE2b-256 3a42c2b788f68fa3503c8e56f7870cfb85ca3ec44774b72dc065a2832eb747fe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page