Skip to content

pipenv subcommand emits insufficient VCS PURLs for affected dependencies in Pipfile.lock #1152

In progress

Description

@trackoor

Describe the bug

When generating an SBOM from Pipfile.lock with cyclonedx-py pipenv, local file and path dependencies omit purl, but local VCS dependencies (such as "git": "git+file:///..." or "git": "file:///..." written by pipenv lock for a local Git repository) are emitted with a pkg:pypi/... PURL (and a bare pkg:pypi/<name> when --short-PURLs is passed).

By contrast, cyclonedx-py environment omits purl when PEP 610 direct_url.json has a file:// URL, including local VCS installs.

To Reproduce

  1. Create Pipfile.lock (matching the lockfile entry written by pipenv for a local Git repository):
{
    "_meta": {
        "hash": {
            "sha256": "ebffa69a1fa192d1cef7cb42ad79231ca976565c5ce371a70160b3048d3cbc06"
        },
        "pipfile-spec": 6,
        "requires": {},
        "sources": [
            {
                "name": "pypi",
                "url": "https://pypi.org/simple",
                "verify_ssl": true
            }
        ]
    },
    "default": {
        "my-project": {
            "git": "git+file:///home/user/projects/my-project",
            "ref": "da59ad000d1405eaecd557175e29083a87d19f7c"
        }
    },
    "develop": {}
}
  1. Run:
cyclonedx-py pipenv . --output-reproducible

Expected behavior

purl is omitted for my-project because its VCS location points to a local file:// repository rather than a published package, matching local file/path entries in cyclonedx-py pipenv and local file:// VCS installs in cyclonedx-py environment.

Screenshots or output-paste

Actual output (components section):

  "components": [
    {
      "bom-ref": "my-project",
      "externalReferences": [
        {
          "comment": "from git",
          "type": "vcs",
          "url": "git+file:///home/user/projects/my-project#da59ad000d1405eaecd557175e29083a87d19f7c"
        }
      ],
      "name": "my-project",
      "properties": [
        {
          "name": "cdx:pipenv:category",
          "value": "default"
        }
      ],
      "purl": "pkg:pypi/my-project?vcs_url=git%2Bfile:///home/user/projects/my-project%40da59ad000d1405eaecd557175e29083a87d19f7c",
      "type": "library"
    }
  ],

(With --short-PURLs, purl becomes "pkg:pypi/my-project".)

Environment

  • cyclonedx-py version: 9.0.0 (PyPI cyclonedx-bom==9.0.0) and main (087a93338905b6c3b4169cb8c35721b442c23ae4)
  • Python version: Python 3.11.2
  • OS: Debian GNU/Linux 12 (bookworm), x86_64

Additional context

In cyclonedx_py/_internal/pipenv.py, PipenvBB.__is_local() already checks maybe_schema == 'file' or maybe_schema.endswith('+file') (with # - git+file:///home/user/projects/MyProject in its inline comment), but its initial if 'file' in data: / elif 'path' in data: guard returns False without inspecting VCS keys via self.__package_vcs(data) (git, hg, svn, bzr).

Contribution

  • I am willing to provide a fix
  • I will wait until somebody else fixes it

Credit: https://ucsbplse.github.io/

Activity

  1. changed the title [-][BUG] pipenv subcommand emits pkg:pypi/ PURLs for local VCS dependencies in Pipfile.lock[/-] [+]pipenv subcommand emits VCS PURLs fir affected dependencies in Pipfile.lock[/+] on Nov 26, 2026
  2. added
    enhancement
    on Nov 26, 2026
  3. jkowalleck commented on Nov 26, 2026

    @jkowalleck
    Member

    not a bug, more of a feature lack

  4. pinsara23 commented on Nov 26, 2026

    @pinsara23
    Contributor

    Hi, I'd like to work on this. In PipenvBB.__is_local(), I'd fall through to __package_vcs(data) when there's no file/path key, so VCS URLs go through the existing file/+file scheme check. Remote VCS deps (git+https://…) keep their PURL. For tests, should I add a git+file entry to the existing pipenv/local fixture, or create a new fixture?

  5. changed the title [-]pipenv subcommand emits VCS PURLs fir affected dependencies in Pipfile.lock[/-] [+]pipenv subcommand emits VCS PURLs for affected dependencies in Pipfile.lock[/+] on Nov 27, 2026
  6. changed the title [-]pipenv subcommand emits VCS PURLs for affected dependencies in Pipfile.lock[/-] [+]pipenv subcommand emits insufficient VCS PURLs for affected dependencies in Pipfile.lock[/+] on Nov 30, 2026
  7. jkowalleck commented on Nov 30, 2026

    @jkowalleck
    Member

    This proposed solution shall be discussed.

    proposed solution

    for VCS Purls:

  8. pinsara23 commented on Nov 30, 2026

    @pinsara23
    Contributor

    Thanks, that makes sense. I'll change the approach: keep the PURL for local VCS dependencies, but omit the vcs_url qualifier when the VCS location is local (file: / +file: schemes). Remote VCS dependencies keep vcs_url as before. I'll update this PR accordingly once the testbed PR is merged.

  9. jkowalleck commented on Nov 30, 2026

    @jkowalleck
    Member

    new test data will be added per #1163

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementhelp wantedsource: pipenv

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions