Switch to Trusted Publishing for package upload to PyPI in CI
Chưa có ai nhận issue này.
Đá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
- 68/100
Hướng nghiên cứu
Bắt đầu với .github/workflows/release.yml và kiểm tra job publish, đặc biệt là bước Upload to PyPI của job này. Cấu hình GitHub environment và đăng ký PyPI tương ứng, sau đó cập nhật quyền của job và xóa password argument. Hoàn thành khi các bản release sử dụng Trusted Publishing với attestations thay cho PyPI token.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Trusted publishing (with attestations) is currently suggested as good practice to ensure confidence that what users download from PyPI is the same artifact that was generated in GitHub CI, meaning that what I see in GitHub is the same as what is installed - handy for auditing. It also avoids the presence of PyPI tokens as 'secrets' in the CI, which can be exfiltrated by bad actors.
Following the recent litellm supply chain attack this week, I would like to express my support for this*. The uvloop package is one of 16 packages in the top 500 PyPI packages (by downloads) which use the pypa/gh-action-pypi-publish action but have not yet upgraded it to use Trusted Publishing: this is 'low hanging fruit' in terms of making Python a more secure programming environment.
Instead of using the stored secret token, GitHub vouches for the upload, and PyPI checks the uploading CI workflow filename against a pre-declared filename you set ahead of time (in uvloop's case the filename is release.yml). It also requires creating an 'environment' for the repo on GitHub (suggested name "pypi") which you also register the package with on PyPI.
* Post-mortems of the litellm attack:
- https://futuresearch.ai/blog/litellm-pypi-supply-chain-attack/
- https://snyk.io/articles/poisoned-security-scanner-backdooring-litellm/
Implementation (click to expand)
-
Configure (or use an existing) GitHub environment, and register with PyPI
-
Add the environment definition to the same
publishjob -
Add
id-token: write,contents: writeandpackages: writepermissions to the samepublishjob- specifying any permission restricts the token, and creating a GitHub release requires
contents: writeand potentiallypackages: write
- specifying any permission restricts the token, and creating a GitHub release requires
-
Remove
passwordargument in theUpload to PyPIstep of thepublishjob of the Build & Publish CI workflow -
Optionally remove the
PYPI_TOKENproject secret
- Ngôn ngữ chính
- Cython
- Star
- 11.9k
- Fork
- 615
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của MagicStack/uvloop
-
License not clear Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
MagicStack/uvloop#759 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
MagicStack/uvloop#702 · 8 bình luận · 9 reaction ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
MagicStack/uvloop#763 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
MagicStack/uvloop#760 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
MagicStack/uvloop#754 · 1 bình luận · 1 reaction ·
Tất cả issue của MagicStack/uvloop
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 84/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
sympozium-ai/sympozium#627 ·
-
repo:raw-data
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
hotosm/raw-data-api#316 · 1 bình luận ·
-
agentic-workflows cascade-suspected
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
willow
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
openedx/openedx-authz#460 ·