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

Add high-level APIs to sign and verify Python artifacts #8

Merged
merged 5 commits into from
May 8, 2024

Conversation

facutuesca
Copy link
Collaborator

Adds a way to sign and verify Python artifacts, as methods of the existing AttestationPayload and Attestation classes:

class AttestationPayload(BaseModel):
    def sign(self, signer: Signer) -> Attestation:
        ...

class Attestation(BaseModel):
    def verify(self, verifier: Verifier, policy: VerificationPolicy, dist: Path) -> None:
        ...

See the new additions to the README for how they would be used in practice.
The tests added use stubs for sigstore.Signer and sigstore.Verifier: we only care if they are called with the expected arguments.

I also updated the test assets so that the .bundle and .attestation files were actually generated by signing an AttestationPayload (as opposed to signing the artifact itself)

@facutuesca facutuesca requested a review from woodruffw May 3, 2024 16:45
def verify(self, verifier: Verifier, policy: VerificationPolicy, dist: Path) -> None:
"""Verify against an existing Python artifact.

On failure, raises `sigstore.errors.InvalidAttestationError`.
Copy link
Member

Choose a reason for hiding this comment

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

Is this correct? I think InvalidAttestationError isn't a type in sigstore-python

Copy link
Collaborator Author

@facutuesca facutuesca May 7, 2024

Choose a reason for hiding this comment

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

True, the docstring is wrong here. Do we want to wrap sigstore's VerificationError with our own exception class, or just use sigstore's?

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, I suppose we should have it be our own -- wrapping makes sense to me 🙂

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed!

Copy link
Member

@woodruffw woodruffw left a comment

Choose a reason for hiding this comment

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

LGTM, one question!

@facutuesca facutuesca merged commit 0d69787 into main May 8, 2024
6 checks passed
@facutuesca facutuesca deleted the sign-verify-apis branch May 8, 2024 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants