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

tuf: use bundled trusted root if available #542

Merged
merged 16 commits into from
Mar 23, 2023

Conversation

tnytown
Copy link
Collaborator

@tnytown tnytown commented Mar 12, 2023

Summary

This changeset modifies the TUF component to fetch keys from the trusted_root.json target, if available. trusted_root.json is a rollup of Sigstore component public keys. Using this target reduces the number of network roundtrips necessary to fetch keys individually.

Resolves #488.

Release Note

Documentation

Signed-off-by: Andrew Pan <a@tny.town>
Signed-off-by: Andrew Pan <a@tny.town>
Signed-off-by: Andrew Pan <a@tny.town>
Signed-off-by: Andrew Pan <a@tny.town>
Signed-off-by: Andrew Pan <a@tny.town>
@woodruffw woodruffw added the component:tuf TUF related components label Mar 13, 2023
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.

@tetsuo-cpp can do a full review, but as a small nit: needs a CHANGELOG entry 🙂

@tnytown
Copy link
Collaborator Author

tnytown commented Mar 14, 2023

I've left this one on draft because I haven't adjusted the tests to exercise the new codepaths. Most of the new logic seems trivial except for the stuff that ensures that a given target in a trusted root is active/expired. I'll work on adding some basic testing for that.

Signed-off-by: Andrew Pan <a@tny.town>
Signed-off-by: Andrew Pan <a@tny.town>
Signed-off-by: Andrew Pan <a@tny.town>
Signed-off-by: Andrew Pan <a@tny.town>
@tnytown tnytown marked this pull request as ready for review March 15, 2023 20:44
@tnytown tnytown changed the title [WIP] tuf: use bundled trusted root if available tuf: use bundled trusted root if available Mar 15, 2023
Signed-off-by: Andrew Pan <a@tny.town>
CHANGELOG.md Outdated Show resolved Hide resolved
Co-authored-by: William Woodruff <william@yossarian.net>
Signed-off-by: Andrew Pan <3821575+tnytown@users.noreply.github.com>
tetsuo-cpp
tetsuo-cpp previously approved these changes Mar 22, 2023
Copy link
Collaborator

@tetsuo-cpp tetsuo-cpp left a comment

Choose a reason for hiding this comment

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

LGTM!

Signed-off-by: Andrew Pan <3821575+tnytown@users.noreply.github.com>
@woodruffw
Copy link
Member

sigstore/_internal/keyring.py:81:39: F841 [*] Local variable `e` is assigned to but never used

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.

Small nits 🙂

sigstore/_internal/keyring.py Show resolved Hide resolved
Comment on lines +288 to +289
if not _is_timerange_valid(ca.valid_for, allow_expired=True):
continue
Copy link
Member

Choose a reason for hiding this comment

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

This is a no-op, right? If so maybe we can just omit it entirely, and perhaps just leave a comment to the effect of "we could check _is_timerange_valid here but don't bother to, since expired Fulcio chains are considered valid for verification purposes."

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

_is_timerange_valid also checks that the current timestamp is after valid_for's start, so in the off chance where that is not the case, this check will fail.

That being said, this detail is not too clear. I'll add a docstring to _is_timerange_valid :)

Copy link
Member

Choose a reason for hiding this comment

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

Got it, thanks!

sigstore/_internal/tuf.py Outdated Show resolved Hide resolved
sigstore/_internal/tuf.py Outdated Show resolved Hide resolved
Signed-off-by: Andrew Pan <a@tny.town>
@tnytown tnytown requested a review from woodruffw March 23, 2023 05:13
@tnytown tnytown self-assigned this Mar 23, 2023
Co-authored-by: William Woodruff <william@yossarian.net>
Signed-off-by: Andrew Pan <3821575+tnytown@users.noreply.github.com>
Comment on lines +156 to +157
@lru_cache()
def _updater(self) -> Updater:
Copy link
Member

Choose a reason for hiding this comment

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

Once we upgrade to 3.8 this can become cached_property, which will be nice. But until then, this LGTM!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yep! I was intending to use cached_property until I saw that it was 3.8+ :( Apparently cryptography polyfills it though!

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. Two thoughts:

  1. Assuming the Sigstore TUF repo maintainers are okay with it, I think we can transition to codebase to assuming a trust root bundle (and failing if not present) after a migration period. We could retain an explicit opt-in flag (like --tuf-unbundled-trust-root), if necessary. CC @asraa for thoughts 🙂

  2. We should add some more unit tests for the bundled trust root. @tnytown could you make a follow-up issue for that?

@woodruffw woodruffw merged commit 7b390f4 into sigstore:main Mar 23, 2023
@woodruffw woodruffw deleted the andrew/bundled-trust-root branch March 23, 2023 23:22
Copy link
Contributor

@asraa asraa left a comment

Choose a reason for hiding this comment

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

This is amazing!!

Yes - we are planning to have this be the stable trusted root target from now on. We will leave the existing targets in there for likely a year, and then deprecate them, so the current code with defaults for the trusted_root.json looks good to me.

Honestly, I wouldn't add an option to use the fallback old unbundled targets. IMO there's no need to, the behavior and targets are the same in both the bundled and unbundled so users wouldn't see any difference

@woodruffw
Copy link
Member

Makes sense, thanks @asraa!

@tnytown: In that case, let's plan to remove support for the old "standalone" targets in an upcoming release. This is entirely an implementation detail in a private API, so we can do it with a patch release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:tuf TUF related components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TUF: Support "bundled" trust root
4 participants