Skip to main content

Security vulnerability auditing tool for Python packages

Project description

🐍 PySentry

A fast, reliable security vulnerability scanner for Python projects, written in Rust.

Overview

PySentry audits Python projects for known security vulnerabilities by analyzing dependency files (uv.lock, pyproject.toml) and cross-referencing them against multiple vulnerability databases. It provides comprehensive reporting with support for various output formats and filtering options.

Key Features

  • Multiple Project Formats: Supports both uv.lock files (with exact versions) and pyproject.toml files
  • Multiple Data Sources:
    • PyPA Advisory Database (default)
    • PyPI JSON API
    • OSV.dev (Open Source Vulnerabilities)
  • Flexible Output: Human-readable, JSON, and SARIF formats
  • Performance Focused:
    • Written in Rust for speed
    • Async/concurrent processing
    • Intelligent caching system
  • Comprehensive Filtering:
    • Severity levels (low, medium, high, critical)
    • Dependency types (production, development, optional)
    • Direct vs. transitive dependencies
  • Enterprise Ready: SARIF output for IDE/CI integration

Installation

Choose the installation method that works best for you:

⚡ Via uvx (Recommended for occasional use)

Run directly without installing (requires uv):

uvx pysentry-rs /path/to/project

This method:

  • Runs the latest version without installation
  • Automatically manages Python environment
  • Perfect for CI/CD or occasional security audits
  • No need to manage package versions or updates

📦 From PyPI (Python Package)

For Python 3.8+ on Linux and macOS:

pip install pysentry-rs

Then use it with Python:

python -m pysentry /path/to/project
# or directly if scripts are in PATH
pysentry-rs /path/to/project

⚡ From Crates.io (Rust Package)

If you have Rust installed:

cargo install pysentry

💾 From GitHub Releases (Pre-built Binaries)

Download the latest release for your platform:

  • Linux x64: pysentry-linux-x64.tar.gz
  • Linux x64 (musl): pysentry-linux-x64-musl.tar.gz
  • Linux ARM64: pysentry-linux-arm64.tar.gz
  • macOS x64: pysentry-macos-x64.tar.gz
  • macOS ARM64: pysentry-macos-arm64.tar.gz
  • Windows x64: pysentry-windows-x64.zip
# Example for Linux x64
curl -L https://github.com/nyudenkov/pysentry/releases/latest/download/pysentry-linux-x64.tar.gz | tar -xz
./pysentry-linux-x64/pysentry --help

🔧 From Source

git clone https://github.com/nyudenkov/pysentry
cd pysentry
cargo build --release

The binary will be available at target/release/pysentry.

Requirements

  • For uvx: Python 3.8+ and uv installed (Linux/macOS only)
  • For binaries: No additional dependencies
  • For Python package: Python 3.8+ (Linux/macOS only)
  • For Rust package and source: Rust 1.79+

Platform Support

Installation Method Linux macOS Windows
uvx
PyPI (pip)
Crates.io (cargo)
GitHub Releases
From Source

Note: Windows Python wheels are not available due to compilation complexity. Windows users should use the pre-built binary from GitHub releases, install via cargo and build from source.

Quick Start

Basic Usage

# Using uvx (recommended for occasional use)
uvx pysentry-rs
uvx pysentry-rs /path/to/python/project

# Using installed binary
pysentry
pysentry /path/to/python/project

# Include development dependencies
pysentry --dev

# Filter by severity (only show high and critical)
pysentry --severity high

# Output to JSON file
pysentry --format json --output audit-results.json

Advanced Usage

# Using uvx for comprehensive audit
uvx pysentry-rs --dev --optional --format sarif --output security-report.sarif

# Check only direct dependencies using OSV database
uvx pysentry-rs --direct-only --source osv

# Or with installed binary
pysentry --dev --optional --format sarif --output security-report.sarif
pysentry --direct-only --source osv

# Ignore specific vulnerabilities
pysentry --ignore CVE-2023-12345 --ignore GHSA-xxxx-yyyy-zzzz

# Disable caching for CI environments
pysentry --no-cache

# Verbose output for debugging
pysentry --verbose

Configuration

Command Line Options

Option Description Default
--format Output format: human, json, sarif human
--severity Minimum severity: low, medium, high, critical low
--source Vulnerability source: pypa, pypi, osv pypa
--dev Include development dependencies false
--optional Include optional dependencies false
--direct-only Check only direct dependencies false
--ignore Vulnerability IDs to ignore (repeatable) []
--output Output file path stdout
--no-cache Disable caching false
--cache-dir Custom cache directory ~/.cache/pysentry
--verbose Enable verbose output false
--quiet Suppress non-error output false

Cache Management

PySentry uses an intelligent caching system to avoid redundant API calls:

  • Default Location: ~/.cache/pysentry/ (or system temp directory)
  • TTL-based Expiration: Separate expiration for each vulnerability source
  • Atomic Updates: Prevents cache corruption during concurrent access
  • Custom Location: Use --cache-dir to specify alternative location

