DependencyTrack / DependencyTrack/dependency-track

PyPI MetaAnalyzer is not compliant with the Simple Repository API (PEP 503|691)

Open
#5,735 0 comments 0 reactions 0 assignees View on GitHub
defect in triage
Dominant language
Java
Stars
4.2k
Forks
811
Avg merge
8h 39m
Merged PRs (30d)
237

Description

### Current Behavior

PyPI MetaAnalyzer is not compliant with the Simple Repository API (PEP 503|691)

Dependency-Track’s PypiMetaAnalyzer retrieves metadata from the legacy PyPI-specific endpoint:
`/pypi//json`

It then extracts:
`info.version` → used as `latestVersion`
`releases[latest][0].upload_time` → used as `publishedTimestamp`

This endpoint is not part of Python packaging standard.
As a result The analyzer does not work with PyPI-compatible registries such as GitLab PyPI Registry

The analyzer ignores the officially standardized interface defined by the Simple Repository API.

### Steps to Reproduce

Configure Dependency-Track to use any PyPI-compatible registry that does not implement `/pypi//json` (e.g., GitLab PyPI Registry), analyze a `pkg:pypi/` component, and observe that Dependency-Track requests `/pypi//json` and fails to populate `latestVersion` and `publishedTimestamp`.

### Expected Behavior

Dependency-Track should retrieve Python package metadata using the Simple Repository API, as defined by the Python packaging specifications:
https://packaging.python.org/en/latest/specifications/simple-repository-api/

Specifically, the PypiMetaAnalyzer should:
* Request package metadata from: `/simple//`
Use HTTP content negotiation with an Accept header such as:
`application/vnd.pypi.simple.v1+json`
`application/vnd.pypi.simple.v1+html;q=0.2`
`text/html;q=0.01`
* Choose parsing logic strictly based on the Content-Type header

Support both standardized response formats:
* JSON form (PEP 691)
* HTML form (PEP 503)

Compute:
latestVersion from: the versions[] field if present (PEP 700), otherwise versions inferred from distribution filenames ?.
Prefer non-yanked files unless all files are yanked.
Set publishedTimestamp from JSON upload-time fields (PEP 691) ?

### Dependency-Track Version

4.13.6

### Dependency-Track Distribution

Container Image

### Database Server

PostgreSQL

### Database Server Version

_No response_

### Browser

Google Chrome

### Checklist

- [x] I have read and understand the [contributing guidelines](https://github.com/DependencyTrack/dependency-track/blob/master/CONTRIBUTING.md#filing-issues)
- [x] I have checked the [existing issues](https://github.com/DependencyTrack/dependency-track/issues) for whether this defect was already reported

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.