pysentry-rs 0.3.10__cp313-cp313-macosx_10_12_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pysentry-rs might be problematic. Click here for more details.

@@ -0,0 +1,828 @@
1
+ Metadata-Version: 2.4
2
+ Name: pysentry-rs
3
+ Version: 0.3.10
4
+ Classifier: Development Status :: 4 - Beta
5
+ Classifier: Intended Audience :: Developers
6
+ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
7
+ Classifier: Programming Language :: Rust
8
+ Classifier: Programming Language :: Python :: Implementation :: CPython
9
+ Classifier: Programming Language :: Python :: 3.9
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Topic :: Security
15
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
+ License-File: LICENSE
17
+ Summary: Security vulnerability auditing tool for Python packages
18
+ Author-email: nyudenkov <nyudenkov@pm.me>
19
+ License: GPL-3.0
20
+ Requires-Python: >=3.9
21
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
22
+ Project-URL: Homepage, https://github.com/nyudenkov/pysentry
23
+ Project-URL: Repository, https://github.com/nyudenkov/pysentry
24
+ Project-URL: Issues, https://github.com/nyudenkov/pysentry/issues
25
+
26
+ # 🐍 PySentry
27
+
28
+ [![OSV Integration](https://img.shields.io/badge/OSV-Integrated-blue)](https://google.github.io/osv.dev/)
29
+ [![PyPI Downloads](https://static.pepy.tech/badge/pysentry-rs/week)](https://pepy.tech/projects/pysentry-rs)
30
+
31
+ [Help to test and improve](https://github.com/nyudenkov/pysentry/issues/12) | [Latest PySentry - pip-audit benchmark](benchmarks/results/latest.md)
32
+
33
+ Please, send feedback to nikita@pysentry.com
34
+
35
+ A fast, reliable security vulnerability scanner for Python projects, written in Rust.
36
+
37
+ ## Overview
38
+
39
+ PySentry audits Python projects for known security vulnerabilities by analyzing dependency files (`uv.lock`, `poetry.lock`, `Pipfile.lock`, `pylock.toml`, `pyproject.toml`, `Pipfile`, `requirements.txt`) and cross-referencing them against multiple vulnerability databases. It provides comprehensive reporting with support for various output formats and filtering options.
40
+
41
+ ## Key Features
42
+
43
+ - **Multiple Project Formats**: Supports `uv.lock`, `poetry.lock`, `Pipfile.lock`, `pylock.toml`, `pyproject.toml`, `Pipfile`, and `requirements.txt` files
44
+ - **External Resolver Integration**: Leverages `uv` and `pip-tools` for accurate requirements.txt constraint solving
45
+ - **Multiple Data Sources**:
46
+ - PyPA Advisory Database (default)
47
+ - PyPI JSON API
48
+ - OSV.dev (Open Source Vulnerabilities)
49
+ - **Flexible Output for different workflows**: Human-readable, JSON, SARIF, and Markdown formats
50
+ - **Performance Focused**:
51
+ - Written in Rust for speed
52
+ - Async/concurrent processing
53
+ - Multi-tier intelligent caching (vulnerability data + resolved dependencies)
54
+ - **Comprehensive Filtering**:
55
+ - Severity levels (low, medium, high, critical)
56
+ - Dependency scopes (main only vs all [optional, dev, prod, etc] dependencies)
57
+ - Direct vs. transitive dependencies
58
+ - **Enterprise Ready**: SARIF output for IDE/CI integration
59
+
60
+ ## Installation
61
+
62
+ Choose the installation method that works best for you:
63
+
64
+ ### ⚡ Via uvx (Recommended for occasional use)
65
+
66
+ Run directly without installing (requires [uv](https://docs.astral.sh/uv/)):
67
+
68
+ ```bash
69
+ uvx pysentry-rs /path/to/project
70
+ ```
71
+
72
+ This method:
73
+
74
+ - Runs the latest version without installation
75
+ - Automatically manages Python environment
76
+ - Perfect for CI/CD or occasional security audits
77
+ - No need to manage package versions or updates
78
+
79
+ ### 📦 From PyPI (Python Package)
80
+
81
+ For Python 3.9+ on Linux, macOS, and Windows:
82
+
83
+ ```bash
84
+ pip install pysentry-rs
85
+ ```
86
+
87
+ Then use it with Python:
88
+
89
+ ```bash
90
+ python -m pysentry /path/to/project
91
+ # or directly if scripts are in PATH
92
+ pysentry-rs /path/to/project
93
+ ```
94
+
95
+ ### ⚡ From Crates.io (Rust Package)
96
+
97
+ If you have Rust installed:
98
+
99
+ ```bash
100
+ cargo install pysentry
101
+ ```
102
+
103
+ ### 💾 From GitHub Releases (Pre-built Binaries)
104
+
105
+ Download the latest release for your platform:
106
+
107
+ - **Linux x64**: `pysentry-linux-x64.tar.gz`
108
+ - **Linux x64 (musl)**: `pysentry-linux-x64-musl.tar.gz`
109
+ - **Linux ARM64**: `pysentry-linux-arm64.tar.gz`
110
+ - **macOS x64**: `pysentry-macos-x64.tar.gz`
111
+ - **macOS ARM64**: `pysentry-macos-arm64.tar.gz`
112
+ - **Windows x64**: `pysentry-windows-x64.zip`
113
+
114
+ ```bash
115
+ # Example for Linux x64
116
+ curl -L https://github.com/nyudenkov/pysentry/releases/latest/download/pysentry-linux-x64.tar.gz | tar -xz
117
+ ./pysentry-linux-x64/pysentry --help
118
+ ```
119
+
120
+ ### 🔧 From Source
121
+
122
+ ```bash
123
+ git clone https://github.com/nyudenkov/pysentry
124
+ cd pysentry
125
+ cargo build --release
126
+ ```
127
+
128
+ The binary will be available at `target/release/pysentry`.
129
+
130
+ ### Requirements
131
+
132
+ - **For uvx**: Python 3.9+ and [uv](https://docs.astral.sh/uv/) installed
133
+ - **For binaries**: No additional dependencies
134
+ - **For Python package**: Python 3.9+
135
+ - **For Rust package and source**: Rust 1.79+
136
+
137
+ ### Platform Support
138
+
139
+ | Installation Method | Linux | macOS | Windows |
140
+ | ------------------- | ----- | ----- | ------- |
141
+ | uvx | ✅ | ✅ | ✅ |
142
+ | PyPI (pip) | ✅ | ✅ | ✅ |
143
+ | Crates.io (cargo) | ✅ | ✅ | ✅ |
144
+ | GitHub Releases | ✅ | ✅ | ✅ |
145
+ | From Source | ✅ | ✅ | ✅ |
146
+
147
+
148
+ ### CLI Command Names
149
+
150
+ - **Rust binary**: `pysentry` (when installed via cargo or binary releases)
151
+ - **Python package**: `pysentry-rs` (when installed via pip or uvx)
152
+
153
+ Both variants support identical functionality. The resolver tools (`uv`, `pip-tools`) must be available in your current environment regardless of which PySentry variant you use.
154
+
155
+ ### Requirements.txt Support Prerequisites
156
+
157
+ To scan `requirements.txt` files, PySentry requires an external dependency resolver to convert version constraints (e.g., `flask>=2.0,<3.0`) into exact versions for vulnerability scanning.
158
+
159
+ **Install a supported resolver:**
160
+
161
+ ```bash
162
+ # uv (recommended - fastest, Rust-based)
163
+ pip install uv
164
+
165
+ # pip-tools (widely compatible, Python-based)
166
+ pip install pip-tools
167
+ ```
168
+
169
+ **Environment Requirements:**
170
+
171
+ - Resolvers must be available in your current environment
172
+ - If using virtual environments, activate your venv before running PySentry:
173
+ ```bash
174
+ source venv/bin/activate # Linux/macOS
175
+ venv\Scripts\activate # Windows
176
+ pysentry /path/to/project
177
+ ```
178
+ - Alternatively, install resolvers globally for system-wide availability
179
+
180
+ **Auto-detection:** PySentry automatically detects and prefers: `uv` > `pip-tools`. Without a resolver, only `uv.lock` and `poetry.lock` files can be scanned.
181
+
182
+ ## Quick Start
183
+
184
+ ### Basic Usage
185
+
186
+ ```bash
187
+ # Using uvx (recommended for occasional use)
188
+ uvx pysentry-rs
189
+ uvx pysentry-rs /path/to/python/project
190
+
191
+ # Using installed binary
192
+ pysentry
193
+ pysentry /path/to/python/project
194
+
195
+ # Automatically detects project type (uv.lock, poetry.lock, Pipfile.lock, pyproject.toml, Pipfile, requirements.txt)
196
+ pysentry /path/to/project
197
+
198
+ # Force specific resolver
199
+ pysentry --resolver uv /path/to/project
200
+ pysentry --resolver pip-tools /path/to/project
201
+
202
+ # Include all dependencies (main + dev + optional)
203
+ pysentry --all-extras
204
+
205
+ # Filter by severity (only show high and critical)
206
+ pysentry --severity high
207
+
208
+ # Output to JSON file
209
+ pysentry --format json --output audit-results.json
210
+ ```
211
+
212
+ ### Advanced Usage
213
+
214
+ ```bash
215
+ # Using uvx for comprehensive audit
216
+ uvx pysentry-rs --all-extras --format sarif --output security-report.sarif
217
+
218
+ # Check multiple vulnerability sources concurrently
219
+ uvx pysentry-rs --sources pypa,osv,pypi /path/to/project
220
+ uvx pysentry-rs --sources pypa --sources osv --sources pypi
221
+
222
+ # Generate markdown report
223
+ uvx pysentry-rs --format markdown --output security-report.md
224
+
225
+ # Control CI exit codes - only fail on critical vulnerabilities
226
+ uvx pysentry-rs --fail-on critical
227
+
228
+ # Or with installed binary
229
+ pysentry --all-extras --format sarif --output security-report.sarif
230
+ pysentry --sources pypa,osv --direct-only
231
+ pysentry --format markdown --output security-report.md
232
+
233
+ # Ignore specific vulnerabilities
234
+ pysentry --ignore CVE-2023-12345 --ignore GHSA-xxxx-yyyy-zzzz
235
+
236
+ # Disable caching for CI environments
237
+ pysentry --no-cache
238
+
239
+ # Verbose output for debugging
240
+ pysentry --verbose
241
+ ```
242
+
243
+ ### Advanced Requirements.txt Usage
244
+
245
+ ```bash
246
+ # Scan multiple requirements files
247
+ pysentry --requirements requirements.txt --requirements requirements-dev.txt
248
+
249
+ # Check only direct dependencies from requirements.txt
250
+ pysentry --direct-only --resolver uv
251
+
252
+ # Ensure resolver is available in your environment
253
+ source venv/bin/activate # Activate your virtual environment first
254
+ pysentry /path/to/project
255
+
256
+ # Debug requirements.txt resolution
257
+ pysentry --verbose --resolver uv /path/to/project
258
+
259
+ # Use longer resolution cache TTL (48 hours)
260
+ pysentry --resolution-cache-ttl 48 /path/to/project
261
+
262
+ # Clear resolution cache before scanning
263
+ pysentry --clear-resolution-cache /path/to/project
264
+ ```
265
+
266
+ ### CI/CD Integration Examples
267
+
268
+ ```bash
269
+ # Development environment - only fail on critical vulnerabilities
270
+ pysentry --fail-on critical --format json --output security-report.json
271
+
272
+ # Staging environment - fail on high+ vulnerabilities
273
+ pysentry --fail-on high --sources pypa,osv --format sarif --output security.sarif
274
+
275
+ # Production deployment - strict security (fail on medium+, default)
276
+ pysentry --sources pypa,pypi,osv --format json --output prod-security.json
277
+
278
+ # Generate markdown report for GitHub issues/PRs
279
+ pysentry --format markdown --output SECURITY-REPORT.md
280
+
281
+ # Comprehensive audit with all sources and full reporting
282
+ pysentry --sources pypa,pypi,osv --all-extras --format json --fail-on low
283
+
284
+ # CI environment with fresh resolution cache
285
+ pysentry --clear-resolution-cache --sources pypa,osv --format sarif
286
+
287
+ # CI with resolution cache disabled
288
+ pysentry --no-resolution-cache --format json --output security-report.json
289
+ ```
290
+
291
+ ## Pre-commit Integration
292
+
293
+ PySentry integrates seamlessly with [pre-commit](https://pre-commit.com/) to automatically scan for vulnerabilities before commits.
294
+
295
+ ### Setup
296
+
297
+ Add PySentry to your `.pre-commit-config.yaml`:
298
+
299
+ ```yaml
300
+ repos:
301
+ - repo: https://github.com/pysentry/pysentry-pre-commit
302
+ rev: v0.3.7
303
+ hooks:
304
+ - id: pysentry # default pysentry settings
305
+ ```
306
+
307
+ ### Advanced Configuration
308
+
309
+ ```yaml
310
+ repos:
311
+ - repo: https://github.com/pysentry/pysentry-pre-commit
312
+ rev: v0.3.7
313
+ hooks:
314
+ - id: pysentry
315
+ args: ["--sources", "pypa,osv", "--fail-on", "high"]
316
+ ```
317
+
318
+ ### Installation Requirements
319
+
320
+ Pre-commit will automatically install PySentry, uv and pip-tools via PyPI.
321
+
322
+ ## Configuration
323
+
324
+ PySentry supports TOML-based configuration files for persistent settings management. Configuration files follow a hierarchical discovery pattern:
325
+
326
+ 1. **Project-level**: `.pysentry.toml` in current or parent directories
327
+ 2. **User-level**: `~/.config/pysentry/config.toml` (Linux/macOS)
328
+ 3. **System-level**: `/etc/pysentry/config.toml` (Unix systems)
329
+
330
+ ### Configuration File Example
331
+
332
+ ```toml
333
+ version = 1
334
+
335
+ [defaults]
336
+ format = "json"
337
+ severity = "medium"
338
+ fail_on = "high"
339
+ scope = "all"
340
+ direct_only = false
341
+
342
+ [sources]
343
+ enabled = ["pypa", "osv"]
344
+
345
+ [resolver]
346
+ type = "uv"
347
+ fallback = "pip-tools"
348
+
349
+ [cache]
350
+ enabled = true
351
+ resolution_ttl = 48
352
+ vulnerability_ttl = 72
353
+
354
+ [output]
355
+ quiet = false
356
+ verbose = false
357
+ color = "auto"
358
+
359
+ [ignore]
360
+ ids = ["CVE-2023-12345", "GHSA-xxxx-yyyy-zzzz"]
361
+ ```
362
+
363
+ ### Environment Variables
364
+
365
+ | Variable | Description | Example |
366
+ | -------------------- | ------------------------------- | -------------------------------------- |
367
+ | `PYSENTRY_CONFIG` | Override config file path | `PYSENTRY_CONFIG=/path/to/config.toml` |
368
+ | `PYSENTRY_NO_CONFIG` | Disable all config file loading | `PYSENTRY_NO_CONFIG=1` |
369
+
370
+ ### Command Line Options
371
+
372
+ | Option | Description | Default |
373
+ | -------------------------- | --------------------------------------------------------- | ----------------- |
374
+ | `--format` | Output format: `human`, `json`, `sarif`, `markdown` | `human` |
375
+ | `--severity` | Minimum severity: `low`, `medium`, `high`, `critical` | `low` |
376
+ | `--fail-on` | Fail (exit non-zero) on vulnerabilities ≥ severity | `medium` |
377
+ | `--sources` | Vulnerability sources: `pypa`, `pypi`, `osv` (multiple) | `pypa` |
378
+ | `--all-extras` | Include all dependencies (main + dev + optional) | `false` |
379
+ | `--direct-only` | Check only direct dependencies | `false` |
380
+ | `--detailed` | Show full vulnerability descriptions instead of truncated | `false` |
381
+ | `--ignore` | Vulnerability IDs to ignore (repeatable) | `[]` |
382
+ | `--output` | Output file path | `stdout` |
383
+ | `--no-cache` | Disable all caching | `false` |
384
+ | `--cache-dir` | Custom cache directory | Platform-specific |
385
+ | `--resolution-cache-ttl` | Resolution cache TTL in hours | `24` |
386
+ | `--no-resolution-cache` | Disable resolution caching only | `false` |
387
+ | `--clear-resolution-cache` | Clear resolution cache on startup | `false` |
388
+ | `--verbose` | Enable verbose output | `false` |
389
+ | `--quiet` | Suppress non-error output | `false` |
390
+ | `--resolver` | Dependency resolver: `auto`, `uv`, `pip-tools` | `auto` |
391
+ | `--requirements` | Additional requirements files (repeatable) | `[]` |
392
+
393
+ ### Cache Management
394
+
395
+ PySentry uses an intelligent multi-tier caching system for optimal performance:
396
+
397
+ #### Vulnerability Data Cache
398
+
399
+ - **Location**: `{CACHE_DIR}/pysentry/vulnerability-db/`
400
+ - **Purpose**: Caches vulnerability databases from PyPA, PyPI, OSV
401
+ - **TTL**: 24 hours (configurable per source)
402
+ - **Benefits**: Avoids redundant API calls and downloads
403
+
404
+ #### Resolution Cache
405
+
406
+ - **Location**: `{CACHE_DIR}/pysentry/dependency-resolution/`
407
+ - **Purpose**: Caches resolved dependencies from `uv`/`pip-tools`
408
+ - **TTL**: 24 hours (configurable via `--resolution-cache-ttl`)
409
+ - **Benefits**: Dramatically speeds up repeated scans of requirements.txt files
410
+ - **Cache Key**: Based on requirements content, resolver version, Python version, platform
411
+
412
+ #### Platform-Specific Cache Locations
413
+
414
+ - **Linux**: `~/.cache/pysentry/`
415
+ - **macOS**: `~/Library/Caches/pysentry/`
416
+ - **Windows**: `%LOCALAPPDATA%\pysentry\`
417
+
418
+ **Finding Your Cache Location**: Run with `--verbose` to see the actual cache directory path being used.
419
+
420
+ #### Cache Features
421
+
422
+ - **Atomic Updates**: Prevents cache corruption during concurrent access
423
+ - **Custom Location**: Use `--cache-dir` to specify alternative location
424
+ - **Selective Clearing**: Control caching behavior per cache type
425
+ - **Content-based Invalidation**: Automatic cache invalidation on content changes
426
+
427
+ #### Cache Control Examples
428
+
429
+ ```bash
430
+ # Disable all caching
431
+ pysentry --no-cache
432
+
433
+ # Disable only resolution caching (keep vulnerability cache)
434
+ pysentry --no-resolution-cache
435
+
436
+ # Set resolution cache TTL to 48 hours
437
+ pysentry --resolution-cache-ttl 48
438
+
439
+ # Clear resolution cache on startup (useful for CI)
440
+ pysentry --clear-resolution-cache
441
+
442
+ # Custom cache directory
443
+ pysentry --cache-dir /tmp/my-pysentry-cache
444
+ ```
445
+
446
+ To manually clear all caches:
447
+
448
+ ```bash
449
+ # Linux
450
+ rm -rf ~/.cache/pysentry/
451
+
452
+ # macOS
453
+ rm -rf ~/Library/Caches/pysentry/
454
+
455
+ # Windows (PowerShell)
456
+ Remove-Item -Recurse -Force "$env:LOCALAPPDATA\pysentry"
457
+ ```
458
+
459
+ To clear only resolution cache:
460
+
461
+ ```bash
462
+ # Linux
463
+ rm -rf ~/.cache/pysentry/dependency-resolution/
464
+
465
+ # macOS
466
+ rm -rf ~/Library/Caches/pysentry/dependency-resolution/
467
+
468
+ # Windows (PowerShell)
469
+ Remove-Item -Recurse -Force "$env:LOCALAPPDATA\pysentry\dependency-resolution"
470
+ ```
471
+
472
+ ## Supported Project Formats
473
+
474
+ ### uv.lock Files (Recommended)
475
+
476
+ PySentry has support for `uv.lock` files:
477
+
478
+ - Exact version resolution
479
+ - Complete dependency graph analysis
480
+ - Source tracking
481
+ - Dependency classification (main, dev, optional) including transitive dependencies
482
+
483
+ ### poetry.lock Files
484
+
485
+ Full support for Poetry lock files:
486
+
487
+ - **Exact Version Resolution**: Scans exact dependency versions locked by Poetry
488
+ - **Lock-File Only Analysis**: Relies purely on the lock file structure, no pyproject.toml parsing needed
489
+ - **Complete Dependency Tree**: Analyzes all resolved dependencies including transitive ones
490
+ - **Dependency Classification**: Distinguishes between main dependencies and optional groups (dev, test, etc.)
491
+ - **Source Tracking**: Supports PyPI registry, Git repositories, local paths, and direct URLs
492
+
493
+ **Key Features:**
494
+
495
+ - No external tools required
496
+ - Fast parsing with exact version information
497
+ - Handles Poetry's dependency groups and optional dependencies
498
+ - Perfect for Poetry-managed projects with established lock files
499
+
500
+ ### Pipfile.lock Files
501
+
502
+ Full support for Pipenv lock files with exact version resolution:
503
+
504
+ - **Exact Version Resolution**: Scans exact dependency versions locked by Pipenv
505
+ - **Lock-File Only Analysis**: Relies purely on the lock file structure, no Pipfile parsing needed
506
+ - **Complete Dependency Tree**: Analyzes all resolved dependencies including transitive ones
507
+ - **Dependency Classification**: Distinguishes between default dependencies and development groups
508
+
509
+ **Key Features:**
510
+
511
+ - No external tools required
512
+ - Fast parsing with exact version information
513
+ - Handles Pipenv's dependency groups (default and develop)
514
+ - Perfect for Pipenv-managed projects with established lock files
515
+
516
+ ### Pipfile Files (External Resolution)
517
+
518
+ Support for Pipfile specification files using external dependency resolvers:
519
+
520
+ **Key Features:**
521
+
522
+ - **Dependencies Resolution**: Converts version constraints from Pipfile to exact versions using mature external tools
523
+ - **Multiple Resolver Support**:
524
+ - **uv**: Rust-based resolver, extremely fast and reliable (recommended)
525
+ - **pip-tools**: Python-based resolver using `pip-compile`, widely compatible
526
+ - **Auto-detection**: Automatically detects and uses the best available resolver in your environment
527
+ - **Dependency Groups**: Supports both default packages and dev-packages sections
528
+ - **Complex Constraint Handling**: Supports version ranges, Git dependencies, and environment markers
529
+
530
+ **Resolution Workflow:**
531
+
532
+ 1. Detects `Pipfile` in your project (when `Pipfile.lock` is not present)
533
+ 2. Auto-detects available resolver (`uv` or `pip-tools`) in current environment
534
+ 3. Resolves version constraints to exact dependency versions
535
+ 4. Scans resolved dependencies for vulnerabilities
536
+ 5. Reports findings with dependency group classification
537
+
538
+ **Note**: When both `Pipfile` and `Pipfile.lock` are present, PySentry prioritizes the lock file for better accuracy. Consider using `pipenv lock` to generate a lock file for the most precise vulnerability scanning.
539
+
540
+ ### requirements.txt Files (External Resolution)
541
+
542
+ Advanced support for `requirements.txt` files using external dependency resolvers:
543
+
544
+ **Key Features:**
545
+
546
+ - **Dependencies Resolution**: Converts version constraints (e.g., `flask>=2.0,<3.0`) to exact versions using mature external tools
547
+ - **Multiple Resolver Support**:
548
+ - **uv**: Rust-based resolver, extremely fast and reliable (recommended)
549
+ - **pip-tools**: Python-based resolver using `pip-compile`, widely compatible
550
+ - **Auto-detection**: Automatically detects and uses the best available resolver in your environment
551
+ - **Multiple File Support**: Combines `requirements.txt`, `requirements-dev.txt`, `requirements-test.txt`, etc.
552
+ - **Dependency Classification**: Distinguishes between direct and transitive dependencies
553
+ - **Isolated Execution**: Resolvers run in temporary directories to prevent project pollution
554
+ - **Complex Constraint Handling**: Supports version ranges, extras, environment markers, and conflict resolution
555
+
556
+ **Resolution Workflow:**
557
+
558
+ 1. Detects `requirements.txt` files in your project
559
+ 2. Auto-detects available resolver (`uv` or `pip-tools`) in current environment
560
+ 3. Resolves version constraints to exact dependency versions
561
+ 4. Scans resolved dependencies for vulnerabilities
562
+ 5. Reports findings with direct vs. transitive classification
563
+
564
+ **Environment Setup:**
565
+
566
+ ```bash
567
+ # Ensure resolver is available in your environment
568
+ source venv/bin/activate # Activate virtual environment
569
+ pip install uv # Install preferred resolver
570
+ pysentry /path/to/project # Run security scan
571
+ ```
572
+
573
+ ### pyproject.toml Files (External Resolution)
574
+
575
+ Support for projects without lock files:
576
+
577
+ - Parses version constraints from `pyproject.toml`
578
+ - **Resolver Required**: Like requirements.txt, needs external resolvers (`uv` or `pip-tools`) to convert version constraints to exact versions for accurate vulnerability scanning
579
+ - Limited dependency graph information compared to lock files
580
+ - Works with both Poetry and PEP 621 formats
581
+
582
+ ## Vulnerability Data Sources
583
+
584
+ ### PyPA Advisory Database (Default)
585
+
586
+ - Comprehensive coverage of Python ecosystem
587
+ - Community-maintained vulnerability database
588
+ - Regular updates from security researchers
589
+
590
+ ### PyPI JSON API
591
+
592
+ - Official PyPI vulnerability data
593
+ - Real-time information
594
+ - Limited to packages hosted on PyPI
595
+
596
+ ### OSV.dev
597
+
598
+ - Cross-ecosystem vulnerability database
599
+ - Google-maintained infrastructure
600
+
601
+ ## Output Formats
602
+
603
+ ### Human-Readable (Default)
604
+
605
+ Most comfortable to read.
606
+
607
+ ### Markdown
608
+
609
+ GitHub-friendly format with structured sections and severity indicators. Perfect for documentation, GitHub issues, and security reports.
610
+
611
+ ### JSON
612
+
613
+ ```json
614
+ {
615
+ "summary": {
616
+ "total_dependencies": 245,
617
+ "vulnerable_packages": 2,
618
+ "total_vulnerabilities": 3,
619
+ "by_severity": {
620
+ "critical": 1,
621
+ "high": 1,
622
+ "medium": 1,
623
+ "low": 0
624
+ }
625
+ },
626
+ "vulnerabilities": [...]
627
+ }
628
+ ```
629
+
630
+ ### SARIF (Static Analysis Results Interchange Format)
631
+
632
+ Compatible with GitHub Security tab, VS Code, and other security tools.
633
+
634
+ ## Performance
635
+
636
+ PySentry is designed for speed and efficiency:
637
+
638
+ - **Concurrent Processing**: Vulnerability data fetched in parallel from multiple sources
639
+ - **Multi-tier Caching**: Intelligent caching for both vulnerability data and resolved dependencies
640
+ - **Efficient Matching**: In-memory indexing for fast vulnerability lookups
641
+ - **Streaming**: Large databases processed without excessive memory usage
642
+
643
+ ### Resolution Cache Performance
644
+
645
+ The resolution cache provides dramatic performance improvements for requirements.txt files:
646
+
647
+ - **First scan**: Standard resolution time using `uv` or `pip-tools`
648
+ - **Subsequent scans**: Near-instantaneous when cache is fresh (>90% time savings)
649
+ - **Cache invalidation**: Automatic when requirements content, resolver, or environment changes
650
+ - **Content-aware**: Different cache entries for different Python versions and platforms
651
+
652
+ ### Requirements.txt Resolution Performance
653
+
654
+ PySentry leverages external resolvers with intelligent caching:
655
+
656
+ - **uv resolver**: 2-10x faster than pip-tools, handles large dependency trees efficiently
657
+ - **pip-tools resolver**: Reliable fallback, slower but widely compatible
658
+ - **Isolated execution**: Prevents project pollution while maintaining security
659
+ - **Resolution caching**: Eliminates repeated resolver calls for unchanged requirements
660
+
661
+ ## Development
662
+
663
+ ### Building from Source
664
+
665
+ ```bash
666
+ git clone https://github.com/nyudenkov/pysentry
667
+ cd pysentry
668
+ cargo build --release
669
+ ```
670
+
671
+ ### Running Tests
672
+
673
+ ```bash
674
+ cargo test
675
+ ```
676
+
677
+ ### Project Structure
678
+
679
+ ```
680
+ src/
681
+ ├── main.rs # CLI interface
682
+ ├── lib.rs # Library API
683
+ ├── cache/ # Caching system
684
+ ├── dependency/ # Dependency scanning
685
+ ├── output/ # Report generation
686
+ ├── parsers/ # Project file parsers
687
+ ├── providers/ # Vulnerability data sources
688
+ ├── types.rs # Core type definitions
689
+ └── vulnerability/ # Vulnerability matching
690
+ ```
691
+
692
+ ## Troubleshooting
693
+
694
+ ### Common Issues
695
+
696
+ **Error: "No lock file or pyproject.toml found"**
697
+
698
+ ```bash
699
+ # Ensure you're in a Python project directory
700
+ ls pyproject.toml uv.lock poetry.lock requirements.txt
701
+
702
+ # Or specify the path explicitly
703
+ pysentry /path/to/python/project
704
+ ```
705
+
706
+ **Error: "No dependency resolver found" or "uv resolver not available"**
707
+
708
+ ```bash
709
+ # Install a supported resolver in your environment
710
+ pip install uv # Recommended - fastest
711
+ pip install pip-tools # Alternative
712
+
713
+ # Verify resolver is available
714
+ uv --version
715
+ pip-compile --version
716
+
717
+ # If using virtual environments, ensure resolver is installed there
718
+ source venv/bin/activate
719
+ pip install uv
720
+ pysentry /path/to/project
721
+ ```
722
+
723
+ **Error: "Failed to resolve requirements"**
724
+
725
+ ```bash
726
+ # Check your requirements.txt syntax
727
+ cat requirements.txt
728
+
729
+ # Try different resolver
730
+ pysentry --resolver pip-tools # if uv fails
731
+ pysentry --resolver uv # if pip-tools fails
732
+
733
+ # Ensure you're in correct environment
734
+ which python
735
+ which uv # or which pip-compile
736
+
737
+ # Debug with verbose output
738
+ pysentry --verbose /path/to/project
739
+ ```
740
+
741
+ **Error: "Failed to fetch vulnerability data"**
742
+
743
+ ```bash
744
+ # Check network connectivity
745
+ curl -I https://osv-vulnerabilities.storage.googleapis.com/
746
+
747
+ # Try with different or multiple sources
748
+ pysentry --sources pypi
749
+ pysentry --sources pypa,osv
750
+ ```
751
+
752
+ **Slow requirements.txt resolution**
753
+
754
+ ```bash
755
+ # Use faster uv resolver instead of pip-tools
756
+ pysentry --resolver uv
757
+
758
+ # Install uv for better performance (2-10x faster)
759
+ pip install uv
760
+
761
+ # Or use uvx for isolated execution
762
+ uvx pysentry-rs --resolver uv /path/to/project
763
+ ```
764
+
765
+ **Requirements.txt files not being detected**
766
+
767
+ ```bash
768
+ # Ensure requirements.txt exists
769
+ ls requirements.txt
770
+
771
+ # Specify path explicitly
772
+ pysentry /path/to/python/project
773
+
774
+ # Include additional requirements files
775
+ pysentry --requirements requirements-dev.txt --requirements requirements-test.txt
776
+
777
+ # Check if higher-priority files exist (they take precedence)
778
+ ls uv.lock poetry.lock Pipfile.lock pyproject.toml Pipfile requirements.txt
779
+ ```
780
+
781
+ **Performance Issues**
782
+
783
+ ```bash
784
+ # Clear all caches and retry
785
+ rm -rf ~/.cache/pysentry # Linux
786
+ rm -rf ~/Library/Caches/pysentry # macOS
787
+ pysentry
788
+
789
+ # Clear only resolution cache (if vulnerability cache is working)
790
+ rm -rf ~/.cache/pysentry/dependency-resolution/ # Linux
791
+ rm -rf ~/Library/Caches/pysentry/dependency-resolution/ # macOS
792
+ pysentry
793
+
794
+ # Clear resolution cache via CLI
795
+ pysentry --clear-resolution-cache
796
+
797
+ # Use verbose mode to identify bottlenecks
798
+ pysentry --verbose
799
+
800
+ # Disable caching to isolate issues
801
+ pysentry --no-cache
802
+ ```
803
+
804
+ **Resolution Cache Issues**
805
+
806
+ ```bash
807
+ # Clear stale resolution cache after environment changes
808
+ pysentry --clear-resolution-cache
809
+
810
+ # Disable resolution cache if causing issues
811
+ pysentry --no-resolution-cache
812
+
813
+ # Extend cache TTL for stable environments
814
+ pysentry --resolution-cache-ttl 168 # 1 week
815
+
816
+ # Check cache usage with verbose output
817
+ pysentry --verbose # Shows cache hits/misses
818
+
819
+ # Force fresh resolution (ignores cache)
820
+ pysentry --clear-resolution-cache --no-resolution-cache
821
+ ```
822
+
823
+ ## Acknowledgments
824
+
825
+ - Inspired by [pip-audit](https://github.com/pypa/pip-audit) and [uv #9189 issue](https://github.com/astral-sh/uv/issues/9189)
826
+ - Originally was a command for [uv](https://github.com/astral-sh/uv)
827
+ - Vulnerability data from [PyPA](https://github.com/pypa/advisory-database), [PyPI](https://pypi.org/), and [OSV.dev](https://osv.dev/)
828
+