To clear the cache:

rm -rf ~/.cache/pysentry/

Supported Project Formats

uv.lock Files (Recommended)

PySentry has support for uv.lock files, providing:

  • Exact version resolution
  • Complete dependency graph analysis
  • Source tracking
  • Dependency classification (main, dev, optional) including transitioning dependencies

pyproject.toml Files

Fallback support for projects without lock files:

  • Parses version constraints from pyproject.toml
  • Limited dependency graph information

Vulnerability Data Sources

PyPA Advisory Database (Default)

  • Comprehensive coverage of Python ecosystem
  • Community-maintained vulnerability database
  • Regular updates from security researchers

PyPI JSON API

  • Official PyPI vulnerability data
  • Real-time information
  • Limited to packages hosted on PyPI

OSV.dev

  • Cross-ecosystem vulnerability database
  • Google-maintained infrastructure

Output Formats

Human-Readable (Default)

Most comfortable to read.

JSON

{
  "summary": {
    "total_dependencies": 245,
    "vulnerable_packages": 2,
    "total_vulnerabilities": 3,
    "by_severity": {
      "critical": 1,
      "high": 1,
      "medium": 1,
      "low": 0
    }
  },
  "vulnerabilities": [...]
}

SARIF (Static Analysis Results Interchange Format)

Compatible with GitHub Security tab, VS Code, and other security tools.

Performance

PySentry is designed for speed and efficiency:

  • Concurrent Processing: Vulnerability data fetched in parallel
  • Smart Caching: Reduces API calls and parsing overhead
  • Efficient Matching: In-memory indexing for fast vulnerability lookups
  • Streaming: Large databases processed without excessive memory usage

Benchmarks

Typical performance on a project with 100+ dependencies:

  • Cold cache: 15-30 seconds
  • Warm cache: 2-5 seconds
  • Memory usage: ~50MB peak

Development

Building from Source

git clone https://github.com/nyudenkov/pysentry
cd pysentry
cargo build --release

Running Tests

cargo test

Project Structure

src/
├── main.rs           # CLI interface
├── lib.rs            # Library API
├── cache/            # Caching system
├── dependency/       # Dependency scanning
├── output/           # Report generation
├── parsers/          # Project file parsers
├── providers/        # Vulnerability data sources
├── types.rs          # Core type definitions
└── vulnerability/    # Vulnerability matching

Troubleshooting

Common Issues

Error: "No lock file or pyproject.toml found"

# Ensure you're in a Python project directory
ls pyproject.toml uv.lock

# Or specify the path explicitly
pysentry /path/to/python/project

Error: "Failed to fetch vulnerability data"

# Check network connectivity
curl -I https://osv-vulnerabilities.storage.googleapis.com/

# Try with different source
pysentry --source pypi

Performance Issues

# Clear cache and retry
rm -rf ~/.cache/pysentry
pysentry

# Use verbose mode to identify bottlenecks
pysentry --verbose

Acknowledgments

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

pysentry_rs-0.1.4.tar.gz (93.3 kB view details)

Uploaded Source

Built Distributions

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

pysentry_rs-0.1.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

