freshcrate
Home > Frameworks > pip-audit

pip-audit

A tool for scanning Python environments for known vulnerabilities

Description

pip-audit ========= <!--- BADGES: START ---> [![CI](https://github.com/pypa/pip-audit/workflows/CI/badge.svg)](https://github.com/pypa/pip-audit/actions/workflows/ci.yml) [![PyPI version](https://badge.fury.io/py/pip-audit.svg)](https://pypi.org/project/pip-audit) [![Packaging status](https://repology.org/badge/tiny-repos/python:pip-audit.svg)](https://repology.org/project/python:pip-audit/versions) [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/pypa/pip-audit/badge)](https://api.securityscorecards.dev/projects/github.com/pypa/pip-audit) [![License](https://img.shields.io/github/license/pypa/pip-audit)](https://github.com/pypa/pip-audit/blob/main/LICENSE) <!--- BADGES: END ---> `pip-audit` is a tool for scanning Python environments for packages with known vulnerabilities. It uses the Python Packaging Advisory Database (https://github.com/pypa/advisory-database) via the [PyPI JSON API](https://warehouse.pypa.io/api-reference/json.html) as a source of vulnerability reports. This project is maintained in part by [Trail of Bits](https://www.trailofbits.com/) with support from Google. This is not an official Google or Trail of Bits product. ## Index * [Features](#features) * [Installation](#installation) * [Third-party packages](#third-party-packages) * [GitHub Actions](#github-actions) * [`pre-commit` support](#pre-commit-support) * [Usage](#usage) * [Environment variables](#environment-variables) * [Exit codes](#exit-codes) * [Dry runs](#dry-runs) * [Examples](#examples) * [Troubleshooting](#troubleshooting) * [Tips and Tricks](#tips-and-tricks) * [Security model](#security-model) * [Licensing](#licensing) * [Contributing](#contributing) * [Code of Conduct](#code-of-conduct) ## Features * Support for auditing local environments and requirements-style files * Support for multiple vulnerability services ([PyPI](https://warehouse.pypa.io/api-reference/json.html#known-vulnerabilities), [OSV](https://osv.dev/docs/)) * Support for emitting [SBOMs](https://en.wikipedia.org/wiki/Software_bill_of_materials) in [CycloneDX](https://cyclonedx.org/) XML or JSON * Support for automatically fixing vulnerable dependencies (`--fix`) * Human and machine-readable output formats (columnar, Markdown, JSON) * Seamlessly reuses your existing local `pip` caches ## Installation `pip-audit` requires Python 3.9 or newer, and can be installed directly via `pip`: ```bash python -m pip install pip-audit ``` ### Third-party packages There are multiple **third-party** packages for `pip-audit`. The matrices and badges below list some of them: [![Packaging status](https://repology.org/badge/vertical-allrepos/python:pip-audit.svg)](https://repology.org/project/python:pip-audit/versions) [![Packaging status](https://repology.org/badge/vertical-allrepos/pip-audit.svg)](https://repology.org/project/pip-audit/versions) [![Conda - Platform](https://img.shields.io/conda/pn/conda-forge/pip-audit?logo=anaconda&style=flat)][#conda-forge-package] [![Conda (channel only)](https://img.shields.io/conda/vn/conda-forge/pip-audit?logo=anaconda&style=flat&color=orange)][#conda-forge-package] [#conda-forge-package]: https://anaconda.org/conda-forge/pip-audit In particular, `pip-audit` can be installed via `conda`: ```bash conda install -c conda-forge pip-audit ``` Third-party packages are **not** directly supported by this project. Please consult your package manager's documentation for more detailed installation guidance. ### GitHub Actions `pip-audit` has [an official GitHub Action](https://github.com/pypa/gh-action-pip-audit)! You can install it from the [GitHub Marketplace](https://github.com/marketplace/actions/gh-action-pip-audit), or add it to your CI manually: ```yaml jobs: pip-audit: steps: - uses: pypa/gh-action-pip-audit@v1.0.0 with: inputs: requirements.txt ``` See the [action documentation](https://github.com/pypa/gh-action-pip-audit/blob/main/README.md) for more details and usage examples. ### `pre-commit` support `pip-audit` has [`pre-commit`](https://pre-commit.com/) support. For example, using `pip-audit` via `pre-commit` to audit a requirements file: ```yaml - repo: https://github.com/pypa/pip-audit rev: v2.10.0 hooks: - id: pip-audit args: ["-r", "requirements.txt"] ci: # Leave pip-audit to only run locally and not in CI # pre-commit.ci does not allow network calls skip: [pip-audit] ``` Any `pip-audit` arguments documented below can be passed. ## Usage You can run `pip-audit` as a standalone program, or via `python -m`: ```bash pip-audit --help python -m pip_audit --help ``` <!-- @begin-pip-audit-help@ --> ``` usage: pip-audit [-h] [-V] [-l] [-r REQUIREMENT] [--locked] [-f FORMAT] [-s SERVICE] [--osv-url OSV_URL] [-d] [-S] [--desc [{on,off,auto}]] [--aliases [{on,off,auto}]] [--cache-dir CACHE_DIR] [--progress-spinner {on,off}] [--ti

Release History

VersionChangesUrgencyDate
2.10.0Imported from PyPI (2.10.0)Low4/21/2026
v2.10.0### Added * `pip-audit` now supports the `--osv-url URL` flag, which can be used to retrieve vulnerabilities from a custom OSV service. This is useful for organizations that host their own mirror of the OSV database, or that have custom OSV records ([#810](https://github.com/pypa/pip-audit/pull/810)) * `pip-audit` now supports the Ecosyste.ms vulnerability service with `--vulnerability-service=esms` ([#903](https://github.com/pypa/pip-audit/pull/903)). ### Changed * The minimum vLow12/1/2025
v2.9.0### Added * `pip-audit` now supports [PEP 751](https://peps.python.org/pep-0751/) lockfiles. These lockfiles can be audited in "project" mode by passing `--locked` to `pip-audit` ([#888](https://github.com/pypa/pip-audit/pull/888)) Low4/7/2025
v2.8.0### Added * `pip-audit` now allows some CLI flags to be configured via environment variables ([#755](https://github.com/pypa/pip-audit/pull/755)) ### Changed * The default cache locations on macOS and Linux now respect each platform's caching directory idioms (e.g. XDG) ([#814](https://github.com/pypa/pip-audit/pull/814)) * The minimum version of Python is now 3.9 ([#846](https://github.com/pypa/pip-audit/pull/846)) Low2/6/2025
v2.7.3### Fixed * Improved handling of temporary files on Windows ([#757](https://github.com/pypa/pip-audit/pull/757)) * Fixed a subprocess deadlock on Windows ([#756](https://github.com/pypa/pip-audit/pull/756)) Low4/30/2024
v2.7.2### Fixed * `pip-audit` now invokes `pip` with `--keyring-provider=subprocess`, partially fixing a regression that was introduced with another authentication fix in 2.6.2. This allows the interior `pip` to use `keyring` to perform third-party index authentication. **Full Changelog**: https://github.com/pypa/pip-audit/compare/v2.7.1...v2.7.2Low2/29/2024
v2.7.1### Fixed * Improved the error returned to users when their default temporary directory lacks execute permissions ([#737](https://github.com/pypa/pip-audit/pull/737)) Low2/12/2024
v2.7.0### Added * `pip-audit` now includes vulnerability aliases when `--format=json` is used, and also includes them in other output formats if specified by adding the flag `--aliases` Low1/11/2024
v2.6.3### Fixed * Removed a misleading warning message that resulted in user confusion ([#719](https://github.com/pypa/pip-audit/pull/719))Low1/8/2024
v2.6.2### Changed * `pip-audit`'s minimum Python version is now 3.8. ### Fixed * Fixed a hang caused by auditing requirements when resolving against an index that requires authentication, causing `pip` to wait indefinitely for credentials ([#707](https://github.com/pypa/pip-audit/pull/707)) Low12/19/2023
v2.6.1### Fixed * Fixed a crash on Windows caused by `pip-audit`'s use of temporary files ([#647](https://github.com/pypa/pip-audit/pull/647)) Low7/24/2023
v2.6.0### Added * Added option to skip dependency resolution via `pip` with the `--disable-pip` flag. This option can only be used with hashed requirements files or when the `--no-deps` flag has been provided ([#610](https://github.com/pypa/pip-audit/pull/610))Low7/2/2023
v2.5.6### Fixed * Fixed a crash caused by incompatible dependency changes ([#617](https://github.com/pypa/pip-audit/pull/617)) Low5/23/2023
v2.5.5### Fixed * Fixed a crash caused by incompatible dependency changes ([#605](https://github.com/pypa/pip-audit/pull/605)) Low5/4/2023
v2.5.4### Changed * Refactored `index-url` option to not override user pip config by default, unless specified ([#565](https://github.com/pypa/pip-audit/pull/565)) ### Fixed * Fixed bug with the `--fix` flag where new requirements were sometimes being appended to requirement files instead of patching the existing requirement ([#577](https://github.com/pypa/pip-audit/pull/577)) * Fixed a crash caused by auditing requirements files that refer to other requirements files ([#568](hLow3/29/2023
v2.5.3### Changed * Further simplified `pip-audit`'s dependency resolution to remove inconsistent behaviour when using hashed requirements or the `--no-deps` flag ([#540](https://github.com/pypa/pip-audit/pull/540)) ### Fixed * Fixed a crash caused by invalid UTF-8 sequences in subprocess outputs ([#572](https://github.com/pypa/pip-audit/pull/572)) Low3/23/2023
v2.5.2### Fixed * Fixed a loose dependency constraint for CycloneDX SBOM generation ([#558](https://github.com/pypa/pip-audit/pull/558))Low3/20/2023
v2.5.1### Fixed * Fixed a crash on Windows caused by multiple open file handles to input requirements ([#551](https://github.com/pypa/pip-audit/pull/551))Low3/17/2023
v2.5.0### Changed * Improved error messaging when a requirements input or indirect dependency has an invalid (non-PEP 440) requirements specifier ([#507](https://github.com/pypa/pip-audit/pull/507)) * `pip-audit`'s handling of dependency resolution has been significantly refactored and simplified ([#523](https://github.com/pypa/pip-audit/pull/523)) ### Fixed * Fixed a potential crash on invalid unicode in subprocess streams ([#536](https://github.com/pypa/pip-audit/pull/536))Low3/16/2023
v2.4.15### Fixed * Fixed an issue where hash checking would fail when using third-party indices ([#462](https://github.com/pypa/pip-audit/pull/462)) * Fixed the behavior of the `--skip-editable` flag, which had regressed with an internal API change ([#499](https://github.com/pypa/pip-audit/pull/499)) * Fixed a dependency resolution bug that can potentially be triggered when multiple packages have the same subdependency ([#488](https://github.com/pypa/pip-audit/pull/488))Low1/31/2023
v2.4.14### Fixed * Fixed a dependency resolution failure caused by incorrect handling of a PEP 440 edge case around prerelease versions ([#477](https://github.com/pypa/pip-audit/pull/477)) Low1/20/2023
v2.4.13### Fixed * Added a lower bound on `packaging` to ensure that non-normalized versions are handled correctly ([#471](https://github.com/pypa/pip-audit/pull/471)) Low1/10/2023
v2.4.12### Fixed * Fixed `pip-audit`'s virtual environment creation and upgrade behavior, preventing spurious vulnerability reports ([#454](https://github.com/pypa/pip-audit/pull/454)) * Users are now warned if a `pip-audit` invocation is ambiguous, e.g. if they've installed `pip-audit` globally but are asking for an audit of a loaded virtual environment ([#451](https://github.com/pypa/pip-audit/pull/451))Low12/29/2022
v2.4.11### Fixed * Fixed a crash triggered when a package specifies an invalid version specifier for its `requires-python` version ([#447](https://github.com/pypa/pip-audit/pull/447))Low12/28/2022
v2.4.10## [2.4.10] ### Fixed * Fixed a crash triggered when no vulnerabilities are found with some configurations ([#437](https://github.com/pypa/pip-audit/pull/437))Low12/15/2022
v2.4.9## [2.4.9] ### Fixed * The `--output` flag will no longer produce an empty file in the event of a failure within `pip-audit` itself, making it easier to distinguish between audit failures being reported by `pip-audit` and `pip-audit`'s own errors ([#432](https://github.com/pypa/pip-audit/pull/432)) * Removed pin on `packaging` now that our dependency pins it for us ([#429](https://github.com/pypa/pip-audit/pull/427))Low12/14/2022
v2.4.8## [2.4.8] ### Fixed * Pin maximum version of `packaging` dependency to avoid installing the new 22.0 version which is incompatible with `pip-requirements-parser` ([#427](https://github.com/pypa/pip-audit/pull/427))Low12/8/2022
v2.4.7### Fixed * Fixed a timestamp parsing bug that occurred with some vulnerability reports provided by the OSV service ([#416](https://github.com/pypa/pip-audit/issues/416))Low11/28/2022
v2.4.6### Fixed * Fixed an incorrect interaction between `--desc=auto` and `--format=json`; `--desc=auto` now includes the description in the generated JSON report, as intended ([#399](https://github.com/pypa/pip-audit/pull/399)) * Fixed a bug in dependency resolution with third-party indices where relative URLs were not resolved correctly ([#411](https://github.com/pypa/pip-audit/pull/411), [#412](https://github.com/pypa/pip-audit/pull/412))Low11/21/2022
v2.4.5### Fixed * Fixed an issue where audits done with the PyPI vulnerability service (the default) were not correctly filtered by "withdrawn" status; "withdrawn" vulnerabilities are now excluded ([#393](https://github.com/pypa/pip-audit/pull/393)) * Fixed an issue where audits done with the OSV vulnerability service (`-s osv`) were not correctly filtered by "withdrawn" status; "withdrawn" vulnerabilities are now excluded ([#386](https://github.com/pypa/pip-audit/pull/386)) * Low10/31/2022
v2.4.4### Changed * `pip-audit` is now a PyPA member project, and lives under [`pypa/pip-audit`](https://github.com/pypa/pip-audit)! * Improved error message for when unpinned URL requirements are found during an audit with the `--no-deps` flag ([#355](https://github.com/pypa/pip-audit/pull/355)) ### Fixed * Fixed an issue where packages on PyPI with no published versions trigger a dependency resolution failure instead of being skipped ([#357](https://github.com/pypa/pip-audLow9/1/2022
v2.4.3## Fixed * Fixed a regression in requirements auditing that was introduced during the move from pip-api to pip-requirements-parser where editable installs without an egg fragment would cause audits to crash (https://github.com/trailofbits/pip-audit/pull/331)Low7/25/2022
v2.4.2### Fixed * CLI: the --format=markdown and --format=columns output formats are no longer broken by long vulnerability descriptions from the OSV and PyPI vulnerability sources (https://github.com/trailofbits/pip-audit/pull/323)Low7/21/2022
v2.4.1## [2.4.1] ### Fixed * Fixed a breakage in hash-checking mode caused by a [change to the PyPI JSON API](https://discuss.python.org/t/backwards-incompatible-change-to-pypi-json-api/17154) ([#318](https://github.com/trailofbits/pip-audit/pull/318))Low7/7/2022
v2.4.0## [2.4.0] ### Added * Output formats: `pip-audit` now supports a Markdown format (`--format=markdown`) which renders results as a set of Markdown tables. ([#312](https://github.com/trailofbits/pip-audit/pull/312))Low6/30/2022
v2.3.4Release v2.3.4Low6/24/2022
v2.3.3### Changed * CLI: `pip-audit` now warns on the combination of `-s osv` and `--require-hashes`, notifying users that only the PyPI service can fully verify hashes ([#298](https://github.com/trailofbits/pip-audit/pull/298)) ### Fixed * CLI/Dependency sources: `--cache-dir=...` and other flags that affect dependency resolver behavior now work correctly when auditing a `pyproject.toml` dependency source ([#300](https://github.com/trailofbits/pip-audit/pull/300))Low6/15/2022
v2.3.2### Changed * CLI: `pip-audit`'s progress spinner has been refactored to make it faster and more responsive ([#283](https://github.com/trailofbits/pip-audit/pull/283)) * CLI, Vulnerability sources: the error message used to report connection failures to vulnerability sources was improved ([#287](https://github.com/trailofbits/pip-audit/pull/287)) * Vulnerability sources: the OSV service is now more resilient to schema changes ([#288](https://github.com/trailofbits/pip-audLow6/14/2022
v2.3.1## [2.3.1](https://github.com/trailofbits/pip-audit/compare/v2.3.0...v2.3.1) - 2022-05-24 ### Fixed * CLI: A bug causing the terminal's cursor to disappear on some versions of CPython was fixed (https://github.com/trailofbits/pip-audit/issues/280)Low5/24/2022
v2.3.0## [2.3.0](https://github.com/trailofbits/pip-audit/compare/v2.2.1...v2.3.0) - 2022-05-18 ### Added CLI: The --ignore-vuln option has been added, allowing users to specify vulnerability IDs to ignore during the final report (https://github.com/trailofbits/pip-audit/pull/275) CLI: The --no-deps flag has been added, allowing users to skip dependency resolution entirely when pip-audit is used in requirements mode (https://github.com/trailofbits/pip-audit/pull/255)Low5/18/2022
v2.2.1Release v2.2.1Low5/2/2022
v2.2.0## 2.2.0 - 2022-05-02 ### Added * CLI: The `--output` option has been added, allowing users to specify a file to write output to. The default behavior of writing to `stdout` is unchanged ([#262](https://github.com/trailofbits/pip-audit/pull/262)) ### Fixed * Vulnerability sources: A bug caused by insufficient version normalization was fixed ([#263](https://github.com/trailofbits/pip-audit/pull/263))Low5/2/2022
v2.1.1[2.1.1](https://github.com/trailofbits/pip-audit/compare/v2.1.0...v2.1.1)[](https://github.com/trailofbits/pip-audit/blob/main/CHANGELOG.md#fixed) - 2022-03-29 Fixed * Dependency sources: A bug caused by ambiguous parses of source distribution files was fixed ([#249](https://github.com/trailofbits/pip-audit/pull/249)) [2.1.1]: https://github.com/trailofbits/pip-audit/compare/v2.1.0...v2.1.1 Low3/29/2022
v2.1.0[2.1.0](https://github.com/trailofbits/pip-audit/compare/v2.0.0...v2.1.0)[](https://github.com/trailofbits/pip-audit/blob/main/CHANGELOG.md#added) - 2022-03-11 Added * CLI: The --skip-editable flag has been added, allowing users to skip local packages or parsed requirements (via -r) that are marked as editable (https://github.com/trailofbits/pip-audit/pull/244) * CLI: pip-audit can audit projects that list their dependencies in pyproject.toml files, via `pip-audit <dir>` (https://githubLow3/11/2022
v2.0.0[2.0.0](https://github.com/trailofbits/pip-audit/compare/v1.1.2...v2.0.0)[](https://github.com/trailofbits/pip-audit/blob/main/CHANGELOG.md#added) - 2022-02-18 Added * CLI: The --fix flag has been added, allowing users to attempt to automatically upgrade any vulnerable dependencies to the first safe version available ([#212](https://github.com/trailofbits/pip-audit/pull/212), [#222](https://github.com/trailofbits/pip-audit/pull/222)) * CLI: The combination of --fix and --dry-run is now suLow2/18/2022
v1.1.2Release v1.1.2Low1/13/2022
v1.1.1Release v1.1.1Low12/7/2021
v1.1.0Release v1.1.0Low12/6/2021
v1.0.1Release v1.0.1Low12/2/2021
v1.0.0Release v1.0.0Low12/1/2021
v0.0.9Release v0.0.9Low12/1/2021

Dependencies & License Audit

Loading dependencies...

Similar Packages

pre-commitA framework for managing and maintaining multi-language pre-commit hooks.v4.6.0
azure-core-tracing-opentelemetryMicrosoft Azure Azure Core OpenTelemetry plugin Library for Pythonazure-template_0.1.0b6187637
spdx-toolsSPDX parser and tools.0.8.5
lacesDjango components that know how to render themselves.0.1.2
django-tasksA backport of Django's built in Tasks framework0.12.0