Skip to content

Support Google Cloud publishers #113

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

Closed
di opened this issue Apr 21, 2025 · 6 comments · Fixed by #114
Closed

Support Google Cloud publishers #113

di opened this issue Apr 21, 2025 · 6 comments · Fixed by #114
Assignees
Labels
enhancement ✨ New feature or request

Comments

@di
Copy link
Contributor

di commented Apr 21, 2025

Currently this library provides GitHubPublisher and GitLabPublisher. Additionally, when verifying, --repository is required to be either a GitHub or GitLab publisher.

Since PyPI supports a Google Cloud Trusted Publisher, this library should provide a GoogleCloudPublisher as well, to enable PyPI to support Google Cloud publishers for publish provenance.

Full end-to-end workflow:

$ cat setup.py
from setuptools import setup

setup(
    name="gcb-attestation-test",
    version="0.0.0",
)

$ python -m build --sdist
* Creating isolated environment: venv+pip...
* Installing packages in isolated environment:
  - setuptools >= 40.8.0
* Getting build dependencies for sdist...
running egg_info
creating src/gcb_attestation_test.egg-info
writing src/gcb_attestation_test.egg-info/PKG-INFO
writing dependency_links to src/gcb_attestation_test.egg-info/dependency_links.txt
writing top-level names to src/gcb_attestation_test.egg-info/top_level.txt
writing manifest file 'src/gcb_attestation_test.egg-info/SOURCES.txt'
reading manifest file 'src/gcb_attestation_test.egg-info/SOURCES.txt'
writing manifest file 'src/gcb_attestation_test.egg-info/SOURCES.txt'
* Building sdist...
running sdist
running egg_info
writing src/gcb_attestation_test.egg-info/PKG-INFO
writing dependency_links to src/gcb_attestation_test.egg-info/dependency_links.txt
writing top-level names to src/gcb_attestation_test.egg-info/top_level.txt
reading manifest file 'src/gcb_attestation_test.egg-info/SOURCES.txt'
writing manifest file 'src/gcb_attestation_test.egg-info/SOURCES.txt'
warning: sdist: standard file not found: should have one of README, README.rst, README.txt, README.md

running check
creating gcb_attestation_test-0.0.0
creating gcb_attestation_test-0.0.0/src
creating gcb_attestation_test-0.0.0/src/gcb_attestation_test.egg-info
copying files to gcb_attestation_test-0.0.0...
copying setup.py -> gcb_attestation_test-0.0.0
copying src/__init__.py -> gcb_attestation_test-0.0.0/src
copying src/gcb_attestation_test.egg-info/PKG-INFO -> gcb_attestation_test-0.0.0/src/gcb_attestation_test.egg-info
copying src/gcb_attestation_test.egg-info/SOURCES.txt -> gcb_attestation_test-0.0.0/src/gcb_attestation_test.egg-info
copying src/gcb_attestation_test.egg-info/dependency_links.txt -> gcb_attestation_test-0.0.0/src/gcb_attestation_test.egg-info
copying src/gcb_attestation_test.egg-info/top_level.txt -> gcb_attestation_test-0.0.0/src/gcb_attestation_test.egg-info
copying src/gcb_attestation_test.egg-info/SOURCES.txt -> gcb_attestation_test-0.0.0/src/gcb_attestation_test.egg-info
Writing gcb_attestation_test-0.0.0/setup.cfg
Creating tar archive
removing 'gcb_attestation_test-0.0.0' (and everything under it)
Successfully built gcb_attestation_test-0.0.0.tar.gz

$ python -m pypi_attestations sign dist/gcb_attestation_test-0.0.0.tar.gz

$ python -m pypi_attestations inspect dist/gcb_attestation_test-0.0.0.tar.gz.publish.attestation
Warning: The information displayed below are not verified, they are only displayed. Use the verify command to verify them.
File: dist/gcb_attestation_test-0.0.0.tar.gz.publish.attestation
Version: 1
Statement:
	Type: https://in-toto.io/Statement/v1
	Subject:
		gcb_attestation_test-0.0.0.tar.gz (digest: 461317362419124b6012e855423a9078d6de8aed3e74fa78cc74d669b23dc6cf)
	Predicate type: https://docs.pypi.org/attestations/publish/v1
	Predicate: None
Certificate:
	Subjects (suitable for `--identity`): ['[email protected]']
	Issuer: CN=sigstore-intermediate,O=sigstore.dev
	Validity: 2025-04-21 15:12:27+00:00
Transparency Log (1 entries):
	Log Index: 200170367

$ python -m pypi_attestations verify attestation --identity [email protected] dist/gcb_attestation_test-0.0.0.tar.gz
OK: dist/gcb_attestation_test-0.0.0.tar.gz.publish.attestation

$ twine upload --attestations dist/*
Uploading distributions to https://upload.pypi.org/legacy/
Uploading gcb_attestation_test-0.0.0.tar.gz
100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.9/7.9 kB • 00:00 • ?
WARNING  Error during upload. Retry with the --verbose option for more details.
ERROR    HTTPError: 400 Bad Request from https://upload.pypi.org/legacy/
         Invalid attestations supplied during upload: Attestations are not currently supported with Google publishers

$ python -m pypi_attestations verify pypi gcb_attestation_test-0.0.0.tar.gz
usage: pypi-attestations verify pypi [-h] --repository REPOSITORY [--staging] [--offline] [--provenance-file PROVENANCE_FILE] PYPI_FILE
pypi-attestations verify pypi: error: the following arguments are required: --repository
@woodruffw woodruffw assigned woodruffw and unassigned woodruffw Apr 21, 2025
@woodruffw woodruffw added the enhancement ✨ New feature or request label Apr 21, 2025
@woodruffw woodruffw self-assigned this Apr 21, 2025
@facutuesca
Copy link
Collaborator

facutuesca commented Apr 21, 2025

The Google Trusted Publishers take two claims: an email and a subject (which then Google sends as claims in their OIDC token). Here, I see that the email is present in the sigstore certificate, but I don't see the subject. Will it always be absent?

@woodruffw
Copy link
Member

Here, I see that the email is present in the sigstore certificate, but I don't see the subject. Will it always be absent?

I believe so, but I'll confirm -- my understanding is that Fulcio emits very few claims when used with an "email" signing identity, and that email is really the only guaranteed one.

@woodruffw
Copy link
Member

Yep, the only things that Fulcio embeds with an email identity is the email claim itself, plus the issuer, both of which we check:

https://github.com/sigstore/fulcio/blob/a99e844583d9c9b6a861fae623f93c8d39a26b33/pkg/identity/email/principal.go#L69-L81

@di
Copy link
Contributor Author

di commented Apr 22, 2025

Thanks @woodruffw! Can we release this?

@woodruffw
Copy link
Member

Yep, I'll kick one off in a moment!

@woodruffw
Copy link
Member

Cut with v0.0.24 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ✨ New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants