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

From Source

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

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

System Requirements

  • Rust 1.70+ (for building from source)
  • Internet connection (for vulnerability database updates)

Quick Start

Basic Usage

# Audit current directory
pysentry

# Audit specific project
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

# Comprehensive audit with all dependency types
pysentry --dev --optional --format sarif --output security-report.sarif

# Check only direct dependencies using OSV database
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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

pysentry_rs-0.1.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

pysentry_rs-0.1.3-cp312-cp312-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pysentry_rs-0.1.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

pysentry_rs-0.1.3-cp311-cp311-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pysentry_rs-0.1.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

pysentry_rs-0.1.3-cp310-cp310-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pysentry_rs-0.1.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

pysentry_rs-0.1.3-cp39-cp39-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

pysentry_rs-0.1.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

pysentry_rs-0.1.3-cp38-cp38-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for pysentry_rs-0.1.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 109a260d99349136e80a38eaf5202fb730da4e9b3fe8f7250a0d414716267a40
MD5 068a93aadbf06ab9ddec2e609ad1aba9
BLAKE2b-256 74f7684736e20a8e588de01580092ed906e21a053e51cf86a53974c1231a40bb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysentry_rs-0.1.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9aa1b435cd326f8925426d6a2608287879623b90b5505b2168e0cfd9ba6b1d14
MD5 b161efb96d7b93c580ccacd02579deb5
BLAKE2b-256 d33e69d3920d9641f3f113c5cc8bd857f453aa1e9f8527f69e24b83fe3fc0561

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysentry_rs-0.1.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a96e601fcca721f265f881c22f8027ff8d8f27fc52efb9e71959cb8d22a0b578
MD5 10d62de504f5b82873d9a6677b7332d4
BLAKE2b-256 29be58af7e748d1c9e4f7b01c38a88cea45eb6930721a87507f3ce3175d79d8d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysentry_rs-0.1.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f7a1dc0f2496ba39ac63951138dca0889da30328fc00894d7798ea02614df1db
MD5 60132a8c0ef828b461697393e802fb6b
BLAKE2b-256 7a2331a22237bcb0b4f15d3a27ad421695dff4b9f3947d859d36b0f6bc998f0a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysentry_rs-0.1.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b3cf2143c36a93cc7885bd680dcc6f723b807aef3b12b165b2af7e071a16acc2
MD5 0091456f8b94f9d46e2266144dc2b5da
BLAKE2b-256 b094dd41abc1efaa8269fee712354464c7129ced2afde2458348ffce351eea8f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysentry_rs-0.1.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6193560820d3ca63c8170b5365b8be78d3422e075bd0067ba209b916cec80c50
MD5 89692f00b41ff514557c7301816548be
BLAKE2b-256 33d624f5804ac879b22ac942088d30d5b59137a2ee9efb15b30aa18318cb82d2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysentry_rs-0.1.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 90bb4d1f25f11ca07f78dc72822fe5ef2ecb2d36b5bdb1dc57ba496ade90ca18
MD5 2cf43e01479665484b733e50d39f6f70
BLAKE2b-256 d0b3d02826ddef71d1d2ab33d0da4085e7d4dd09d4599426c86b2e6e09ead6c2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysentry_rs-0.1.3-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8569d55dad4b18a3cfce37ed8797990e5be3cbf99b1ce4e1b5052bc25f4a0f0a
MD5 f124164a686fea90b39ecdf149437fa6
BLAKE2b-256 91893bfdcd463f759fba1b1ae23f2c7c4fd8985dafdb162ef58490cf155f3882

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysentry_rs-0.1.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b324ab0a31c9105e4536e48fa798f425eae24b400f4c095d6ae03ddc72a1cb84
MD5 09b0d286c641063290afbca8de1cd97c
BLAKE2b-256 7c1d6595cee6b932fe676565789bc8b9c2341677f9baedd51487c5a5a9a0c624

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysentry_rs-0.1.3-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 758e6973f1056be2d5bb90d07c306216a71e88df59e5be46eed44bf3f5bb2c1c
MD5 070448ab55a117b50fa48127826f67db
BLAKE2b-256 573456c59d9a5294aeb8428aaa57b4a1aaad1c5cfe05fae19ea209ee637205fb

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