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/Crimson7research/npmscanner.git
cd npmscanner

# 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.2.tar.gz (29.4 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.2-py3-none-any.whl (32.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: npmscanner-0.1.2.tar.gz
  • Upload date:
  • Size: 29.4 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.2.tar.gz
Algorithm Hash digest
SHA256 8c8882a1c9f9e8a8ff4d2586d85fb65a8813baeeb7d433b2c578b77fc70dede1
MD5 ae0b1d26b87dc60eeaec04705794b3a6
BLAKE2b-256 ee8f7f7a7b85d25c4bbaefbdcf535b832ccd2104c945c4549406483665d2a3a0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: npmscanner-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 32.7 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8a5cc9170f2e36fe866e68a3a343840589c54f08a6f7c66a4dfa8cccfc5de3e3
MD5 3ec3d2b4ad44356b23d1a420be519894
BLAKE2b-256 4258a5a499a0af2dae41a22452a38a0a5f894b8c6bc9d608c0cc4882dfe6507f

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