Skip to content

uv audit Command for Security Vulnerability Scanning #9189

@31z4

Description

@31z4

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:

  1. Read dependencies from both pyproject.toml and uv.lock
  2. Check all locked dependencies (including all dependency groups) against the Python Packaging Advisory Database
  3. 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

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 to requirements.txt format for scanning
  • Issues:
    • Additional synchronization overhead
    • Platform compatibility issues
    • Complex workflow

Additional Context

Next Steps

  1. Gather community feedback on the proposed approach
  2. Discuss implementation details if approved
  3. Define specific behavior for edge cases
  4. Determine output format standards

💡 Please share your thoughts on this proposal, particularly regarding:

  • Preferred output formats
  • Specific use cases to consider

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions