Skip to content

[DRAFT] Add RekorV2Client #1400

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
wants to merge 23 commits into from

Conversation

ramonpetgrave64
Copy link
Contributor

@ramonpetgrave64 ramonpetgrave64 commented May 20, 2025

Client support for Rekor V2: sigstore-python #289

Summary

Adds a new RekorV2Client class, for use as a library, not yet within the CLI.

With the same pending TODOs in #1387

  • We are embedding the auto-generated types until we can find a home for them

Testing

  • Unit tests that call live instances of RekorV2, only "alpha" for now
  • Lints are not yet expected to pass, mainly due to type hints on the copy-pasted auto-generated types.

TODOS

  • add more client methods: get_tile, get_entry_bundle, get_checkpoint.
  • enable testing against more instances: staging, prod, local
  • add extra assert in test after improve KindVersion compatibility #1370
  • use these types in sigstore/protobuf-specs when ready (hopefully this week of May 19, 2025)
  • remove workaround where the ...V_0_0_2 is changed to ...V002
  • prefer sending the certificate, rather than the public key to Rekor

Release Note

  • Added a RekorV2Client for posting new entries to a Rekor V2 instance.

Documentation

TODO

Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
@ramonpetgrave64 ramonpetgrave64 changed the title Add RekorV2Client [DRAFT] Add RekorV2Client May 20, 2025
Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
@jku
Copy link
Member

jku commented May 28, 2025

I'll look at cleaning up some tests next:

  • all of the added tests currently end up getting skipped or xfailed on CI
  • some of them are essentially parsing tests and should likely never be skipped: there is no need for the signing cert and private key here to be from a real environment
  • the actual staging test should likely be gated behind staging marker
  • I don't think testing rekorv1 (staging, prod) urls as expected failures is useful
  • similarly, adding local test servers URLs xfailing because we don't have local test servers in the suite is probably not useful

In fact I don't think we need to test with multiple instances at all in the RekorClient test -- we will have integration tests later for the whole client

@jku
Copy link
Member

jku commented Jun 3, 2025

Note to self:

  • I think nothing in either Client really needs the "rekor types" that the _build_* methods return: create_entry() uses them but only to generate the json payload
  • so it looks like the _build_*() methods could just return the relevant json payload
  • this would allow making the create_entry method signatures actually same and not just pretend they are similar

I'll look into this later this week.

EDIT: I have done this change: the log submitter abstraction is now less leaky

* Make sure the exposed signatures actually are abstract:
  the request payload can be just a dict so both clients actually
  implement the same API
* There is still a "EntryRequest" NewType being used instead of dict
  just to make the intent clear

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
@jku
Copy link
Member

jku commented Jun 4, 2025

todo for this pr:

  • sort out the protobuf situation (Client generation and mirroring in protobuf-specs rekor-tiles#338): preferably get the proto code generated in protobuf-specs, release that. Alternatively update and polish the generated code here -- this would be a temporary thing
  • testing (I'm looking at this next):
    • I think the current tests for the _build_*() methods are not amazing: they are complicated and basically only repeat the content of the methods in the test and I think rely on an external service (OIDC + fulcio) for no reason: the value is questionable... I think I will remove them for now.
    • The create_entry() test seems more usable --- but even that depends on both OIDC and fulcio so is essentially an integration test pretending to be a unit test
    • the support for multiple environments in the tests is probably overkill -- unit tests should just verify the code works

Comment on lines +82 to +86
resp = self.session.post(
f"{self.url}/log/entries",
json=payload,
timeout=CREATE_ENTRIES_TIMEOUT_SECONDS,
)
Copy link
Member

Choose a reason for hiding this comment

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

this does not really do what the rekor docs say... Session timeout is the maximum allowed time between any two bytes the server sends as response. So the effective total timeout could still be effectively infinite.

I don't think the setting here is harmful but it strongly suggests that we're enforcing the rekor documented overall timeout when we're really not... We could either not have a timeout (we don't in other places) or mention in a comment that this is not the same thing as the rekor 20 sec recommendation

* Don't pretend these are unit tests: just have something simple
  that proves the client roughly does what it should
* We should have real unit tests (that don't require the whole
  staging infra as current tests do) and integration tests but this
  is what I have now

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
@jku
Copy link
Member

jku commented Jun 4, 2025

I've replaced the tests with two very simple staging tests -- they're definitely not unit tests but essentially integration tests (with a small hack since the integration does not exist yet) that prove the client is at some level operational.

I think I'll move this branch to origin -- that should make the staging tests run (since the GH token should be available)...

@jku jku mentioned this pull request Jun 4, 2025
@jku
Copy link
Member

jku commented Jun 4, 2025

closing for #1422 (the branch is the same, but now in origin so staging tests run on CI)

@jku jku closed this Jun 4, 2025
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