Fix security issues with the Trusted Publishing example
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 230
- Forks
- 14
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
https://github.com/simonw/python-lib/blob/4b825ed/%7B%7Bcookiecutter.hyphenated%7D%7D/.github/workflows/publish.yml#L44-L49 suggests that building the dists within the same job that publishes them is okay. But it's not.
Such a structure opens the workflow users to privilege escalation through poisoning the build dependencies, which is why I've always insisted on the separation — the build scripts must never have access to id-token: write.
- https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
- https://docs.pypi.org/trusted-publishers/security-model/
Another suggestion is to fix the GitHub Environment name to represent the deployment target as it's meant to. I usually go for pypi and testpypi so it's obvious that uploading to both is separate.
I saw release here https://github.com/simonw/python-lib/blob/4b825ed/%7B%7Bcookiecutter.hyphenated%7D%7D/.github/workflows/publish.yml#L33C5-L33C25, which is not an upload target but a process name which is very generic.
The declaration syntax can also be extended to include a URL:
- environment: release
+ environment:
+ name: pypi
+ url: https://pypi.org/project/{% endraw %}{{ cookiecutter.hyphenated }}{% raw %}/${{ github.ref_name }}
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con {{cookiecutter.hyphenated}}/.github/workflows/publish.yml, especialmente con las líneas 33 y 44-49, y después lee la guía enlazada de PyPI Trusted Publishing. Comprueba cómo comparten permisos los pasos de build y publish y cómo se llama el entorno de release. El trabajo está terminado cuando el workflow separa la creación de la publicación, mantiene el acceso a id-token alejado de los scripts de build y nombra los destinos de PyPI con la URL de su proyecto.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- github-actions, python
- Área
- ci-cd, release, security
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bien especificado
- Aptitud para principiantes
- 45/100