Skip to content

fix(pipenv): strip === operator from locked versions - #1156

Open
VfourTwenty wants to merge 3 commits into
CycloneDX:mainfrom
VfourTwenty:fix/1153-pipenv-arbitrary-equality-pin
Open

VfourTwenty wants to merge 3 commits into
CycloneDX:mainfrom
VfourTwenty:fix/1153-pipenv-arbitrary-equality-pin

Conversation

@VfourTwenty

Copy link
Copy Markdown

Description

Pipfile.lock can contain arbitrary-equality pins like "version": "===0.4.6". pipenv writes them when a === pinned entry has a marker that doesn't match the locking host (e.g. sys_platform == 'win32' locked on linux). _make_bom cut the version with [2:] which only works for ==, so the component came out as version =0.4.6 and purl pkg:pypi/colorama@%3D0.4.6, which doesn't match anything in vuln databases.

  • Replaced [2:] with .lstrip('=') in cyclonedx_py/_internal/pipenv.py, so == and === pins both give the bare version
  • Added fixture tests/_data/infiles/pipenv/arbitrary-equality (colorama ===0.4.6 with a win32 marker, lockfile generated with real pipenv lock on linux) + its snapshots
  • No existing snapshots changed, output for == pins stays the same

Ran tests.integration.test_cli_pipenv locally: 185 pass, and with the old pipenv.py the 14 new cases fail with =0.4.6 / %3D0.4.6.

i didn't touch the bom-ref (colorama===0.4.6). it's only an internal id that links components inside the document, vuln lookups go by purl / version, which are fixed now.

Resolves or fixes issue: #1153

AI Tool Disclosure

  • My contribution does not include any AI-generated content
  • My contribution includes AI-generated content, as disclosed below:
    • AI Tools: Claude
    • LLMs and versions: Claude Opus 5.5
    • Prompts: used it to trace the root cause of #1153, draft the one-line fix and generate the fixture + snapshots the way the repo's snapshot README describes. reviewed the diff myself and re-ran the pipenv tests with and without the fix in docker

Affirmation

Signed-off-by: VfourTwenty <132915930+VfourTwenty@users.noreply.github.com>
@VfourTwenty
VfourTwenty requested a review from a team as a code owner November 26, 2026 09:13
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity ✅ 0 (≤ 20 complexity)
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Co-authored-by: Jan Kowalleck <jan.kowalleck@gmail.com>
Signed-off-by: VfourTwenty <132915930+VfourTwenty@users.noreply.github.com>
This reverts commit bef0b6f.

Signed-off-by: VfourTwenty <132915930+VfourTwenty@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working source: pipenv

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] cyclonedx-py pipenv leaves a leading = in component version and PURL for === pins in Pipfile.lock

2 participants