Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(poetry): handle package names in a case-insensitive manner #6817

Closed
knqyf263 opened this issue May 29, 2024 · 2 comments · Fixed by #6852
Closed

fix(poetry): handle package names in a case-insensitive manner #6817

knqyf263 opened this issue May 29, 2024 · 2 comments · Fixed by #6852
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. scan/sbom Issues relating to SBOM
Milestone

Comments

@knqyf263
Copy link
Collaborator

Description

It looks like package names in pyproject.toml are lowercased in poetry.lock.

$ cat pyproject.toml
[tool.poetry]
name = "poetry-test"
version = "0.1.0"
description = ""
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.11"
pytest = ">=2.8.0,<=6.2.5"
pytest-httpbin = "==1.0.0"
pytest-mock = "==2.0.0"
httpbin = "==0.7.0"
Flask = ">=1.0,<2.0"
trustme = { version = "*"}
wheel = { version = "*"}


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

$ grep -B1 -A4 'name = "flask"' poetry.lock
[[package]]
name = "flask"
version = "1.1.2"
description = "A simple framework for building complex web applications."
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"

Flask and flask don't match here, causing the wrong relationship (Flask is recognized as an indirect dependency).

if _, ok := p[pkg.Name]; ok {
app.Packages[i].Relationship = types.RelationshipDirect
} else {
app.Packages[i].Indirect = true
app.Packages[i].Relationship = types.RelationshipIndirect
}

@knqyf263 knqyf263 added kind/bug Categorizes issue or PR as related to a bug. scan/sbom Issues relating to SBOM labels May 29, 2024
@knqyf263 knqyf263 added this to the v0.53.0 milestone May 29, 2024
@nikpivkin
Copy link
Contributor

@DmitriyLewen By the way, the PEP says that package name comparisons must consider hyphens and underscores to be equivalent. https://peps.python.org/pep-0426/#name

@DmitriyLewen
Copy link
Contributor

Wow, thanks! I will check this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. scan/sbom Issues relating to SBOM
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants