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

Tweaks to better interop with go-tuf #377

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

lukesteensen
Copy link

@lukesteensen lukesteensen commented Aug 30, 2022

👋 I've been working on integrating the Vector project with Datadog's TUF/Uptane implementation, and this PR contains the handful of tweaks I've had to make to get everything interoperating happily:

  1. A spec_version of "1.0" is not actually valid according to SemVer. It should probably be "1.0.0" everywhere, but I've kept a check for the old value so that it continues to work with existing metadata.
  2. The datetime parsing was overly strict relative to the spec, which only specifies ISO8601. Here it's adjusted to use a full RFC3339 parser that handles the slightly differing format that go-tuf can emit.
  3. Allowing * in paths, which is legal according to the spec and used somewhat heavily when specifying delegations.
  4. Adding a couple of Send bounds, which isn't related to interop but made the library easier to use.

The spec_version change does seem to break the interop tests, but I wanted to make sure we want to move forward with the change before doing the work of regenerating the test data.

If any these seem undesirable or warrant more discussion, I'd be happy to split them into separate PRs.

/cc @Zenithar @cedricvanrompay-datadog

Copy link
Collaborator

@erickt erickt left a comment

Choose a reason for hiding this comment

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

Hello! Great patch, thanks! Beyond my comments, it looks like there's some test failures from us changing the spec_version. It also might be time to update our golden test files from python-tuf and go-tuf.

--

And sorry that I keep putting out beta versions without cutting a formal release. I think with my delegation fix, and fleshing out the builder more I'm almost ready to commit to not breaking the API. I was tracking that work in #355. One thing to note though I'm not super confident in our delegation support. We aren't currently using it, so outside of the tests here we don't have a lot of real world use cases. For example, I just found that we were using the wrong field name last week in #373. I'd love any help trying to harden that.

tuf/src/interchange/cjson/shims.rs Show resolved Hide resolved
tuf/src/interchange/cjson/shims.rs Show resolved Hide resolved
tuf/src/metadata.rs Show resolved Hide resolved
@lukesteensen
Copy link
Author

Thanks! I've updated the lib tests, so those should now be passing, but left the interop tests since I'm not sure of the best procedure for generating new fixtures.

As far as testing delegation support, I'll see if some of our TUF experts can have a look and give some feedback. I'm pretty sure we use them at Datadog, but my team is still pretty new to TUF.

@trishankatdatadog
Copy link
Member

trishankatdatadog commented Aug 30, 2022

First, nice work!

As far as testing delegation support, I'll see if some of our TUF experts can have a look and give some feedback. I'm pretty sure we use them at Datadog, but my team is still pretty new to TUF.

Second, yes, we do use delegations for full verification. I recommend taking a look at how go-tuf or python-tuf does it.

@cedricvanrompay-datadog

Interesting, it seems that go-tuf has it wrong as well for the spec_version format: https://github.com/theupdateframework/go-tuf/blob/ac7b5d7bce18cca5a84a28b021bd6372f450b35b/data/types.go#L112

@trishankatdatadog
Copy link
Member

Interesting, it seems that go-tuf has it wrong as well for the spec_version format: https://github.com/theupdateframework/go-tuf/blob/ac7b5d7bce18cca5a84a28b021bd6372f450b35b/data/types.go#L112

If so, would you help us to create a new issue there? Thanks!

@trishankatdatadog
Copy link
Member

BTW, we don't have keyid_hash_algorithms in the metadata here, do we?

@lukesteensen
Copy link
Author

lukesteensen commented Sep 1, 2022

I've added one more commit here to add a catch-all additional_fields property to TargetsMetadata all of the top level metadata structs. It turns out that go-tuf has a custom field here that is not mentioned in the spec. I didn't necessarily want to duplicate that, but the spec does also say that implementations can use additional fields and they should be maintained, so that's what I did. If someone has a better solution for that I'd be happy to discuss it.

Copy link
Member

@trishankatdatadog trishankatdatadog left a comment

Choose a reason for hiding this comment

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

IDK Rust, but the ideas therein seems good enough to me 👍🏽

@erickt
Copy link
Collaborator

erickt commented Sep 8, 2022

It looks like we also got some test failures. I'd also like the additional_fields to have some tests too. It might be better to factor that out into a separate PR so it doesn't conflate with the other changes.

