Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add optional pypi release job inside the reusable tox workflow #243

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ssbarnea
Copy link
Member

No description provided.

Copy link

github-actions bot commented Nov 11, 2024

Label error. Requires exactly 1 of: bug, enhancement, major, minor, patch, skip-changelog. Found: upstream

# keep permissions at top level because this is a composite workflow
permissions:
checks: read
contents: read
id-token: write
id-token: write # release
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting the OIDC privilege is highly discouraged because giving such elevated privileges to random scripts like transitive build dependencies, testing automation and other things can lead to privilege elevation and impersonation attacks and who knows what else. For this reason, I emphasize this in all the docs for pypi-publish that are in my reach. We even managed to update GitHub's own PyPI+OIDC doc to show that it's only acceptable in the publishing job that only downloads the dists and calls pypi-publish but nothing else.
So whenever I see id-token: write anywhere outside of the narrow scope of a single job doing this single thing, I know immediately that it's a security vulnerability.

fetch-depth: 0 # needed by setuptools-scm

- name: Build dists
run: python3 -m tox -e pkg
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following the previous comment, building within the publishing job with OIDC is a popular example of letting the possibility of being impersonated over OIDC into your life. Don't do this, it's not supported.

name: release ${{ github.event.ref }}
# if: github.ref_type == 'tag' || inputs.publish_pypi == 'true'
needs: check
environment: release # keep it here to allow users to prompt for release
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I finally updated PyPI and its docs to suggest using pypi and testpypi recently. So that people would stop thinking of deployment targets (which what the environments are) as processes (which they are not). So I recommend those name in place of cryptic generic terms.

PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
run: |
if [ -z "${PYPI_API_TOKEN}" ]; then
echo "PYPI_API_TOKEN is not set, please add it to your repository environment named 'release'."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the current environment name is available in the context vars somewhere, it's usually better than hardcoding.

@ssbarnea ssbarnea added the upstream Blocked due to upstream dependencies label Nov 11, 2024
@ssbarnea ssbarnea marked this pull request as draft November 11, 2024 15:25
@ssbarnea ssbarnea changed the title Add optional pypi release job inside the reusable tox workflow [WIP] Add optional pypi release job inside the reusable tox workflow Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream Blocked due to upstream dependencies
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants