Skip to main content

Scan GitHub repositories for Indicators of Compromise (IOCs) in package dependencies across multiple languages

Project description

GitHub IOC Scanner

A powerful command-line tool for scanning GitHub repositories to detect Indicators of Compromise (IOCs) in package dependencies across multiple programming languages and package managers.

Python 3.8+ License: MIT Security

๐Ÿš€ Features

  • Multi-Language Support: JavaScript/Node.js, Python, Ruby, PHP, Go, Rust
  • Flexible Scanning: Organization-wide, team-specific, or individual repository scanning
  • High Performance: Parallel processing with intelligent batching and caching
  • Real-time Progress: Live progress tracking with ETA calculations
  • Supply Chain Security: Detect compromised packages and typosquatting attacks
  • Comprehensive IOCs: Pre-loaded with 900+ known malicious packages including recent attacks

๐Ÿ“ฆ Supported Package Managers

Language Package Managers Files Scanned
JavaScript/Node.js npm, yarn, pnpm, bun package.json, package-lock.json, yarn.lock, pnpm-lock.yaml, bun.lockb
Python pip, pipenv, poetry requirements.txt, Pipfile.lock, poetry.lock, pyproject.toml
Ruby bundler Gemfile.lock
PHP composer composer.lock
Go go modules go.mod, go.sum
Rust cargo Cargo.lock

๐Ÿ› ๏ธ Installation

From PyPI (Recommended)

pip install github-ioc-scanner

From Source

git clone https://github.com/your-org/github-ioc-scanner.git
cd github-ioc-scanner
pip install -e .

Development Installation

git clone https://github.com/your-org/github-ioc-scanner.git
cd github-ioc-scanner
pip install -e ".[dev]"

โšก Quick Start

1. Set up GitHub Token

export GITHUB_TOKEN="your_github_token_here"

2. Basic Usage

# Scan all repositories in an organization
github-ioc-scan --org your-org

# Scan a specific repository
github-ioc-scan --org your-org --repo your-repo

# Fast scan (root-level files only)
github-ioc-scan --org your-org --fast

๐Ÿ“‹ Usage Examples

Organization Scanning

Scan all repositories in an organization:

github-ioc-scan --org your-org

Team-based Scanning

Scan repositories belonging to a specific team:

github-ioc-scan --org your-org --team security-team

Repository-specific Scanning

Scan a specific repository:

github-ioc-scan --org your-org --repo your-repo

Fast Mode

For quick assessments, use fast mode to scan only root-level files:

github-ioc-scan --org your-org --fast

Include Archived Repositories

By default, archived repositories are skipped. Include them with:

github-ioc-scan --org your-org --include-archived

Batch Processing

For large organizations, use batch processing for optimal performance:

# Aggressive batching strategy
github-ioc-scan --org your-org --batch-strategy aggressive

# Custom concurrency limits
github-ioc-scan --org your-org --max-concurrent 10

# Enable cross-repository batching
github-ioc-scan --org your-org --enable-cross-repo-batching

Verbose Output

Get detailed information during scanning:

github-ioc-scan --org your-org --verbose

๐Ÿ” Current IOC Coverage

The scanner includes comprehensive IOC definitions for:

Recent Supply Chain Attacks

  • S1ngularity/NX Attack (September 2024): 150+ compromised packages with worm payload
  • CrowdStrike Typosquatting Campaign: 400+ malicious packages impersonating CrowdStrike
  • Historical Attacks: Various documented supply chain compromises

Attack Types Detected

  • Typosquatting: Packages with names similar to popular libraries
  • Dependency Confusion: Malicious packages targeting internal dependencies
  • Compromised Packages: Legitimate packages that were later compromised
  • Backdoored Libraries: Libraries with hidden malicious functionality

Total Coverage

  • 900+ IOC Definitions: Comprehensive coverage of known malicious packages
  • Regular Updates: IOC definitions are continuously updated with new threats
  • Multi-language: Coverage across all supported package managers

๐Ÿ“Š Output Formats

Standard Output

๐Ÿ” Scanning organization: your-org
๐Ÿ“ Found 45 repositories to scan
[โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ] 100% | 45/45 repositories | ETA: 0s

โš ๏ธ  THREATS DETECTED:

Repository: your-org/frontend-app
โ”œโ”€โ”€ package.json
โ”‚   โ””โ”€โ”€ ๐Ÿšจ CRITICAL: malicious-package@1.0.0
โ”‚       โ””โ”€โ”€ IOC Source: s1ngularity_nx_attack_2024.py
โ”‚       โ””โ”€โ”€ Description: Compromised package from S1ngularity NX attack

