Add ability to optionally ignore dev dependencies in Poetry projects
Release notes
TODO
Problem to solve
When Dependency Scanning runs on Poetry projects, it will always include development dependencies. NPM projects with dependency scanning respect the option to include or exclude devDependencies. This was done to provide the ability to view what issues exist only within production. For Poetry, this would be the results of production installs i.e. poetry install --no-dev. This issue aims to bring optional development dependency inclusion to Poetry dependency scanning.
For additional context, the Poetry package manager propagates the dev context when resolving transitive dependencies. This is supported by the pyproject.toml and poetry.lock found in the python-poetry project. The pyproject.toml file only includes the pytest dev dependency but the lock file includes pytest and all of it's dependencies as dev dependencies.
Intended users
- Sasha (Software Developer)
- Priyanka (Platform Engineer)
- Sam (Security Analyst)
- Alex (Security Operations Engineer)
Proposal
- Add
Categorytopoetry.docPackageto capture package category. - Update
poetry.Parseto only add a development dependency if theopts.IncludeDevis true.
Documentation
- Update the documentation in Configuring specific analyzers used by dependency scanning to mention support for Poetry projects.
Availability & Testing
-
Poetry unit tests should be updated to include cases where the
IncludeDevoption is set to false. -
Poetry integrations tests should be updated to include cases where
DS_INCLUDE_DEV_DEPENDENCIESis set tofalse.
Implementation Plan
-
Update Gemnasium - Add
Categorytopoetry.docPackageto capture package category. - Update
poetry.Parseto skip ifopts.IncludeDevisfalseandpkg.Category == "dev". - Add unit tests to the
poetryparser to verify that the category field is extracted. - Update Poetry integrations tests to test
DS_INCLUDE_DEV_DEPENDENCIES="false".
- Add
-
Update Documentation in Configuring specific analyzers used by dependency scanning to mention support for optionally including development dependencies found in poetry.lockfiles.