pysentry-rs 0.3.12__cp310-cp310-manylinux_2_28_aarch64.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,881 @@
1
+ Metadata-Version: 2.4
2
+ Name: pysentry-rs
3
+ Version: 0.3.12
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-3.14 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-3.14 and [uv](https://docs.astral.sh/uv/) installed
133
+ - **For binaries**: No additional dependencies
134
+ - **For Python package**: Python 3.9-3.14
135
+ - **For Rust package and source**: Rust 1.79+
136
+
137
+ ### Platform Support
138
+
139
+ | Installation Method | Linux (x64) | Linux (ARM64) | macOS (x64) | macOS (ARM64) | Windows (x64) |
140
+ | ------------------- | ----------- | ------------- | ----------- | ------------- | ------------- |
141
+ | uvx | ✅ | ✅ | ✅ | ✅ | ✅ |
142
+ | PyPI (pip) | ✅ | ✅ | ✅ | ✅ | ✅ |
143
+ | Crates.io (cargo) | ✅ | ✅ | ✅ | ✅ | ✅ |
144
+ | GitHub Releases | ✅ | ✅ | ✅ | ✅ | ✅ |
145
+ | From Source | ✅ | ✅ | ✅ | ✅ | ✅ |
146
+
147
+ **Supported Python Versions**: 3.9, 3.10, 3.11, 3.12, 3.13, 3.14
148
+ **Supported Architectures**: x86_64 (x64), ARM64 (aarch64)
149
+
150
+
151
+ ### CLI Command Names
152
+
153
+ - **Rust binary**: `pysentry` (when installed via cargo or binary releases)
154
+ - **Python package**: `pysentry-rs` (when installed via pip or uvx)
155
+
156
+ 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.
157
+
158
+ ### Requirements.txt Support Prerequisites
159
+
160
+ 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.
161
+
162
+ **Install a supported resolver:**
163
+
164
+ ```bash
165
+ # uv (recommended - fastest, Rust-based)
166
+ pip install uv
167
+
168
+ # pip-tools (widely compatible, Python-based)
169
+ pip install pip-tools
170
+ ```
171
+
172
+ **Environment Requirements:**
173
+
174
+ - Resolvers must be available in your current environment
175
+ - If using virtual environments, activate your venv before running PySentry:
176
+ ```bash
177
+ source venv/bin/activate # Linux/macOS
178
+ venv\Scripts\activate # Windows
179
+ pysentry /path/to/project
180
+ ```
181
+ - Alternatively, install resolvers globally for system-wide availability
182
+
183
+ **Auto-detection:** PySentry automatically detects and prefers: `uv` > `pip-tools`. Without a resolver, only `uv.lock` and `poetry.lock` files can be scanned.
184
+
185
+ ## Quick Start
186
+
187
+ ### Basic Usage
188
+
189
+ ```bash
190
+ # Using uvx (recommended for occasional use)
191
+ uvx pysentry-rs
192
+ uvx pysentry-rs /path/to/python/project
193
+
194
+ # Using installed binary
195
+ pysentry
196
+ pysentry /path/to/python/project
197
+
198
+ # Automatically detects project type (uv.lock, poetry.lock, Pipfile.lock, pyproject.toml, Pipfile, requirements.txt)
199
+ pysentry /path/to/project
200
+
201
+ # Force specific resolver
202
+ pysentry --resolver uv /path/to/project
203
+ pysentry --resolver pip-tools /path/to/project
204
+
205
+ # Exclude extra dependencies (only check main dependencies)
206
+ pysentry --exclude-extra
207
+
208
+ # Filter by severity (only show high and critical)
209
+ pysentry --severity high
210
+
211
+ # Output to JSON file
212
+ pysentry --format json --output audit-results.json
213
+ ```
214
+
215
+ ### Advanced Usage
216
+
217
+ ```bash
218
+ # Using uvx for comprehensive audit (extras included by default)
219
+ uvx pysentry-rs --format sarif --output security-report.sarif
220
+
221
+ # Check multiple vulnerability sources concurrently
222
+ uvx pysentry-rs --sources pypa,osv,pypi /path/to/project
223
+ uvx pysentry-rs --sources pypa --sources osv --sources pypi
224
+
225
+ # Generate markdown report
226
+ uvx pysentry-rs --format markdown --output security-report.md
227
+
228
+ # Control CI exit codes - only fail on critical vulnerabilities
229
+ uvx pysentry-rs --fail-on critical
230
+
231
+ # Or with installed binary (extras included by default)
232
+ pysentry --format sarif --output security-report.sarif
233
+ pysentry --sources pypa,osv --direct-only
234
+ pysentry --format markdown --output security-report.md
235
+
236
+ # Ignore specific vulnerabilities
237
+ pysentry --ignore CVE-2023-12345 --ignore GHSA-xxxx-yyyy-zzzz
238
+
239
+ # Ignore unfixable vulnerabilities (only while they have no fix available)
240
+ pysentry --ignore-while-no-fix CVE-2025-8869
241
+
242
+ # Disable caching for CI environments
243
+ pysentry --no-cache
244
+
245
+ # Verbose output for debugging
246
+ pysentry --verbose
247
+ ```
248
+
249
+ ### Advanced Requirements.txt Usage
250
+
251
+ ```bash
252
+ # Scan multiple requirements files
253
+ pysentry --requirements requirements.txt --requirements requirements-dev.txt
254
+
255
+ # Check only direct dependencies from requirements.txt
256
+ pysentry --direct-only --resolver uv
257
+
258
+ # Ensure resolver is available in your environment
259
+ source venv/bin/activate # Activate your virtual environment first
260
+ pysentry /path/to/project
261
+
262
+ # Debug requirements.txt resolution
263
+ pysentry --verbose --resolver uv /path/to/project
264
+
265
+ # Use longer resolution cache TTL (48 hours)
266
+ pysentry --resolution-cache-ttl 48 /path/to/project
267
+
268
+ # Clear resolution cache before scanning
269
+ pysentry --clear-resolution-cache /path/to/project
270
+ ```
271
+
272
+ ### CI/CD Integration Examples
273
+
274
+ ```bash
275
+ # Development environment - only fail on critical vulnerabilities
276
+ pysentry --fail-on critical --format json --output security-report.json
277
+
278
+ # Staging environment - fail on high+ vulnerabilities
279
+ pysentry --fail-on high --sources pypa,osv --format sarif --output security.sarif
280
+
281
+ # Production deployment - strict security (fail on medium+, default)
282
+ pysentry --sources pypa,pypi,osv --format json --output prod-security.json
283
+
284
+ # Generate markdown report for GitHub issues/PRs
285
+ pysentry --format markdown --output SECURITY-REPORT.md
286
+
287
+ # Comprehensive audit with all sources and full reporting (extras included by default)
288
+ pysentry --sources pypa,pypi,osv --format json --fail-on low
289
+
290
+ # CI environment with fresh resolution cache
291
+ pysentry --clear-resolution-cache --sources pypa,osv --format sarif
292
+
293
+ # CI with resolution cache disabled
294
+ pysentry --no-resolution-cache --format json --output security-report.json
295
+ ```
296
+
297
+ ## Pre-commit Integration
298
+
299
+ PySentry integrates seamlessly with [pre-commit](https://pre-commit.com/) to automatically scan for vulnerabilities before commits.
300
+
301
+ ### Setup
302
+
303
+ Add PySentry to your `.pre-commit-config.yaml`:
304
+
305
+ ```yaml
306
+ repos:
307
+ - repo: https://github.com/pysentry/pysentry-pre-commit
308
+ rev: v0.3.11
309
+ hooks:
310
+ - id: pysentry # default pysentry settings
311
+ ```
312
+
313
+ ### Advanced Configuration
314
+
315
+ ```yaml
316
+ repos:
317
+ - repo: https://github.com/pysentry/pysentry-pre-commit
318
+ rev: v0.3.11
319
+ hooks:
320
+ - id: pysentry
321
+ args: ["--sources", "pypa,osv", "--fail-on", "high"]
322
+ ```
323
+
324
+ ### Installation Requirements
325
+
326
+ Pre-commit will automatically install PySentry, uv and pip-tools via PyPI.
327
+
328
+ ## Configuration
329
+
330
+ PySentry supports TOML-based configuration files for persistent settings management. Configuration files follow a hierarchical discovery pattern:
331
+
332
+ 1. **Project-level**: `.pysentry.toml` in current or parent directories
333
+ 2. **User-level**: `~/.config/pysentry/config.toml` (Linux/macOS)
334
+ 3. **System-level**: `/etc/pysentry/config.toml` (Unix systems)
335
+
336
+ ### Configuration File Example
337
+
338
+ ```toml
339
+ version = 1
340
+
341
+ [defaults]
342
+ format = "json"
343
+ severity = "medium"
344
+ fail_on = "high"
345
+ scope = "all"
346
+ direct_only = false
347
+
348
+ [sources]
349
+ enabled = ["pypa", "osv"]
350
+
351
+ [resolver]
352
+ type = "uv"
353
+ fallback = "pip-tools"
354
+
355
+ [cache]
356
+ enabled = true
357
+ resolution_ttl = 48
358
+ vulnerability_ttl = 72
359
+
360
+ [output]
361
+ quiet = false
362
+ verbose = false
363
+ color = "auto"
364
+
365
+ [ignore]
366
+ ids = ["CVE-2023-12345", "GHSA-xxxx-yyyy-zzzz"]
367
+ while_no_fix = ["CVE-2025-8869"]
368
+
369
+ [http]
370
+ timeout = 120
371
+ connect_timeout = 30
372
+ max_retries = 3
373
+ retry_initial_backoff = 1
374
+ retry_max_backoff = 60
375
+ show_progress = true
376
+ ```
377
+
378
+
379
+ ### Environment Variables
380
+
381
+ | Variable | Description | Example |
382
+ | -------------------- | ------------------------------- | -------------------------------------- |
383
+ | `PYSENTRY_CONFIG` | Override config file path | `PYSENTRY_CONFIG=/path/to/config.toml` |
384
+ | `PYSENTRY_NO_CONFIG` | Disable all config file loading | `PYSENTRY_NO_CONFIG=1` |
385
+
386
+ ### Command Line Options
387
+
388
+ | Option | Description | Default |
389
+ | -------------------------- | --------------------------------------------------------- | ----------------- |
390
+ | `--format` | Output format: `human`, `json`, `sarif`, `markdown` | `human` |
391
+ | `--severity` | Minimum severity: `low`, `medium`, `high`, `critical` | `low` |
392
+ | `--fail-on` | Fail (exit non-zero) on vulnerabilities ≥ severity | `medium` |
393
+ | `--sources` | Vulnerability sources: `pypa`, `pypi`, `osv` (multiple) | `pypa` |
394
+ | `--exclude-extra` | Exclude extra dependencies (dev, optional, etc) | `false` |
395
+ | `--direct-only` | Check only direct dependencies | `false` |
396
+ | `--detailed` | Show full vulnerability descriptions instead of truncated | `false` |
397
+ | `--ignore` | Vulnerability IDs to ignore (repeatable) | `[]` |
398
+ | `--ignore-while-no-fix` | Ignore vulnerabilities only while no fix is available | `[]` |
399
+ | `--output` | Output file path | `stdout` |
400
+ | `--no-cache` | Disable all caching | `false` |
401
+ | `--cache-dir` | Custom cache directory | Platform-specific |
402
+ | `--resolution-cache-ttl` | Resolution cache TTL in hours | `24` |
403
+ | `--no-resolution-cache` | Disable resolution caching only | `false` |
404
+ | `--clear-resolution-cache` | Clear resolution cache on startup | `false` |
405
+ | `--verbose` | Enable verbose output | `false` |
406
+ | `--quiet` | Suppress non-error output | `false` |
407
+ | `--resolver` | Dependency resolver: `auto`, `uv`, `pip-tools` | `auto` |
408
+ | `--requirements` | Additional requirements files (repeatable) | `[]` |
409
+
410
+ ### Cache Management
411
+
412
+ PySentry uses an intelligent multi-tier caching system for optimal performance:
413
+
414
+ #### Vulnerability Data Cache
415
+
416
+ - **Location**: `{CACHE_DIR}/pysentry/vulnerability-db/`
417
+ - **Purpose**: Caches vulnerability databases from PyPA, PyPI, OSV
418
+ - **TTL**: 24 hours (configurable per source)
419
+ - **Benefits**: Avoids redundant API calls and downloads
420
+
421
+ #### Resolution Cache
422
+
423
+ - **Location**: `{CACHE_DIR}/pysentry/dependency-resolution/`
424
+ - **Purpose**: Caches resolved dependencies from `uv`/`pip-tools`
425
+ - **TTL**: 24 hours (configurable via `--resolution-cache-ttl`)
426
+ - **Benefits**: Dramatically speeds up repeated scans of requirements.txt files
427
+ - **Cache Key**: Based on requirements content, resolver version, Python version, platform
428
+
429
+ #### Platform-Specific Cache Locations
430
+
431
+ - **Linux**: `~/.cache/pysentry/`
432
+ - **macOS**: `~/Library/Caches/pysentry/`
433
+ - **Windows**: `%LOCALAPPDATA%\pysentry\`
434
+
435
+ **Finding Your Cache Location**: Run with `--verbose` to see the actual cache directory path being used.
436
+
437
+ #### Cache Features
438
+
439
+ - **Atomic Updates**: Prevents cache corruption during concurrent access
440
+ - **Custom Location**: Use `--cache-dir` to specify alternative location
441
+ - **Selective Clearing**: Control caching behavior per cache type
442
+ - **Content-based Invalidation**: Automatic cache invalidation on content changes
443
+
444
+ #### Cache Control Examples
445
+
446
+ ```bash
447
+ # Disable all caching
448
+ pysentry --no-cache
449
+
450
+ # Disable only resolution caching (keep vulnerability cache)
451
+ pysentry --no-resolution-cache
452
+
453
+ # Set resolution cache TTL to 48 hours
454
+ pysentry --resolution-cache-ttl 48
455
+
456
+ # Clear resolution cache on startup (useful for CI)
457
+ pysentry --clear-resolution-cache
458
+
459
+ # Custom cache directory
460
+ pysentry --cache-dir /tmp/my-pysentry-cache
461
+ ```
462
+
463
+ To manually clear all caches:
464
+
465
+ ```bash
466
+ # Linux
467
+ rm -rf ~/.cache/pysentry/
468
+
469
+ # macOS
470
+ rm -rf ~/Library/Caches/pysentry/
471
+
472
+ # Windows (PowerShell)
473
+ Remove-Item -Recurse -Force "$env:LOCALAPPDATA\pysentry"
474
+ ```
475
+
476
+ To clear only resolution cache:
477
+
478
+ ```bash
479
+ # Linux
480
+ rm -rf ~/.cache/pysentry/dependency-resolution/
481
+
482
+ # macOS
483
+ rm -rf ~/Library/Caches/pysentry/dependency-resolution/
484
+
485
+ # Windows (PowerShell)
486
+ Remove-Item -Recurse -Force "$env:LOCALAPPDATA\pysentry\dependency-resolution"
487
+ ```
488
+
489
+ ## Supported Project Formats
490
+
491
+ ### uv.lock Files (Recommended)
492
+
493
+ PySentry has support for `uv.lock` files:
494
+
495
+ - Exact version resolution
496
+ - Complete dependency graph analysis
497
+ - Source tracking
498
+ - Dependency classification (main, dev, optional) including transitive dependencies
499
+
500
+ ### poetry.lock Files
501
+
502
+ Full support for Poetry lock files:
503
+
504
+ - **Exact Version Resolution**: Scans exact dependency versions locked by Poetry
505
+ - **Lock-File Only Analysis**: Relies purely on the lock file structure, no pyproject.toml parsing needed
506
+ - **Complete Dependency Tree**: Analyzes all resolved dependencies including transitive ones
507
+ - **Dependency Classification**: Distinguishes between main dependencies and optional groups (dev, test, etc.)
508
+ - **Source Tracking**: Supports PyPI registry, Git repositories, local paths, and direct URLs
509
+
510
+ **Key Features:**
511
+
512
+ - No external tools required
513
+ - Fast parsing with exact version information
514
+ - Handles Poetry's dependency groups and optional dependencies
515
+ - Perfect for Poetry-managed projects with established lock files
516
+
517
+ ### Pipfile.lock Files
518
+
519
+ Full support for Pipenv lock files with exact version resolution:
520
+
521
+ - **Exact Version Resolution**: Scans exact dependency versions locked by Pipenv
522
+ - **Lock-File Only Analysis**: Relies purely on the lock file structure, no Pipfile parsing needed
523
+ - **Complete Dependency Tree**: Analyzes all resolved dependencies including transitive ones
524
+ - **Dependency Classification**: Distinguishes between default dependencies and development groups
525
+
526
+ **Key Features:**
527
+
528
+ - No external tools required
529
+ - Fast parsing with exact version information
530
+ - Handles Pipenv's dependency groups (default and develop)
531
+ - Perfect for Pipenv-managed projects with established lock files
532
+
533
+ ### Pipfile Files (External Resolution)
534
+
535
+ Support for Pipfile specification files using external dependency resolvers:
536
+
537
+ **Key Features:**
538
+
539
+ - **Dependencies Resolution**: Converts version constraints from Pipfile to exact versions using mature external tools
540
+ - **Multiple Resolver Support**:
541
+ - **uv**: Rust-based resolver, extremely fast and reliable (recommended)
542
+ - **pip-tools**: Python-based resolver using `pip-compile`, widely compatible
543
+ - **Auto-detection**: Automatically detects and uses the best available resolver in your environment
544
+ - **Dependency Groups**: Supports both default packages and dev-packages sections
545
+ - **Complex Constraint Handling**: Supports version ranges, Git dependencies, and environment markers
546
+
547
+ **Resolution Workflow:**
548
+
549
+ 1. Detects `Pipfile` in your project (when `Pipfile.lock` is not present)
550
+ 2. Auto-detects available resolver (`uv` or `pip-tools`) in current environment
551
+ 3. Resolves version constraints to exact dependency versions
552
+ 4. Scans resolved dependencies for vulnerabilities
553
+ 5. Reports findings with dependency group classification
554
+
555
+ **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.
556
+
557
+ ### requirements.txt Files (External Resolution)
558
+
559
+ Advanced support for `requirements.txt` files using external dependency resolvers:
560
+
561
+ **Key Features:**
562
+
563
+ - **Dependencies Resolution**: Converts version constraints (e.g., `flask>=2.0,<3.0`) to exact versions using mature external tools
564
+ - **Multiple Resolver Support**:
565
+ - **uv**: Rust-based resolver, extremely fast and reliable (recommended)
566
+ - **pip-tools**: Python-based resolver using `pip-compile`, widely compatible
567
+ - **Auto-detection**: Automatically detects and uses the best available resolver in your environment
568
+ - **Multiple File Support**: Combines `requirements.txt`, `requirements-dev.txt`, `requirements-test.txt`, etc.
569
+ - **Dependency Classification**: Distinguishes between direct and transitive dependencies
570
+ - **Isolated Execution**: Resolvers run in temporary directories to prevent project pollution
571
+ - **Complex Constraint Handling**: Supports version ranges, extras, environment markers, and conflict resolution
572
+
573
+ **Resolution Workflow:**
574
+
575
+ 1. Detects `requirements.txt` files in your project
576
+ 2. Auto-detects available resolver (`uv` or `pip-tools`) in current environment
577
+ 3. Resolves version constraints to exact dependency versions
578
+ 4. Scans resolved dependencies for vulnerabilities
579
+ 5. Reports findings with direct vs. transitive classification
580
+
581
+ **Environment Setup:**
582
+
583
+ ```bash
584
+ # Ensure resolver is available in your environment
585
+ source venv/bin/activate # Activate virtual environment
586
+ pip install uv # Install preferred resolver
587
+ pysentry /path/to/project # Run security scan
588
+ ```
589
+
590
+ ### pyproject.toml Files (External Resolution)
591
+
592
+ Support for projects without lock files:
593
+
594
+ - Parses version constraints from `pyproject.toml`
595
+ - **Resolver Required**: Like requirements.txt, needs external resolvers (`uv` or `pip-tools`) to convert version constraints to exact versions for accurate vulnerability scanning
596
+ - Limited dependency graph information compared to lock files
597
+ - Works with both Poetry and PEP 621 formats
598
+
599
+ ## Vulnerability Data Sources
600
+
601
+ ### PyPA Advisory Database (Default)
602
+
603
+ - Comprehensive coverage of Python ecosystem
604
+ - Community-maintained vulnerability database
605
+ - Regular updates from security researchers
606
+
607
+ ### PyPI JSON API
608
+
609
+ - Official PyPI vulnerability data
610
+ - Real-time information
611
+ - Limited to packages hosted on PyPI
612
+
613
+ ### OSV.dev
614
+
615
+ - Cross-ecosystem vulnerability database
616
+ - Google-maintained infrastructure
617
+
618
+ ## Output Formats
619
+
620
+ ### Human-Readable (Default)
621
+
622
+ Most comfortable to read.
623
+
624
+ ### Markdown
625
+
626
+ GitHub-friendly format with structured sections and severity indicators. Perfect for documentation, GitHub issues, and security reports.
627
+
628
+ ### JSON
629
+
630
+ ```json
631
+ {
632
+ "summary": {
633
+ "total_dependencies": 245,
634
+ "vulnerable_packages": 2,
635
+ "total_vulnerabilities": 3,
636
+ "by_severity": {
637
+ "critical": 1,
638
+ "high": 1,
639
+ "medium": 1,
640
+ "low": 0
641
+ }
642
+ },
643
+ "vulnerabilities": [...]
644
+ }
645
+ ```
646
+
647
+ ### SARIF (Static Analysis Results Interchange Format)
648
+
649
+ Compatible with GitHub Security tab, VS Code, and other security tools.
650
+
651
+ ## Performance
652
+
653
+ PySentry is designed for speed and efficiency:
654
+
655
+ - **Concurrent Processing**: Vulnerability data fetched in parallel from multiple sources
656
+ - **Multi-tier Caching**: Intelligent caching for both vulnerability data and resolved dependencies
657
+ - **Efficient Matching**: In-memory indexing for fast vulnerability lookups
658
+ - **Streaming**: Large databases processed without excessive memory usage
659
+
660
+ ### Resolution Cache Performance
661
+
662
+ The resolution cache provides dramatic performance improvements for requirements.txt files:
663
+
664
+ - **First scan**: Standard resolution time using `uv` or `pip-tools`
665
+ - **Subsequent scans**: Near-instantaneous when cache is fresh (>90% time savings)
666
+ - **Cache invalidation**: Automatic when requirements content, resolver, or environment changes
667
+ - **Content-aware**: Different cache entries for different Python versions and platforms
668
+
669
+ ### Requirements.txt Resolution Performance
670
+
671
+ PySentry leverages external resolvers with intelligent caching:
672
+
673
+ - **uv resolver**: 2-10x faster than pip-tools, handles large dependency trees efficiently
674
+ - **pip-tools resolver**: Reliable fallback, slower but widely compatible
675
+ - **Isolated execution**: Prevents project pollution while maintaining security
676
+ - **Resolution caching**: Eliminates repeated resolver calls for unchanged requirements
677
+
678
+ ## Development
679
+
680
+ ### Building from Source
681
+
682
+ ```bash
683
+ git clone https://github.com/nyudenkov/pysentry
684
+ cd pysentry
685
+ cargo build --release
686
+ ```
687
+
688
+ ### Running Tests
689
+
690
+ ```bash
691
+ cargo test
692
+ ```
693
+
694
+ ### Project Structure
695
+
696
+ ```
697
+ src/
698
+ ├── main.rs # CLI interface
699
+ ├── lib.rs # Library API
700
+ ├── cache/ # Caching system
701
+ ├── dependency/ # Dependency scanning
702
+ ├── output/ # Report generation
703
+ ├── parsers/ # Project file parsers
704
+ ├── providers/ # Vulnerability data sources
705
+ ├── types.rs # Core type definitions
706
+ └── vulnerability/ # Vulnerability matching
707
+ ```
708
+
709
+ ## Troubleshooting
710
+
711
+ ### Common Issues
712
+
713
+ **Error: "No lock file or pyproject.toml found"**
714
+
715
+ ```bash
716
+ # Ensure you're in a Python project directory
717
+ ls pyproject.toml uv.lock poetry.lock requirements.txt
718
+
719
+ # Or specify the path explicitly
720
+ pysentry /path/to/python/project
721
+ ```
722
+
723
+ **Error: "No dependency resolver found" or "uv resolver not available"**
724
+
725
+ ```bash
726
+ # Install a supported resolver in your environment
727
+ pip install uv # Recommended - fastest
728
+ pip install pip-tools # Alternative
729
+
730
+ # Verify resolver is available
731
+ uv --version
732
+ pip-compile --version
733
+
734
+ # If using virtual environments, ensure resolver is installed there
735
+ source venv/bin/activate
736
+ pip install uv
737
+ pysentry /path/to/project
738
+ ```
739
+
740
+ **Error: "Failed to resolve requirements"**
741
+
742
+ ```bash
743
+ # Check your requirements.txt syntax
744
+ cat requirements.txt
745
+
746
+ # Try different resolver
747
+ pysentry --resolver pip-tools # if uv fails
748
+ pysentry --resolver uv # if pip-tools fails
749
+
750
+ # Ensure you're in correct environment
751
+ which python
752
+ which uv # or which pip-compile
753
+
754
+ # Debug with verbose output
755
+ pysentry --verbose /path/to/project
756
+ ```
757
+
758
+ **Error: "Failed to fetch vulnerability data"**
759
+
760
+ ```bash
761
+ # Check network connectivity
762
+ curl -I https://osv-vulnerabilities.storage.googleapis.com/
763
+
764
+ # Try with different or multiple sources
765
+ pysentry --sources pypi
766
+ pysentry --sources pypa,osv
767
+
768
+ # For slow or unstable networks, increase timeout and retries
769
+ # Create/edit .pysentry.toml in your project:
770
+ ```
771
+
772
+ ```toml
773
+ [http]
774
+ timeout = 300 # 5 minute timeout
775
+ max_retries = 5 # More retry attempts
776
+ retry_max_backoff = 120 # Longer backoff delays
777
+ ```
778
+
779
+ ```bash
780
+ # Then run again
781
+ pysentry
782
+ ```
783
+
784
+ **Network timeout errors:**
785
+
786
+ PySentry includes automatic retry with exponential backoff for network issues. If you still experience timeouts:
787
+
788
+ ```bash
789
+ # Increase timeout values in config
790
+ pysentry config init --output .pysentry.toml
791
+ # Edit .pysentry.toml and adjust [http] section
792
+ ```
793
+
794
+ **Rate limiting (HTTP 429 errors):**
795
+
796
+ PySentry automatically handles rate limiting. If rate limits persist:
797
+
798
+ ```toml
799
+ [http]
800
+ max_retries = 5 # More attempts
801
+ retry_initial_backoff = 5 # Longer initial wait
802
+ retry_max_backoff = 300 # Up to 5 minute backoff
803
+ ```
804
+
805
+ **Slow requirements.txt resolution**
806
+
807
+ ```bash
808
+ # Use faster uv resolver instead of pip-tools
809
+ pysentry --resolver uv
810
+
811
+ # Install uv for better performance (2-10x faster)
812
+ pip install uv
813
+
814
+ # Or use uvx for isolated execution
815
+ uvx pysentry-rs --resolver uv /path/to/project
816
+ ```
817
+
818
+ **Requirements.txt files not being detected**
819
+
820
+ ```bash
821
+ # Ensure requirements.txt exists
822
+ ls requirements.txt
823
+
824
+ # Specify path explicitly
825
+ pysentry /path/to/python/project
826
+
827
+ # Include additional requirements files
828
+ pysentry --requirements requirements-dev.txt --requirements requirements-test.txt
829
+
830
+ # Check if higher-priority files exist (they take precedence)
831
+ ls uv.lock poetry.lock Pipfile.lock pyproject.toml Pipfile requirements.txt
832
+ ```
833
+
834
+ **Performance Issues**
835
+
836
+ ```bash
837
+ # Clear all caches and retry
838
+ rm -rf ~/.cache/pysentry # Linux
839
+ rm -rf ~/Library/Caches/pysentry # macOS
840
+ pysentry
841
+
842
+ # Clear only resolution cache (if vulnerability cache is working)
843
+ rm -rf ~/.cache/pysentry/dependency-resolution/ # Linux
844
+ rm -rf ~/Library/Caches/pysentry/dependency-resolution/ # macOS
845
+ pysentry
846
+
847
+ # Clear resolution cache via CLI
848
+ pysentry --clear-resolution-cache
849
+
850
+ # Use verbose mode to identify bottlenecks
851
+ pysentry --verbose
852
+
853
+ # Disable caching to isolate issues
854
+ pysentry --no-cache
855
+ ```
856
+
857
+ **Resolution Cache Issues**
858
+
859
+ ```bash
860
+ # Clear stale resolution cache after environment changes
861
+ pysentry --clear-resolution-cache
862
+
863
+ # Disable resolution cache if causing issues
864
+ pysentry --no-resolution-cache
865
+
866
+ # Extend cache TTL for stable environments
867
+ pysentry --resolution-cache-ttl 168 # 1 week
868
+
869
+ # Check cache usage with verbose output
870
+ pysentry --verbose # Shows cache hits/misses
871
+
872
+ # Force fresh resolution (ignores cache)
873
+ pysentry --clear-resolution-cache --no-resolution-cache
874
+ ```
875
+
876
+ ## Acknowledgments
877
+
878
+ - Inspired by [pip-audit](https://github.com/pypa/pip-audit) and [uv #9189 issue](https://github.com/astral-sh/uv/issues/9189)
879
+ - Originally was a command for [uv](https://github.com/astral-sh/uv)
880
+ - Vulnerability data from [PyPA](https://github.com/pypa/advisory-database), [PyPI](https://pypi.org/), and [OSV.dev](https://osv.dev/)
881
+