Safer GitLab CI package instructions
Problem to solve
- Python package documentation: https://docs.gitlab.com/ee/user/packages/pypi_repository/index.html#using-gitlab-ci-with-pypi-packages
The GitLab CI snippet is partial and in particular should probably note that the CI_JOB_TOKEN
is based on the user, not the branch, so new packages will be uploaded and existing ones overwritten before a branch is merged.
Proposal
- The example could include a complete job definition using
only
to restrict uploads to a particular branch
As a larger product discussion goes, it feels like there would be room for some restrictions on the CI token, such as not allowing package registry writes from unprotected branches. Since the token doesn't have more permissions than the user pushing the code it's not a security hole but it seems like a rake in the grass awaiting an unsuspecting maintainer, especially since versions are not immutable.