Skip to content

Replace pip-audit with uv audit for vulnerability scanning - #7

Draft
GuidoHeijden with Copilot wants to merge 3 commits into
mainfrom
copilot/replace-pip-audit-with-uv-audit
Draft

Replace pip-audit with uv audit for vulnerability scanning#7
GuidoHeijden with Copilot wants to merge 3 commits into
mainfrom
copilot/replace-pip-audit-with-uv-audit

Conversation

Copilot AI commented May 20, 2026

Copy link
Copy Markdown

Summary

Migrates from pip-audit to uv audit for dependency vulnerability scanning, as uv audit is no longer a preview feature and provides a simpler, more integrated solution for projects managed by uv.

Changes

hooks/check_uv_lock_vulnerabilities.py

  • Replaced the pip-audit approach (export to requirements.txt → run pip-audit) with a direct uv audit --frozen subprocess call
  • Vulnerability ignore configuration moved from [tool.pip-audit] to [tool.uv-audit] section in pyproject.toml
  • Removed unused imports (os, tempfile, pip_audit)

pyproject.toml

  • Removed pip-audit from dependencies (now empty dependencies = [])
  • Added [tool.uv] exclude-newer = "P7D" to enforce a 7-day dependency cooldown for supply chain attack prevention
  • Updated project description

README.md

  • Updated hook descriptions to reference uv audit instead of pip-audit
  • Added documentation on the dependency cooldown mechanism (exclude-newer)
  • Added documentation on how to ignore specific vulnerability advisories

uv.lock

  • Regenerated without pip-audit and its transitive dependencies

Dependency Cooldown

The exclude-newer = "P7D" setting ensures that only packages published more than 7 days ago are considered during dependency resolution. This prevents supply chain attacks where malicious packages are quickly published and consumed. The --frozen flag in uv audit ensures the audit runs against the existing lockfile without re-resolving, so developers are not blocked by vulnerability fixes still within the cooldown period.

- Rewrite check_uv_lock_vulnerabilities.py to use `uv audit --frozen`
- Remove pip-audit dependency from pyproject.toml
- Add `[tool.uv] exclude-newer = "P7D"` for supply chain attack prevention
- Update README.md with uv audit documentation and cooldown explanation
- Regenerate uv.lock without pip-audit dependencies

Agent-Logs-Url: https://github.com/DatacationOrg/pre-commit-hooks/sessions/7a17e0b9-8ab5-4088-8c0b-039df530392d

Co-authored-by: GuidoHeijden <41060932+GuidoHeijden@users.noreply.github.com>
@GuidoHeijden

Copy link
Copy Markdown

I have made changes such that this PR is good to go. However, uv audit remains in preview and does not account for exclude-newer so no reason to already merge this in. Will revisit once uv audit is no longer a preview feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants