-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Open
Description
Problem
Currently, there's no integrated way to audit dependencies defined in pyproject.toml
and uv.lock
against known security vulnerabilities in the Python Packaging Advisory Database. This creates security risks and workflow inefficiencies:
- Dependencies across different groups cannot be audited in a single operation
- Current solutions require additional tools and complex workflows
- Cross-platform compatibility issues with existing solutions
- Risk of auditing outdated or incorrect dependency sets
Proposed Solution
Implement a native uv audit
command that would:
- Read dependencies from both
pyproject.toml
anduv.lock
- Check all locked dependencies (including all dependency groups) against the Python Packaging Advisory Database
- Generate a security report highlighting:
- Identified vulnerabilities
- Affected versions
- Available fixes
Example usage:
# Audit all dependencies
uv audit
# Audit specific dependency groups
uv audit --group dev,test
# Output in different formats
uv audit --format json
Benefits
- Improved Security: Integrated security scanning as part of the uv toolchain
- Better Performance: Native implementation could offer significant speed improvements (assuming that querying the Python Packaging Advisory Database isn't a bottleneck)
- Cross-Platform: Works consistently across all supported platforms
- Comprehensive Coverage:
- Seamless support for dependency groups
- Covers all project dependencies, not just installed packages
- Ensures audit matches locked dependencies exactly
- Simplified Workflow:
- No additional tools required
- Single command for complete package security audit
- Native integration with uv's dependency management
Alternatives Considered
1. Using pip-audit
- Current Status:
- Limited
pyproject.toml
support (ref: Support for optional dependencies/extras when auditing from pyproject.toml pypa/pip-audit#766) - No
uv.lock
support
- Limited
- Limitations:
- Additional dependency requirement
- Cross-platform inconsistencies
- Incomplete dependency group coverage
2. Extending pip-audit for uv.lock
support
- Pros:
- Leverages existing tool
- Community familiarity
- Cons:
- Loses uv's performance benefits
- Additional dependency requirement remains
- More complex integration
3. Local environment scanning with pip-audit
- Approach: Running
pip-audit -l
against installed packages - Issues:
- Environment may not match declarations
- Limited dependency group coverage
- Platform-specific behavior
4. Requirements.txt generation and scanning with pip-audit
- Approach: Convert
uv.lock
torequirements.txt
format for scanning - Issues:
- Additional synchronization overhead
- Platform compatibility issues
- Complex workflow
Additional Context
- Related Issue: Security check before installation discussion (✨[Feature Request]: Filter uv install by Python Package Authority's Security Advisory Database.✨ #8842)
- Implementation Interest: I'm willing to contribute to the implementation pending community feedback
- Similar Features:
- cargo audit (Rust)
- npm audit (Node.js)
- composer audit (PHP)
Next Steps
- Gather community feedback on the proposed approach
- Discuss implementation details if approved
- Define specific behavior for edge cases
- Determine output format standards
💡 Please share your thoughts on this proposal, particularly regarding:
- Preferred output formats
- Specific use cases to consider
blueraft, alexander-gridnev, T-256, UnknownPlatypus, SteveMcGrath and 73 more
Metadata
Metadata
Assignees
Labels
No labels