Repository navigation
Conversation
The implicit distribution URLs built from an index (requirements --index-url/--extra-index-url, Pipfile.lock indexes, poetry legacy sources) interpolated the raw requirement name. PEP 503 requires clients to request /<normalized-name>/ and makes redirects optional, so names such as Flask_SQLAlchemy, PyYAML or ruamel.yaml.clib produced URLs that 404 on static PEP 503 mirrors and local directories. Apply normalize_packagename() to those URL path segments. Component names and PURLs are unchanged. fixes CycloneDX#1154 Signed-off-by: Julio César Suástegui <5745504+juliosuas@users.noreply.github.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | ✅ 0 (≤ 20 complexity) |
| Duplication | 0 |
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.
jkowalleck
left a comment
There was a problem hiding this comment.
Implementation and tests look good. 👍
just very litle refactoring needed to streamline things
| # url based on https://warehouse.pypa.io/api-reference/legacy.html | ||
| # PEP 503 requires clients to request the normalized project name | ||
| # see https://packaging.python.org/en/latest/specifications/simple-repository-api/#project-detail | ||
| simple_name = normalize_packagename(name) if name else name |
There was a problem hiding this comment.
lets call it name_normalized
There was a problem hiding this comment.
lets rename this to normalize-packagename.txt - aligned with tests/_data/infiles/pipenv/normalize-packagename
Call the normalized package name name_normalized in _make_component, and rename the requirements fixture to normalize-packagename.txt so it matches tests/_data/infiles/pipenv/normalize-packagename. Signed-off-by: Julio César Suástegui <5745504+juliosuas@users.noreply.github.com>
|
@jkowalleck thanks! Both done in e851746: |
Description
Implicit distribution URLs built from a package index used the raw requirement name (
.../simple/Flask_SQLAlchemy/). PEP 503 requires clients to request/<normalized-name>/and redirects are optional, so these URLs 404 on static PEP 503 mirrors (S3/Nginx) and local directories.This PR applies the existing
normalize_packagename()helper to the URL path segment in:requirements:implicit dist urlandimplicit dist extra-urlpipenv:from explicit index/from implicit index: pypipoetry:from legacy-apiComponent
nameandpurlare unchanged.Resolves #1154
Tests
tests/_data/infiles/requirements/unnormalized-names.txt(with--index-urland--extra-index-url) and its snapshots.ruamel.yaml.clib->ruamel-yaml-clib).python -m unittest discover -t . -s tests: 1463 tests, only theTestCliEnvironment.setUpClasstestbed error that also occurs onmainin my sandbox (it needs network to build the venv testbeds). flake8 and mypy clean.AI Tool Disclosure
Affirmation