๐Ÿ“ˆ Scan Summary:
โ”œโ”€โ”€ Repositories scanned: 45
โ”œโ”€โ”€ Files analyzed: 127
โ”œโ”€โ”€ Threats found: 1
โ””โ”€โ”€ Scan duration: 23.4s

JSON Output

github-ioc-scan --org your-org --output json

โš™๏ธ Configuration

Environment Variables

Variable Description Default
GITHUB_TOKEN GitHub personal access token Required
GITHUB_IOC_CACHE_DIR Cache directory location ~/.cache/github-ioc-scanner
GITHUB_IOC_LOG_LEVEL Logging level INFO

Configuration File

Create a config.yaml file:

github:
  token: "your_token_here"
  
scanning:
  fast_mode: false
  include_archived: false
  max_concurrent: 5
  
batch:
  strategy: "adaptive"
  enable_cross_repo_batching: true
  
cache:
  enabled: true
  ttl_hours: 24

๐Ÿš€ Performance Features

Intelligent Caching

  • File-level caching: Avoid re-scanning unchanged files
  • ETag support: Efficient GitHub API usage
  • Smart invalidation: Automatic cache updates

Parallel Processing

  • Concurrent requests: Multiple repositories processed simultaneously
  • Batch optimization: Intelligent request batching
  • Rate limit management: Automatic rate limit handling

Progress Tracking

  • Real-time updates: Live progress bars with ETA
  • Detailed metrics: Success rates, processing speeds
  • Performance monitoring: Automatic performance optimization

๐Ÿ›ก๏ธ Security Features

Supply Chain Protection

  • Comprehensive IOC database: 900+ known malicious packages
  • Typosquatting detection: Advanced pattern matching
  • Dependency analysis: Deep dependency tree scanning

Privacy & Security

  • Local processing: All analysis done locally
  • Secure API usage: Proper token handling
  • No data collection: No telemetry or data sharing

๐Ÿ“š Documentation

Comprehensive documentation is available in the docs/ directory:

๐Ÿงช Testing

Run the test suite:

# Run all tests
pytest

# Run with coverage
pytest --cov=src/github_ioc_scanner

# Run specific test categories
pytest tests/test_parsers.py  # Parser tests
pytest tests/test_batch_*.py  # Batch processing tests

๐Ÿค Contributing

We welcome contributions! Please see our Contributing Guidelines for details.

Development Setup

  1. Fork the repository
  2. Create a virtual environment: python -m venv venv
  3. Activate it: source venv/bin/activate (Linux/Mac) or venv\Scripts\activate (Windows)
  4. Install development dependencies: pip install -e ".[dev]"
  5. Run tests: pytest

Adding New IOCs

To add new IOC definitions:

  1. Create or update files in the issues/ directory
  2. Follow the existing format: IOC_PACKAGES = {"package-name": ["version1", "version2"]}
  3. Add documentation about the source and nature of the IOCs
  4. Submit a pull request

๐Ÿ“„ License

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

๐Ÿ”— Links

โš ๏ธ Disclaimer

This tool is provided for security research and defensive purposes only. The IOC definitions are based on publicly available threat intelligence and research. Always verify findings independently and follow responsible disclosure practices.

๐Ÿ™ Acknowledgments

  • Security researchers and organizations who share threat intelligence
  • The open-source community for package manager tools and libraries
  • GitHub for providing comprehensive APIs for repository analysis

Made with โค๏ธ for the security community

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

github_ioc_scanner-1.0.6.tar.gz (312.9 kB view details)

Uploaded Source

Built Distribution

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

github_ioc_scanner-1.0.6-py3-none-any.whl (181.1 kB view details)

Uploaded Python 3

File details

Details for the file github_ioc_scanner-1.0.6.tar.gz.

File metadata

  • Download URL: github_ioc_scanner-1.0.6.tar.gz
  • Upload date:
  • Size: 312.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.17

File hashes

Hashes for github_ioc_scanner-1.0.6.tar.gz
Algorithm Hash digest
SHA256 d5f73d8eac3fffca3cd93c2a75a4a74f6376485591e53da1841eafcaae933676
MD5 21cb9ad4aa28158a23ac3149f350f218
BLAKE2b-256 f1c80bf0bb95047a3fbaf45315c502db57a7e61597dc35a0f37fa2ddee26ffe5

See more details on using hashes here.

File details

Details for the file github_ioc_scanner-1.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for github_ioc_scanner-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 daa90cd2f4638b65d9ce3d790a44295d0628288ac78a987340edbdcccf071a04
MD5 323280adcb92e225c1d93abc0805a4b1
BLAKE2b-256 2be6c76078911b0c8f897edce84eff71e9d7d243b5b2b2c7b08e9371745aa547

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