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

Confirm terminating roles logic from spec #168

Open
tedbow opened this issue Jun 9, 2021 · 10 comments
Open

Confirm terminating roles logic from spec #168

tedbow opened this issue Jun 9, 2021 · 10 comments

Comments

@tedbow
Copy link

tedbow commented Jun 9, 2021

In https://github.com/php-tuf/php-tuf we are making sure we have the logic correct around terminating delegations. As we have updated our implementation of the spec from v1.0.9(the release when we started) to the most recent releases we have notice there has been some changes to wording in this area of the spec.

To make sure we get the logic correct for terminating delegations I have created this simple example to make sure our assumptions are correct(actually we don't all have same assumptions these are mine)
TUF delegation assumptions

Constraints

term = terminating delegation
non-term = non terminating delegation
Priority: The roles in each level are ordered from left to right in the order they would appear under [delegations][roles]
All roles have paths = [‘assets/*’] (just to provide matches for every role only focus on terminating logic now)
Target being searched for = 'assets/always-match.txt’

Expected outcome

Expected role evaluation:
Targets -> A > B > C > D

Am I correct?

@trishankatdatadog
Copy link
Member

trishankatdatadog commented Jun 9, 2021

Thanks, Ted!

There's still one point of confusion here: the term/non-term labels should apply to the edges, not the nodes.

However, I think your interpretation is correct, as per the spec and the Diplomat paper.

From simulating the code on this graph in my head, I think my tuf-on-a-plane code would correctly not explore E, but would incorrectly explore F.

Any disagreements, @mnm678 and @JustinCappos?

@trishankatdatadog
Copy link
Member

IOW: once you see a terminating delegation anywhere in the graph, the rest of the graph is completely pruned.

@trishankatdatadog
Copy link
Member

There are two ways of interpreting terminating delegations: global vs local pruning. Only one of them is the intended/correct interpretation.

@joshuagl
Copy link
Member

joshuagl commented Jun 10, 2021

I'm not one of the original authors, but my interpretation of the spec and the Diplomat paper matches the expected outcome suggested here.

@JustinCappos
Copy link
Member

I agree this interpretation is correct.

I'm also curious what everyone thinks should happen if there is a threshold delegation to A and F as well. Certainly that is worth a test case...

@mnm678
Copy link
Collaborator

mnm678 commented Jun 11, 2021

From simulating the code on this graph in my head, I think my tuf-on-a-plane code would correctly not explore E, but would incorrectly explore F.

I read it the same. The loop will need to propagate that there was a terminating delegation up to previous iterations in order to correctly not explore F. It looks like the reference implementation handles this correctly by breaking out of the for loop here (I didn't check the new client).

I'm also curious what everyone thinks should happen if there is a threshold delegation to A and F as well. Certainly that is worth a test case...

In that case, I'd argue that F should be explored (and required for the threshold). But I don't think this behavior is well-defined in the spec.

@trishankatdatadog
Copy link
Member

I'm also curious what everyone thinks should happen if there is a threshold delegation to A and F as well. Certainly that is worth a test case...

By threshold delegation, you mean multirole delegation? Agree with @mnm678 that if min_roles_in_agreement >=1 (which I assume is always the case), then, yes, it should backtrack from A and check F, despite any terminating delegation from A. Agree that the spec is underspecified with respect to TAP 3. Also need to think about whether there is any contradiction between terminating delegations and TAP 3.

@mnm678
Copy link
Collaborator

mnm678 commented Jun 14, 2021

The spec states that

A terminating delegation for a package causes any further statements about a package that are not made by the delegated party or its descendants to be ignored.

Which by a literal reading does contradict TAP 3. I don't think TAP 3 is supported by 1.0 of the specification, but this is something we should figure out before adding it.

@trishankatdatadog
Copy link
Member

trishankatdatadog commented Jun 14, 2021

Which by a literal reading does contradict TAP 3. I don't think TAP 3 is supported by 1.0 of the specification, but this is something we should figure out before adding it.

In particular, I'd like to see concrete pseudocode added to the spec. Otherwise, readers are likely to get confused.

@tedbow
Copy link
Author

tedbow commented Jun 16, 2021

Thanks everyone for the confirmation. I working on fixing our implementation increasing our test coverage for different cases here php-tuf/php-tuf#216

If anyone is interested we test our client implementation by creating test fixtures with a FixtureBuilder that uses the Python server implementation. For example here is 1 for that PR that creates the above test case https://github.com/php-tuf/php-tuf/blob/tedbow-fix_terminating_2/fixtures/TUFTestFixtureTerminatingDelegation/__init__.py
(BTW @phenaproxima and myself are learning python to create these test fixtures so don't expect great python code 😁)

We then make test case for a given test fixture and given target, whether it should be found and which metadata files the client should retreive/evaluate to determine this. Like this case for role "F" in the example not finding a target because of terminating delegation in "B" https://github.com/php-tuf/php-tuf/blob/tedbow-fix_terminating_2/tests/Client/UpdaterTest.php#L653

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

No branches or pull requests

5 participants