Switch to Trusted Publishing for package upload to PyPI in CI
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 68/100
Direzione di ricerca
Inizia da .github/workflows/release.yml e ispeziona il job publish, in particolare il passaggio Upload to PyPI. Configura l’ambiente pypi di GitHub e la relativa registrazione su PyPI, aggiungi le autorizzazioni e l’ambiente richiesti per il job e rimuovi l’argomento password e, facoltativamente, PYPI_API_TOKEN. Il lavoro è completato quando le release vengono pubblicate tramite Trusted Publishing con attestazioni invece che con un token memorizzato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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 httptools 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 httptools'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 Release CI workflow -
Optionally remove the
PYPI_API_TOKENproject secret
- Lingua principale
- Python
- Stelle
- 1.3k
- Fork
- 107
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di MagicStack/httptools
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
MagicStack/httptools#136 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
MagicStack/httptools#127 · 2 commenti · 1 reazione ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
MagicStack/httptools#126 ·
-
Python 3.10 Armv7 version Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
MagicStack/httptools#125 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 42/100
MagicStack/httptools#124 · 2 reazioni ·
Tutte le issue di MagicStack/httptools
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
learningequality/ricecooker#747 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
BSData/horus-heresy-3rd-edition#3171 ·
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
run-llama/llama_index#23199 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
KhronosGroup/glTF-Blender-IO#2769 ·