Skip to content

Enable Pipenv dev dependency scanning

Oscar Tovar requested to merge hacks4oats/enable-pipenv-dev-packages-scanning into v4

What does this MR do?

  • The piplock parser has been registered in the gemnasium-python main package. This parser is capable of scanning and filtering out dev dependencies found in Pipfile.lock files.
  • The pipenv builder has been updated so that it no longer returns a pipdeptree graph export. Instead, it returns the path to the Pipfile.lock of the project, so that the project can scan dev dependencies.
    • If a project does contain an existing Pipfile.lock file, the builder will run pipenv sync --dev to ensure that we do not update the lock file when installing the dependencies. See the sync subcommand documentation for details.
    • If a project does not contain an existing Pipfile.lock file, the builder will run pipenv install --dev to ensure that we create a lock file when installing the dependencies. See the install subcommand documentation for details.
  • A hack was added to the pipenv builder so that the names used for dependencies does not change when switching from scanning the graph export to scanning the Pipfile.lock.
  • Dependencies declared in the [dev-packages] section of a Pipfile.lock are scanned by default. The parser respects the setting declared by DS_INCLUDE_DEV_DEPENDENCIES, so a false value will exclude these dependencies.
  • The pipfile-lock test fixture now includes a development dependency to ensure that we skip the direct and indirect dev dependencies when toggling DS_INCLUDE_DEV_DEPENDENCIES to false in image tests.
  • The test project has been updated so that dependency scanning on tests/python-pipenv matches the reports in qa/expect/python-pipenv/.

IMPORTANT (updated)

The move to generating and parsing Pipfile.lock files has impacted the package names in the generated reports i.e. gl-dependency-scanning-report.json and gl-sbom-pypi-pip.cdx.json. This is because Pipenv applies PEP8 standards to the packages fetched (which is also what PyPi does).

The names are currently transformed by the builder to the values previously used. This is a temporary addition until the Rails backend takes care of deduplicating findings generated by either the canonical name or the normalized names.

What are the relevant issue numbers?

Does this MR meet the acceptance criteria?

Edited by Fabien Catteau

Merge request reports