Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

VEX product purl detected from pyproject.toml keeps the raw project name (pkg:pypi/My_Service) instead of the normalized pypi name

Đã đóng Phù hợp với người mới
#1,547 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Một pull request liên quan đã được merge.

  • #1577 của @mikolalysenko — đã merge

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
80/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python, rust
Lĩnh vực
security

Hướng nghiên cứu

Lỗi nằm ở parse_pyproject trong crates/socket-patch-core/src/vex/product.rs (khoảng dòng 157-167), nơi purl pypi được tạo từ tên dự án gốc. Hãy so sánh với nhánh npm và composer trong cùng tệp, vốn đã chuyển tên thành chữ thường, và kiểm tra các hàm hỗ trợ PEP 503 được nêu trong issue. Hoàn thành khi My_Service cho ra pkg:pypi/[email protected] và Demo_Pkg.Core cho ra pkg:pypi/[email protected], kèm một unit test bao phủ cả hai trường hợp.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

agent:triaged bug bughunt pm:poetry priority:p1

[agent] Found by the scheduled Poetry bug-hunt routine (ledger #311).

Summary

When vex (or scan --vex / apply --vex) auto-detects the top-level product from pyproject.toml, it copies the project name verbatim into the purl. A Poetry project named My_Service gets the product pkg:pypi/[email protected], and Demo_Pkg.Core gets pkg:pypi/[email protected]. The purl spec's pypi type says the name must be lowercased with _ replaced by - (PyPI compares names in PEP 503 form, which also maps . to -). So the expected products are pkg:pypi/[email protected] and pkg:pypi/[email protected] (demo-pkg-core in full PEP 503 form).

The npm and composer branches of the same detector already lowercase their names (product.rs, e.g. parse_composer_json), and the rest of the codebase compares PyPI names in PEP 503 form (crawlers/fuzzy_match.rs, crawlers/hatch_env.rs). Only the pyproject branch skips it.

Impact

An OpenVEX consumer matches products[].@id against the product identifier in the SBOM or scan it is applied to. SBOM generators emit the normalized pypi purl, so a VEX document saying pkg:pypi/My_Service@… won't match the project by exact purl, and its not_affected statements are silently ignored. That affects every Python project whose name has uppercase letters or _, which is common: Poetry, PDM and hatch all accept and preserve such names. It isn't Poetry-specific; any pyproject-based product goes through parse_pyproject. --vex-product / --product work around it.

Repro (Linux, main fc1b4f9)

Uses a local mock of the patch API serving one patched six-1.16.0 wheel. The same result comes from any pypi patch.

# Poetry 2.5.1, PEP 621 layout, agent mode + standalone vex
mkdir proj && cd proj
printf '[project]\nname = "My_Service"\nversion = "1.2.0"\nrequires-python = ">=3.9"\ndependencies = ["six==1.16.0"]\n\n[tool.poetry]\npackage-mode = false\n' > pyproject.toml
POETRY_VIRTUALENVS_IN_PROJECT=true poetry lock && poetry install
socket-patch scan --mode agent --json --yes --api-url $MOCK --api-token x --org test-org
socket-patch vex -O v.json --json --api-url $MOCK --api-token x --org test-org
jq -r '.statements[].products[]."@id"' v.json
# → pkg:pypi/[email protected]      (expected pkg:pypi/[email protected])

# Poetry 1.8.5, legacy [tool.poetry] layout, hosted + same-run VEX
#   [tool.poetry] name = "My_Service", version = "0.1.0", six = "1.16.0"
socket-patch scan --mode hosted --vex out.vex.json --json --yes …
# → pkg:pypi/[email protected]

# Poetry 2.5.1, [tool.poetry] name = "Demo_Pkg.Core"
# → pkg:pypi/[email protected]

For reference, packaging.utils.canonicalize_name("My_Service") is my-service.

Expected vs actual

  • Expected: CLI_CONTRACT.md / product.rs's module doc say pyproject.toml maps to pkg:pypi/<name>@<version>, and a pypi purl's name is the normalized one (purl spec, pypi type: lowercase, _ → -), as the component purls in the same document already are (pkg:pypi/[email protected]).
  • Actual: the name is emitted byte for byte as written in [project].name / [tool.poetry].name.

OS × version

OS Poetry Layout Path Result
Linux 1.8.5 [tool.poetry] scan --mode hosted --vex reproduces
Linux 2.5.1 [project] agent scan + vex reproduces
Linux 2.5.1 [tool.poetry] scan --mode hosted --vex reproduces
macOS / Windows any any — not run (the code path is OS-independent string handling)

Suspect code

crates/socket-patch-core/src/vex/product.rs:157-167 (parse_pyproject builds format!("pkg:pypi/{name}@{version}") from pyproject_name_version without normalizing). The PEP 503 helper consolidated under #883 could be reused here.

Ngôn ngữ chính
Rust
Star
8
Fork
1
Merge trung bình
16 giờ 18 phút
Pull request đã merge (30 ngày)
587

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của SocketDev/socket-patch

Tất cả issue của SocketDev/socket-patch

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.