Skip to main content

Security scanner for Python dependencies - detects typosquats, CVEs, malicious hooks, unused deps, and metadata anomalies

Project description

PyDepSpy - Python Dependency Security Scanner

PyDepSpy

PyDepSpy is a production-ready CLI tool that scans Python project dependencies for security vulnerabilities and suspicious packages. It runs 5 independent detection engines in parallel across your dependency tree, detecting typosquats, CVEs, malicious install hooks, unused dependencies, and metadata anomalies.

Why PyDepSpy?

5 Detection Engines - Comprehensive scanning:

  • Typosquat Detection: Finds packages similar to popular ones (e.g., requets instead of requests)
  • CVE Scanner: Queries OSV.dev for known vulnerabilities
  • Malicious Hooks: AST-scans setup.py for suspicious install-time code execution
  • Ghost Dependencies: Identifies unused declared dependencies (security surface area)
  • Metadata Auditor: Flags red flags in PyPI metadata (no homepage, brand new packages, suspicious emails)

Parallel Execution - Scans 50 packages in ~3 seconds (not 50 seconds)

Local Caching - Second scan of same project is instant (24-hour TTL on API responses)

Beautiful Output - Rich terminal tables with color-coded severity

Multiple Formats - Terminal, JSON, and SARIF (GitHub Code Scanning)

CI/CD Ready - Exit code 1 on CRITICAL/HIGH findings, composable in pipelines

Installation

pip install pydepspy

Or from source:

git clone https://github.com/tanuj437/pydepspy.git
cd pydepspy
pip install -e .

Quick Start

# Scan current project
pydepspy scan

# Scan a specific directory
pydepspy scan --project /path/to/project

# Output as JSON
pydepspy scan --format json

# Save to file
pydepspy scan --output report.json

# Use SARIF for GitHub Code Scanning
pydepspy scan --format sarif --output results.sarif

Usage

Basic Scan

$ pydepspy scan
🔍 Scanning .
✓ No issues found across 24 packages

With Findings

$ pydepspy scan
🔍 Scanning .

┏━━━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┓
┃ Severity  Package        Type               Message            ┃
┡━━━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━┩
│ CRITICAL  requets        TYPOSQUAT          Possible typosquat │
│ HIGH      django         CVE                CVE-2024-XXXXX     │
│ MEDIUM    unused-pkg     UNUSED             Never imported     │
└──────────┴───────────────┴───────────────────┴────────────────────┘

3 CRITICAL  1 HIGH  1 MEDIUM across 24 packages

Command Line Options

Options:
  --project PATH         Path to Python project [default: current directory]
  --format TEXT          Output format: text, json, sarif [default: text]
  --output FILE          Write output to file instead of stdout
  --cache / --no-cache   Use local cache for API responses [default: cache enabled]
  --help                 Show help message

Exit Codes

  • 0 - No CRITICAL or HIGH findings
  • 1 - One or more CRITICAL or HIGH findings detected
  • Other - Error occurred during scanning

This makes PyDepSpy composable in CI pipelines:

pydepspy scan || exit 1  # Fail the build if issues found

Output Formats

Terminal (Default)

Beautiful, human-readable Rich tables with color-coded severity.

JSON

Structured output for programmatic processing:

{
  "version": "1.0",
  "findings": [
    {
      "package": "malicious-pkg",
      "severity": "CRITICAL",
      "type": "TYPOSQUAT",
      "message": "Possible typosquat of: requests",
      "cve_id": null,
      "fix": null
    }
  ],
  "statistics": {
    "total": 1,
    "by_severity": {"CRITICAL": 1, "HIGH": 0, "MEDIUM": 0, "LOW": 0}
  }
}

SARIF

For GitHub Code Scanning integration:

pydepspy scan --format sarif --output results.sarif

Then upload to GitHub:

gh codeql database upload-results results.sarif --repository=...

Supported Formats

PyDepSpy automatically detects and parses dependencies from:

  • requirements.txt - Standard pip format
  • pyproject.toml - PEP 621 and Poetry format
  • setup.py - Setuptools install_requires
  • Pipfile / Pipfile.lock - Pipenv format

Caching

API responses are cached locally at ~/.pydepspy/cache.db with a 24-hour TTL:

# Use cache (default)
pydepspy scan

# Disable cache
pydepspy scan --no-cache

# Clear cache
rm ~/.pydepspy/cache.db

Second scans of the same project are instant! 🚀

Development

Setup

git clone https://github.com/tanuj437/pydepspy.git
cd pydepspy
pip install -e ".[dev]"

Run Tests

pytest
pytest --cov=pydepspy

Run Linters

black pydepspy tests
ruff check pydepspy tests
mypy pydepspy

Architecture

PyDepSpy uses a modular, detector-based architecture:

  • Parsers - Extract dependencies from various formats
  • Detectors - Independent scanning engines that return standardized Finding objects
  • Aggregator - Deduplicates and scores findings
  • Reporters - Render output in different formats
  • Cache - SQLite-backed with TTL
  • CLI - Click-based entry point

Each detector runs concurrently via asyncio.gather() for maximum performance.

Roadmap

v0.1.0 (Current)

  • ✅ Typosquat detection
  • ✅ CVE scanner
  • ✅ Install hook inspector
  • ✅ Ghost dependency finder
  • ✅ Metadata auditor
  • ✅ Terminal, JSON, SARIF output
  • ✅ Caching

v0.2.0 (Planned)

  • --fix flag for auto-upgrading vulnerable packages
  • GitHub Actions integration
  • More metadata anomaly checks
  • Custom rule support
  • Real-time PyPI monitoring

License

MIT License - see LICENSE file

Contributing

Contributions welcome! Please:

  1. Fork the repo
  2. Create a feature branch (git checkout -b feature/something)
  3. Add tests
  4. Submit a PR

Acknowledgments

Contact


Made with ❤️ for Python security

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

pydepspy-0.1.0.tar.gz (27.5 kB view details)

Uploaded Source

Built Distribution

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

pydepspy-0.1.0-py3-none-any.whl (25.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pydepspy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0d48dd221eb6533aa2be2d3d43bb35ea6a66177c3659b6859b98429a6db303eb
MD5 775987aa2894135f65b546a718d175fa
BLAKE2b-256 5b1d4af62fe661f8108714cc93ec4a42193ee65cbd2e5a7e236754ab495ea3e0

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pydepspy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dc70998ae247679e5fda92ca399a92fc8154d1edf10dd15aa95acf31259b9b3b
MD5 5b28dde3cb1ca8a80b5885f816e72912
BLAKE2b-256 f42e10fe62bd479a3999b2965761ea17b1337440d81e8094a9e3908112666f3e

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