pysentry_rs-0.1.4-cp313-cp313-macosx_11_0_arm64.whl (2.6 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pysentry_rs-0.1.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

pysentry_rs-0.1.4-cp312-cp312-macosx_11_0_arm64.whl (2.6 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pysentry_rs-0.1.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

pysentry_rs-0.1.4-cp311-cp311-macosx_11_0_arm64.whl (2.6 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pysentry_rs-0.1.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

pysentry_rs-0.1.4-cp310-cp310-macosx_11_0_arm64.whl (2.6 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pysentry_rs-0.1.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

pysentry_rs-0.1.4-cp39-cp39-macosx_11_0_arm64.whl (2.6 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

pysentry_rs-0.1.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

pysentry_rs-0.1.4-cp38-cp38-macosx_11_0_arm64.whl (2.6 MB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

File details

Details for the file pysentry_rs-0.1.4.tar.gz.

File metadata

  • Download URL: pysentry_rs-0.1.4.tar.gz
  • Upload date:
  • Size: 93.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for pysentry_rs-0.1.4.tar.gz
Algorithm Hash digest
SHA256 7eb7b11ccc986bb41e3a3180f2851e7aa3f75cc6d7a6e6cc9cbe45b564555f5f
MD5 d4ff8eadcda0c15ae7f8689c88fed1f9
BLAKE2b-256 93b75d6298db9d4a97b24f1f62e574520205b8d80bc536db925b953b0ff54ca3

See more details on using hashes here.

File details

Details for the file pysentry_rs-0.1.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pysentry_rs-0.1.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 278694fbd6dd5199ea7585dcd59368488edadf92e535c4622044bbaba9ba7324
MD5 9369278d1ebe67f1637fcf915b4437e8
BLAKE2b-256 2bfa68e688f852df9f23f1292a39f6c4348ea3f970dcce1f2e353a3a280bf48f

See more details on using hashes here.

File details

Details for the file pysentry_rs-0.1.4-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pysentry_rs-0.1.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e18ed5fc709eed85ce155b7e40b3eaae797e518aa5d70b9a8ea5793e2a906458
MD5 a17b0cb4257c7c4ba4c66036b540de02
BLAKE2b-256 1cc67472c3c59977d1b4a8a8190481c958837b397b802b66204d30838921c385

See more details on using hashes here.

File details

Details for the file pysentry_rs-0.1.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pysentry_rs-0.1.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 979275501780cfccb0c84f94f4f0687737e6ccefbce99767247a02d71f18d470
MD5 29a15c637c0c0a0e5db7915b9de81504
BLAKE2b-256 b97e537d87e82def1b3674e0a675f32cbd2de27727f19862455932a2e093c95b

See more details on using hashes here.

File details

Details for the file pysentry_rs-0.1.4-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pysentry_rs-0.1.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4d7a2ee35214529cf638e80adde1cac40783b7be35a4b7a518c22582e918e36c
MD5 2930d773cc8a45375258e16393c5ab27
BLAKE2b-256 57ae9736c2f5a6f0f0076d71141e2007a48459c90a855f3f5e8cf766b8bc3b64

See more details on using hashes here.

File details

Details for the file pysentry_rs-0.1.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pysentry_rs-0.1.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a2149277af3584a77f03dfce8173d53ec1daa5bf181ad3a7537f0cd0f17304e7
MD5 744f16a02e53face67552bcf6c4d4c21
BLAKE2b-256 c39a2be63cea518e76162d03e2c7c0a56ced678c1eac71dc272a19f923039723

See more details on using hashes here.

File details

Details for the file pysentry_rs-0.1.4-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pysentry_rs-0.1.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4d7f56a4316feef4477b946ac50fba0d0ef9ca592d69e46e7adbd568a1ceb2cf
MD5 b70ddb3adc52242c769fb8cb8ad4ebdc
BLAKE2b-256 8f189a25395e2617d0e04b9a6302954f3f620a3158483ffef6472e683b91cc77

See more details on using hashes here.

File details

Details for the file pysentry_rs-0.1.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pysentry_rs-0.1.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6c4665cdbd19128c0c3b50763d6c3352c2831b17894e4321ddb29a103a7f85c6
MD5 0031e9b4267cc6b4ea47d9251db9886f
BLAKE2b-256 8c07ef9372d94f83814c8edfbfe5e9ba337508bcb949f37b8b5a5da5723590d7

See more details on using hashes here.

File details

Details for the file pysentry_rs-0.1.4-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pysentry_rs-0.1.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c1acf561543d9059365e9ec00a6bde3641994ef0c4186e2cdc6bab82e0bc1abd
MD5 c3f68f8b6a914159ff09a373795f7f58
BLAKE2b-256 85018bd5eaee13db68ca717acc3f375b844f5fc912fc543a7ddf69575b9f46d3

See more details on using hashes here.

File details

Details for the file pysentry_rs-0.1.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pysentry_rs-0.1.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fb0e63f3be5dd74f591f47d5f744d120ee126259163d8523914f5f6209be1d8f
MD5 94756d760bca9d1ea45437950b2bb21b
BLAKE2b-256 0f9b936739a3167a4443f554cbfefc66430f3764a0f0ef809fae0f3cfc40151a

See more details on using hashes here.

File details

Details for the file pysentry_rs-0.1.4-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pysentry_rs-0.1.4-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f20840371e1ec8abcbce46b904ad51592e5b4ec90ddea17de4a44a9fd54cc343
MD5 cfdd8070df926485a87afa5f855168b1
BLAKE2b-256 ec1673d02051b09f3931ffa6fc72a7fc3e75fc33f86ee05086751719cb31297e

See more details on using hashes here.

File details

Details for the file pysentry_rs-0.1.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pysentry_rs-0.1.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5e836bbebceda056435fd44afe081792e1437922c1a7d924d5de2e9d073d6d87
MD5 aea6a0fa61588521f126a683bbece2d2
BLAKE2b-256 8d44bb6a0ebf630e8b39902b560e0932b5660b8099d2f58468e667d244de7fb7

See more details on using hashes here.

File details

Details for the file pysentry_rs-0.1.4-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pysentry_rs-0.1.4-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 478938e0934e6e53ff658422d2f3abe1e123e9b9e0e680d2fec43cd39c1ef4ec
MD5 0b27efbaeef859dcf6205f28c94fe4d4
BLAKE2b-256 7eb7c865fa5bccdd23a403cc94ddd50ebc69b00f6ea0fa4d185ec3170e179a17

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