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

Generate PEP 740 attestations for PyPI #12981

Merged
merged 13 commits into from
Oct 8, 2024

Conversation

AA-Turner
Copy link
Member

@AA-Turner AA-Turner commented Oct 6, 2024

@AA-Turner
Copy link
Member Author

AA-Turner commented Oct 6, 2024

Output from https://github.com/AA-Turner/sphinx/actions/runs/11203683364/job/31141226284:

python -m pypi_attestations sign dist/*
python -m pypi_attestations inspect dist/*.publish.attestation
Warning: The information displayed below are not verified, they are only displayed. Use the verify command to verify them.
File: dist/sphinx-8.1.0-py3-none-any.whl.publish.attestation
Version: 1
Statement:
    Type: https://in-toto.io/Statement/v1
    Subject:
        sphinx-8.1.0-py3-none-any.whl (digest: b657d540a03ced0c94c27d5d3c3639710c5b205ae42d5e48daef957dd5b35f06)
    Predicate type: https://docs.pypi.org/attestations/publish/v1
    Predicate: None
Certificate:
    Subjects: ['https://github.com/AA-Turner/sphinx/.github/workflows/create-release.yml@refs/heads/attestations']
    Issuer: CN=sigstore-intermediate,O=sigstore.dev
    Validity: 2024-10-06 17:16:58+00:00
Transparency Log (1 entries):
    Log Index: 137444982
Warning: The information displayed below are not verified, they are only displayed. Use the verify command to verify them.
File: dist/sphinx-8.1.0.tar.gz.publish.attestation
Version: 1
Statement:
    Type: https://in-toto.io/Statement/v1
    Subject:
        sphinx-8.1.0.tar.gz (digest: 78ddd883f3dabdd56919e7f91f7c168a4c219dd92170828beeec8a7f0e3c3e7c)
    Predicate type: https://docs.pypi.org/attestations/publish/v1
    Predicate: None
Certificate:
    Subjects: ['https://github.com/AA-Turner/sphinx/.github/workflows/create-release.yml@refs/heads/attestations']
    Issuer: CN=sigstore-intermediate,O=sigstore.dev
    Validity: 2024-10-06 17:16:58+00:00
Transparency Log (1 entries):
    Log Index: 137444983
python -m pypi_attestations verify dist/*.whl --identity https://github.com/AA-Turner/sphinx/.github/workflows/create-release.yml@refs/heads/attestations
OK: dist/sphinx-8.1.0-py3-none-any.whl.publish.attestation
python -m pypi_attestations verify dist/*.tar.gz --identity https://github.com/AA-Turner/sphinx/.github/workflows/create-release.yml@refs/heads/attestations
OK: dist/sphinx-8.1.0.tar.gz.publish.attestation

A

@jayaddison
Copy link
Contributor

A question / observation: the attestation doesn't appear to provide a reference back to the original source code revision (git commit, in this case) that the attested artifact was built from. As a consumer of provenance data, I'd like in future to be able to navigate back to the source material (perhaps from an archive, if necessary), and then precisely locate the build revision, and compare/inspect/rebuild/etc from there.

Note: I did briefly wonder whether the certificate subject (SAN?) would be the place to expect that information -- but the current value, that reflects the build process (the GitHub Action, in this case) I think is intentional per-design according to PEP-740:

  • verification_material.certificate identifies an appropriate signing
    subject, such as the machine identity of the Trusted Publisher that published
    the package.

(that seems to describe what the SAN should contain - but I might have misunderstood. I realize mentioning that field may seem slightly off-topic, but I want to figure out whether it's the expected location for an unambiguous source revision reference)

@AA-Turner
Copy link
Member Author

AA-Turner commented Oct 6, 2024

I didn't follow the discussions around PEP 740, but yes it appears that there's no link to the SCM. This may have been intentional though, perhaps @woodruffw would know more.

A

@AA-Turner
Copy link
Member Author

AA-Turner commented Oct 8, 2024

The new actions/attest approach also records sigstore attestations in the repo, e.g.:

Notably, these include commit metadata.

A

@AA-Turner AA-Turner marked this pull request as ready for review October 8, 2024 04:07
# Conflicts:
#	.github/workflows/create-release.yml
# Conflicts:
#	.github/workflows/create-release.yml
@AA-Turner AA-Turner merged commit 1bfa4e6 into sphinx-doc:master Oct 8, 2024
8 checks passed
@AA-Turner AA-Turner deleted the attestations branch October 8, 2024 04:18
@woodruffw
Copy link

I didn't follow the discussions around PEP 740, but yes it appears that there's no link to the SCM.

There is one, but it's at a lower layer in the format: the X.509 certificate contains extensions corresponding to the machine identity/workflow identity of the CI job that ran the attestation step, and one of those extensions is the commit SHA.

The full set of extensions and how they map to individual CI providers (like GHA) is here: https://github.com/sigstore/fulcio/blob/main/docs/oid-info.md

@jayaddison
Copy link
Contributor

Thank you, @woodruffw!

@jayaddison
Copy link
Contributor

A question / observation: the attestation doesn't appear to provide a reference back to the original source code revision (git commit, in this case) that the attested artifact was built from. As a consumer of provenance data, I'd like in future to be able to navigate back to the source material (perhaps from an archive, if necessary), and then precisely locate the build revision, and compare/inspect/rebuild/etc from there.

Commenting here for future reference / to complete the thread: in fact the attestation does already include these details; my observation was based only on the output of pypi_attestations inspect, and that is a partial view of the attestation's contents.

@AA-Turner AA-Turner added this to the 8.1.0 milestone Oct 10, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants