Repository navigation
Description
Description
Trivy builds the Poetry dependency graph from the [package.dependencies] sections of poetry.lock (pkg/dependency/parser/python/poetry/parse.go).
The Poetry analyzer then walks the graph from the direct dependencies in pyproject.toml and marks every package it cannot reach as a development dependency.
Development dependencies are hidden by default (--include-dev-deps shows them), so a package whose edge is lost disappears from the results: from vulnerability scanning and from the SBOM.
An edge is lost in two cases.
Reported in #11318.
1. Array of constraints
When a package requires the same dependency with different constraints for different environment markers, Poetry writes an array of inline tables.
For example, pandas 3 → numpy:
[package.dependencies]
numpy = [
{version = ">=1.26.0", markers = "python_version < \"3.14\""},
{version = ">=2.3.3", markers = "python_version >= \"3.14\""},
]The parser only understands a string (numpy = ">=1.26.0") and a single inline table (numpy = {version = ">=1.26.0", markers = "..."}).
For an array it gets an empty constraint, matching fails, and the edge is dropped.
With --debug:
DEBUG [poetry] Failed to parse poetry dependency err="failed to match version for numpy: python constraint error (): improper specifier: "
Reproduction
mkdir repro-a && cd repro-a
cat > pyproject.toml <<'EOF'
[project]
name = "repro"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = ["pandas>=3"]
EOF
cat > poetry.lock <<'EOF'
[[package]]
name = "numpy"
version = "2.5.3"
optional = false
python-versions = ">=3.12"
groups = ["main"]
files = []
[[package]]
name = "pandas"
version = "3.0.6"
optional = false
python-versions = ">=3.11"
groups = ["main"]
files = []
[package.dependencies]
numpy = [
{version = ">=1.26.0", markers = "python_version < \"3.14\""},
{version = ">=2.3.3", markers = "python_version >= \"3.14\""},
]
[metadata]
lock-version = "2.1"
python-versions = ">=3.12"
content-hash = "0000000000000000000000000000000000000000000000000000000000000000"
EOF
trivy fs --format cyclonedx . | jq -r '.components[] | select(.type == "library") | "\(.name)@\(.version)"'Expected: numpy@2.5.3 and pandas@3.0.6.
Actual: only pandas@3.0.6.
With --include-dev-deps numpy shows up, but the graph has no pandas → numpy edge.
2. Several locked versions of the same package
Poetry can lock several versions of one package, each for its own markers.
For example, with requires-python = ">=3.11" the lock file gets numpy 2.4.6 for Python 3.11 and numpy 2.5.3 for Python 3.12 and later.
The parser links a dependency only to the first locked version that satisfies the constraint.
The other versions get no incoming edges, are treated as development dependencies and are hidden.
This is independent of case 1: the same happens with a plain string constraint that both versions satisfy.
The difficulty is that Trivy does not evaluate markers: it does not know which Python version and platform the project will be installed on.
So the lock file alone does not tell which of the locked versions will actually be installed.
Reproduction
mkdir repro-b && cd repro-b
cat > pyproject.toml <<'EOF'
[project]
name = "repro"
version = "0.1.0"
requires-python = ">=3.11"
dependencies = ["pandas>=3"]
EOF
cat > poetry.lock <<'EOF'
[[package]]
name = "numpy"
version = "2.4.6"
optional = false
python-versions = ">=3.11"
groups = ["main"]
markers = "python_version == \"3.11\""
files = []
[[package]]
name = "numpy"
version = "2.5.3"
optional = false
python-versions = ">=3.12"
groups = ["main"]
markers = "python_version >= \"3.12\""
files = []
[[package]]
name = "pandas"
version = "3.0.6"
optional = false
python-versions = ">=3.11"
groups = ["main"]
files = []
[package.dependencies]
numpy = ">=1.26.0"
[metadata]
lock-version = "2.1"
python-versions = ">=3.11"
content-hash = "0000000000000000000000000000000000000000000000000000000000000000"
EOF
trivy fs --format cyclonedx . | jq -r '.components[] | select(.type == "library") | "\(.name)@\(.version)"'Expected: numpy@2.4.6, numpy@2.5.3 and pandas@3.0.6.
Actual: numpy@2.4.6 and pandas@3.0.6.
Environment
Reproduced with Trivy 0.76.2 and on the current main.
Related
- Poetry array-form dependency constraints omit NumPy from the default SBOM #11318: the original report.
- fix(python): parse poetry dependencies with marker-specific constraints #11058: a closed PR that fixes case 1.
Activity
lxcxjxhx commentedon Nov 26, 2026
I am picking up case 1 (array of constraints) from this report; case 2 (several locked versions of one package) needs marker evaluation, which Trivy does not do, so I am leaving it out of the PR.
Measured on \main\ (f94c2ef) with the pandas->numpy lock file below, before/after the parser change:
before: deps = [] after: deps = [{pandas@3.0.6 [numpy@2.5.3]}]No change to any other test case in \pkg/dependency/parser/python/poetry.
juliosuas commentedon Nov 26, 2026
Hi @DmitriyLewen, if nobody on the team has started on this I'd be happy to take it. Approach:
parseDependencyreturns all matching IDs; constraints are read from all three forms (string, inline table, array of inline tables, skipping entries withoutversionsuch as path/git); every locked version that satisfies any constraint gets an edge, because markers aren't evaluated. I'd add both reproductions from the issue as parser testdata and as analyzer testdata (checking thatnumpystays a non-dev indirect dependency). Does linking every matching version match what you had in mind for case 2?DmitriyLewen commentedon Nov 27, 2026
Hi @lxcxjxhx , @juliosuas ,
sueun-dev has already worked on this task (he previously prepared a fix and opened a discussion). He mentioned he was ready to reopen the PR, so I am waiting for his reply.
If there is no response from him in the near future, we will reassign the issue.
Regards, Dmitriy