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 TrustRoot crd. #291

Merged
merged 3 commits into from Dec 11, 2022
Merged

Add TrustRoot crd. #291

merged 3 commits into from Dec 11, 2022

Conversation

vaikas
Copy link
Collaborator

@vaikas vaikas commented Oct 5, 2022

Signed-off-by: Ville Aikas vaikas@chainguard.dev

Summary

This PR starts adding support for being able to support multiple TUF Roots / repositories as well as bring your own keys.
The compress/uncompress will be used to serialize/unserialize air-gapped entries provided by user.
For now only supports the bring your own keys case. Since everything will be boiled down to that, it's the first step to get that wired, then will need to add grabbing the keys/certs from the actual TUF roots / repositories, but since this is getting large as it is, but demonstrates e2e going from a CRD -> Reconcile -> ConfigMap should have the necessary pieces in place to add the TUF Remote / Repository support as a follow up.

High level design document is here:
https://docs.google.com/document/d/1a-tV9YyXHvtoaZXm-eMcqP-zFTWg6Pqfjyl8W4uS9F4/edit#heading=h.ynb0pmylorbd

Release Note

  • Add TrustRoot CRD for support multiple TUF roots as well as bring your own keys.

Documentation

Copy link

@JAORMX JAORMX left a comment

Choose a reason for hiding this comment

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

Could you add some docs about this?

@vaikas
Copy link
Collaborator Author

vaikas commented Nov 8, 2022

@JAORMX yeah, I'm just trying to get the rough chainsaw size bits up while sorting how this may look.

Copy link
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

Was mostly looking at broad strokes controller stuff, not looking too much at the details.

cmd/trustedkeys/main.go Outdated Show resolved Hide resolved
cmd/trustedkeys/main.go Outdated Show resolved Hide resolved
pkg/reconciler/testing/v1alpha1/trustedkeys.go Outdated Show resolved Hide resolved
pkg/reconciler/trustedkeys/controller.go Outdated Show resolved Hide resolved
pkg/reconciler/trustedkeys/controller.go Outdated Show resolved Hide resolved
pkg/reconciler/trustedkeys/trustedkeys.go Outdated Show resolved Hide resolved
pkg/reconciler/trustedkeys/trustedkeys.go Outdated Show resolved Hide resolved
@vaikas vaikas force-pushed the tuf-roots-crd branch 2 times, most recently from 5cc4704 to 669df0b Compare December 9, 2022 03:44
@vaikas vaikas changed the title WIP: Add tuf_root crd. Add TrustRoot crd. Dec 9, 2022
@codecov-commenter
Copy link

codecov-commenter commented Dec 9, 2022

Codecov Report

Merging #291 (6307a7b) into main (2bc604f) will decrease coverage by 5.79%.
The diff coverage is 24.01%.

@@            Coverage Diff             @@
##             main     #291      +/-   ##
==========================================
- Coverage   58.91%   53.11%   -5.80%     
==========================================
  Files          31       38       +7     
  Lines        3052     3660     +608     
==========================================
+ Hits         1798     1944     +146     
- Misses       1152     1585     +433     
- Partials      102      131      +29     
Impacted Files Coverage Δ
cmd/policy_webhook/main.go 0.00% <0.00%> (ø)
pkg/apis/policy/v1alpha1/register.go 0.00% <0.00%> (ø)
pkg/apis/policy/v1alpha1/trustroot_defaults.go 0.00% <0.00%> (ø)
pkg/apis/policy/v1alpha1/trustroot_types.go 0.00% <0.00%> (ø)
pkg/apis/policy/v1alpha1/zz_generated.deepcopy.go 13.33% <0.00%> (-7.62%) ⬇️
pkg/tuf/repo.go 26.84% <26.84%> (ø)
pkg/apis/config/sigstore_keys.go 28.81% <28.81%> (ø)
pkg/apis/policy/v1alpha1/trustroot_validation.go 30.18% <30.18%> (ø)
pkg/reconciler/trustroot/trustroot.go 36.14% <36.14%> (ø)
pkg/reconciler/trustroot/controller.go 86.66% <86.66%> (ø)
... and 1 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Signed-off-by: Ville Aikas <vaikas@chainguard.dev>
// The time the *entire* chain was valid. This is at max the
// longest interval when *all* certificates in the chain where valid,
// but it MAY be shorter.
// dev.sigstore.common.v1.TimeRange valid_for = 4;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wouldn't this be a TTL ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think the problem is that it will require a start and optionally an end :) So, I'd like to figure out how this should work hence the TODO :)

// Certificate Transparency Log
CTLog []TransparencyLogInstance `json:"ctLog"`
// Trusted timestamping authorities
TimeStampAuthorities []CertificateAuthority `json:"timestampAuthorities"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are these optionals ? If so we could use pointers []*CertificateAuthority and add omitempty to the json fields

Copy link
Collaborator

Choose a reason for hiding this comment

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

In the protos definition, this appears as timestamp_authorities

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah, I think we'll need either tlog or tsa here. Though, I suppose anything but CA could be optional.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think though that array type has a native nil, so I think the entries in it do not need to be pointers. Just need to add the // +optional above this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So for consistency, I think it might be better to just specify the trusted certchain in one place (trustroot) rather than bake it into each CIP, just like for Fulcio/Rekor we don't bake the certs/keys in.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

re having the underscore in the name, that's not right :) For the JSON fields, the convention is camelcase.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think in the fullness of time the URLs from the keyless/ctlog might just go away and you just refer to the trust root, since the entries in the TrustRoot have the URLs necessary to construct the clients as well as all the other necessary bits.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So for consistency, I think it might be better to just specify the trusted certchain in one place (trustroot) rather than bake it into each CIP, just like for Fulcio/Rekor we don't bake the certs/keys in.

But we bake in the keys, and ctlog references 🤔 .

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, that's why I say in fullness of time :) I think CTLog / Fulcio URL will go away and they will just refer to the TrustRoot.

type CertificateAuthority struct {
// The root certificate MUST be self-signed, and so the subject and
// issuer are the same.
Subject DistinguishedName `json:"subject"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't you wanna use subject,omitempty

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this is required as per the proto comments so that we can ensure the root cert is self signed.

local := client.MemoryLocalStore()
tufClient := client.NewClient(local, remote)

// TODO(vaikas): What should we do with above tufClient validation
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe check the targets

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I'll add that as part of when I add support for bringing those in (next PR or the one after) since this is getting big already 🤣

Signed-off-by: Ville Aikas <vaikas@chainguard.dev>
mattmoor
mattmoor previously approved these changes Dec 10, 2022
Copy link
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

Broad strokes of all of the controller stuff generally lgtm, but I haven't reviewed all of the TUF/reconciler details.

.github/workflows/kind-e2e-trustroot-crd.yaml Outdated Show resolved Hide resolved
Signed-off-by: Ville Aikas <vaikas@chainguard.dev>
Copy link
Collaborator

@hectorj2f hectorj2f left a comment

Choose a reason for hiding this comment

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

lgtm

@vaikas vaikas merged commit 96dde0c into sigstore:main Dec 11, 2022
@vaikas vaikas deleted the tuf-roots-crd branch December 11, 2022 22:30
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.

None yet

5 participants