Support extras statements in Python PDM cataloger (#4352)

* fix pdm

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* update json schema

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* fix tests

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* add test for metadata construction

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* add missing test fixture

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* conserve markers

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* update json schema

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* add additional tests

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

---------

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
Alex Goodman
2025-11-14 15:13:10 -05:00
committed by GitHub
parent 6a21b5e5e2
commit 7bf7bcc461
11 changed files with 6121 additions and 156 deletions
File diff suppressed because it is too large Load Diff
+71 -6
View File
@@ -1,6 +1,6 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "anchore.io/schema/syft/json/16.0.43/document",
"$id": "anchore.io/schema/syft/json/16.1.0/document",
"$ref": "#/$defs/Document",
"$defs": {
"AlpmDbEntry": {
@@ -3300,6 +3300,23 @@
],
"description": "PythonPackage represents all captured data for a python egg or wheel package (specifically as outlined in the PyPA core metadata specification https://packaging.python.org/en/latest/specifications/core-metadata/)."
},
"PythonPdmFileEntry": {
"properties": {
"url": {
"type": "string",
"description": "URL is the file download URL"
},
"digest": {
"$ref": "#/$defs/PythonFileDigest",
"description": "Digest is the hash digest of the file hosted at the URL"
}
},
"type": "object",
"required": [
"url",
"digest"
]
},
"PythonPdmLockEntry": {
"properties": {
"summary": {
@@ -3308,27 +3325,75 @@
},
"files": {
"items": {
"$ref": "#/$defs/PythonFileRecord"
"$ref": "#/$defs/PythonPdmFileEntry"
},
"type": "array",
"description": "Files are the package files with their paths and hash digests"
"description": "Files are the package files with their paths and hash digests (for the base package without extras)"
},
"marker": {
"type": "string",
"description": "Marker is the \"environment\" --conditional expressions that determine whether a package should be installed based on the runtime environment"
},
"requiresPython": {
"type": "string",
"description": "RequiresPython specifies the Python version requirement (e.g., \"\u003e=3.6\")."
},
"dependencies": {
"items": {
"type": "string"
},
"type": "array",
"description": "Dependencies are the dependency specifications, without environment qualifiers"
"description": "Dependencies are the dependency specifications for the base package (without extras)"
},
"extras": {
"items": {
"$ref": "#/$defs/PythonPdmLockExtraVariant"
},
"type": "array",
"description": "Extras contains variants for different extras combinations (PDM may have multiple entries per package)"
}
},
"type": "object",
"required": [
"summary",
"files",
"dependencies"
"files"
],
"description": "PythonPdmLockEntry represents a single package entry within a pdm.lock file."
},
"PythonPdmLockExtraVariant": {
"properties": {
"extras": {
"items": {
"type": "string"
},
"type": "array",
"description": "Extras are the optional extras enabled for this variant (e.g., [\"toml\"], [\"dev\"], or [\"toml\", \"dev\"])"
},
"dependencies": {
"items": {
"type": "string"
},
"type": "array",
"description": "Dependencies are the dependencies specific to this extras variant"
},
"files": {
"items": {
"$ref": "#/$defs/PythonPdmFileEntry"
},
"type": "array",
"description": "Files are the package files specific to this variant (only populated if different from base)"
},
"marker": {
"type": "string",
"description": "Marker is the environment conditional expression for this variant (e.g., \"python_version \u003c \\\"3.11\\\"\")"
}
},
"type": "object",
"required": [
"extras"
],
"description": "PythonPdmLockExtraVariant represents a specific extras combination variant within a PDM lock file."
},
"PythonPipRequirementsEntry": {
"properties": {
"name": {