Files
trivy/docs/docs/coverage/language/python.md
Teppei Fukuda a4e981b4ec docs: add coverage (#4954)
* docs: add coverage

* add more pages

* add dart, dotnet, elixir languages.

* add C, ruby, cocoapods. Update links

* rename headers for dart and elixir

* docs: add Google Distroless and Photon OS

* docs: add IaC

* docs: put vulnerability into a single page

* fixed broken links

* docs: add coverage overview

* update some links

* add note about arch for Rocky linux

* docs: fix typo

* fix typo

* docs: add footnotes

* docs: add a link to coverage in the license section

* docs: add a conversion table

* docs: get aligned

---------

Co-authored-by: DmitriyLewen <dmitriy.lewen@smartforce.io>
2023-08-17 08:00:34 +00:00

4.0 KiB

Python

Trivy supports three types of Python package managers: pip, Pipenv and Poetry. The following scanners are supported for package managers.

Package manager SBOM Vulnerability License
pip -
Pipenv -
Poetry -

In addition, Trivy supports three formats of Python packages: egg, wheel and conda. The following scanners are supported for Python packages.

Packaging SBOM Vulnerability License
Egg
Wheel
Conda - -

The following table provides an outline of the features Trivy offers.

Package manager File Transitive dependencies Dev dependencies Dependency graph Position
pip requirements.txt - Include - -
Pipenv Pipfile.lock Include -
Poetry poetry.lock Exclude
Packaging Dependency graph
Egg
Wheel

These may be enabled or disabled depending on the target. See here for the detail.

Package managers

Trivy parses your files generated by package managers in filesystem/repository scanning.

pip

requirements.txt files usually contain only the direct dependencies and not contain the transitive dependencies. Therefore, Trivy scans only for the direct dependencies with requirements.txt.

To detect transitive dependencies as well, you need to generate requirements.txt with pip freeze.

$ cat requirements.txt # it will only find `requests@2.28.2`.
requests==2.28.2 
$ pip install -r requirements.txt
...

$ pip freeze > requirements.txt   
$ cat requirements.txt # it will also find the transitive dependencies of `requests@2.28.2`.
certifi==2022.12.7
charset-normalizer==3.1.0
idna==3.4
PyJWT==2.1.0
requests==2.28.2
urllib3==1.26.15

pip freeze also helps to resolve extras(optional) dependencies (like package[extras]=0.0.0).

requirements.txt files don't contain information about dependencies used for development. Trivy could detect vulnerabilities on the development packages, which not affect your production environment.

License detection is not supported for pip.

Pipenv

Trivy parses Pipfile.lock. Pipfile.lock files don't contain information about dependencies used for development. Trivy could detect vulnerabilities on the development packages, which not affect your production environment.

License detection is not supported for Pipenv.

Poetry

Trivy uses poetry.lock to identify dependencies and find vulnerabilities. To build the correct dependency graph, pyproject.toml also needs to be present next to poetry.lock.

License detection is not supported for Poetry.

Packaging

Trivy parses the manifest files of installed packages in container image scanning and so on. See here for the detail.

Egg

Trivy looks for *.egg-info, *.egg-info/PKG-INFO, *.egg and EGG-INFO/PKG-INFO to identify Python packages.

Wheel

Trivy looks for .dist-info/META-DATA to identify Python packages.