@erickt
Copy link
Collaborator

erickt commented Sep 12, 2022

FYI I did find a bug in rust-tuf's delegation #381.

erickt added a commit to erickt/rust-tuf that referenced this pull request Sep 23, 2022
In theupdateframework#377, @lukesteensen noticed that we created metadata with the wrong
spec version. We used `1.0`, but the proper form is `1.0.0`.
Unfortunately landing this fix will be non-trivial, since old versions
of rust-tuf will error out if the spec version is not `1.0`.

As a stopgap, this patch changes rust-tuf to allow either a spec version
of `1.0` or `1.0.0` so that we can switch to the proper schem once all
the old clients have upgraded, or we come up with another way to
gracefully perform this migration.
@erickt
Copy link
Collaborator

erickt commented Sep 23, 2022

I just realized that switching our metadata generation to building metadata with the spec_version of 1.0.0 would cause old clients to reject the now spec-conformant metadata, so we need to come up with a way to do a graceful migration.

As a stopgap, I factored out some of your fix in #386 to make sure new clients will at least be able to support the proper format once we start producing it.

erickt added a commit to erickt/rust-tuf that referenced this pull request Sep 23, 2022
This extracts @lukesteensen's RFC 3339 timestamp parser from theupdateframework#377. This
allows rust-tuf to interoperate better with other TUF implementations,
which might include things like microseconds, or not be in the UTC
timezone.
erickt added a commit to erickt/rust-tuf that referenced this pull request Sep 23, 2022
From theupdateframework#377, the [TUF spec] allows for paths to contain `*`. According to
@lukesteensen, this is routinely used in delegations.

Note though this does not attempt to implement delegation path globs.
That will be implemented in theupdateframework#388.

[TUF spec]: https://theupdateframework.github.io/specification/latest/#targetpath
@erickt erickt mentioned this pull request Sep 23, 2022
erickt added a commit that referenced this pull request Sep 27, 2022
In #377, @lukesteensen noticed that we created metadata with the wrong
spec version. We used `1.0`, but the proper form is `1.0.0`.
Unfortunately landing this fix will be non-trivial, since old versions
of rust-tuf will error out if the spec version is not `1.0`.

As a stopgap, this patch changes rust-tuf to allow either a spec version
of `1.0` or `1.0.0` so that we can switch to the proper schem once all
the old clients have upgraded, or we come up with another way to
gracefully perform this migration.
erickt added a commit to erickt/rust-tuf that referenced this pull request Sep 27, 2022
This extracts @lukesteensen's RFC 3339 timestamp parser from theupdateframework#377. This
allows rust-tuf to interoperate better with other TUF implementations,
which might include things like microseconds, or not be in the UTC
timezone.
erickt added a commit that referenced this pull request Sep 27, 2022
This extracts @lukesteensen's RFC 3339 timestamp parser from #377. This
allows rust-tuf to interoperate better with other TUF implementations,
which might include things like microseconds, or not be in the UTC
timezone.
erickt added a commit to erickt/rust-tuf that referenced this pull request Sep 27, 2022
From theupdateframework#377, the [TUF spec] allows for paths to contain `*`. According to
@lukesteensen, this is routinely used in delegations.

Note though this does not attempt to implement delegation path globs.
That will be implemented in theupdateframework#388.

[TUF spec]: https://theupdateframework.github.io/specification/latest/#targetpath
erickt added a commit that referenced this pull request Sep 27, 2022
From #377, the [TUF spec] allows for paths to contain `*`. According to
@lukesteensen, this is routinely used in delegations.

Note though this does not attempt to implement delegation path globs.
That will be implemented in #388.

[TUF spec]: https://theupdateframework.github.io/specification/latest/#targetpath
@lukesteensen
Copy link
Author

@erickt Thanks so much for taking most of these across the line! Apologies for the radio silence, I had a couple weeks of travel there and some conflicting work priorities. It seems like the additional_fields piece, as well as maybe the Send bound tweak, are all that's left? This coming week I'm happy to open a more specific PR for just that.

@erickt
Copy link
Collaborator

erickt commented Oct 1, 2022

Yeah, although I saw and landed a patch that removed a number of unnecessary trait bounds. It might be that inheriting Send might not be necessary anymore.

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.

4 participants