🐍 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) andpyproject.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
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
# Audit specific project
# Include development dependencies
# Filter by severity (only show high and critical)
# Output to JSON file
Advanced Usage
# Comprehensive audit with all dependency types
# Check only direct dependencies using OSV database
# Ignore specific vulnerabilities
# Disable caching for CI environments
# Verbose output for debugging
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:
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
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
Running Tests
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
# Or specify the path explicitly
Error: "Failed to fetch vulnerability data"
# Check network connectivity
# Try with different source
Performance Issues
# Clear cache and retry
# Use verbose mode to identify bottlenecks