Repository navigation
Fix terminating in fixture generation and getMetadataForTarget() - #216
Conversation
phenaproxima
left a comment
There was a problem hiding this comment.
This makes sense to me. One punctuation nitpick.
|
I checked the last TUF spec to make sure we don't have to change the logic again. The description has changed See latest 1.0.19 https://theupdateframework.github.io/specification/v1.0.19/#update-targets and 1.0.17 the version we are on: https://theupdateframework.github.io/specification/v1.0.17/#update-targets This switch the order that See this issue theupdateframework/specification#140 Here is the commit where it changed theupdateframework/specification@718f133 |
|
See this slack convo https://cloud-native.slack.com/archives/C8NMD3QJ3/p1622232421026200
|
|
Making this a draft because we still need clarification on how this should work |
|
After chatting more with @trishankatdatadog I think 1 & 2 from my original comment on the issue are still a problem but 3 is not. |
…terminating role path and 1 that does not
Co-authored-by: Adam <[email protected]>
| .create_target('e.txt', signing_role='e') \ | ||
| .delegate('f', ['*.txt']) \ | ||
| .create_target('f.txt', signing_role='f') \ | ||
| .publish() |
There was a problem hiding this comment.
@phenaproxima I haven't made the phpunit test that uses this fixture yet but I think this is how to make the test case specified in theupdateframework/specification#168
I looked through the json files and I think it produces the correct fixture but let me know if you think it produces the correct fixture.
BTW I love how easy this is to make with the new FixtureBuilder class !
Fix typos.
| } | ||
| $searchedRoles[] = $delegatedRoleName; | ||
| // § 5.6.7.2.1 | ||
| // If the current delegation is a multi-role delegation, recursively visit each role, and check that each has signed exactly the same non-custom metadata (i.e., length and hashes) about the target (or the lack of any such metadata). |
There was a problem hiding this comment.
Question: how do we know if the current delegation is a "multi-role" delegation? What does that mean?
There was a problem hiding this comment.
"multi-role" wording was wrong. This was taken out of spec. I thought it meant a role that delegate to more than 1 more role. but it actually refers to something else that is not in 1.x version of the spec and is being considered for 2.x.
I updated the wording from the current version of the spec.
| 'level_3' => 1, | ||
| 'level_3_below_terminated' => 1, | ||
| ], | ||
| // Roles after terminating delegation where the target path does not |
There was a problem hiding this comment.
"...where the target path does not the terminating role are..." seems like odd phrasing. Missing a word?
There was a problem hiding this comment.
Added more context. Take another look
…h no terminating. fails tests
phenaproxima
left a comment
There was a problem hiding this comment.
This is really good. I'm super happy about the robust test coverage. My concerns lie more with overall grokkability -- the TUF spec, as we know, is poorly worded about this recursive search for targets within a delegation tree, and therefore I think we need to be completely clear about what we're doing and how we expect it to work. I think my biggest wishlist item after this review is inline comments for all the test cases where, at the very least, we explain what the expected outcome is.
| * @param bool $terminated | ||
| * | ||
| * @return \Tuf\Metadata\TargetsMetadata|null | ||
| * The target metadata that is the end node for search or null if the target metadata does not make any delegations. |
There was a problem hiding this comment.
I'd rephrase this too. Maybe "The targets metadata that was the last visited node in the delegation tree, or null if there were no delegated roles to search. If targets metadata is returned, it may or may not contain information about the desired target."
There was a problem hiding this comment.
I simplified this method so only returns a targets metadata object if it has the info about the file. So the comment is simpler now
…ave a clear error when .json is not in the repo but it should be.
| } | ||
|
|
||
| /** | ||
| * Performs a search of delegate roles for a metadata containing information about a target. |
There was a problem hiding this comment.
| * Performs a search of delegate roles for a metadata containing information about a target. | |
| * Searches delegated roles for metadata containing information about a target. |
I wondering if the test cases would be easier to understand if we combined Right now So basically these 2 test methods maybe be better named But regardless of the naming if we wanted to see all the test cases for 1 fixture you would have to look at 2 provider methods. We could combine this into 1 test method |
phenaproxima
left a comment
There was a problem hiding this comment.
Made a small change, but otherwise I think I'm okay deferring documentation to a follow-up.
3 problems
level_2_after_terminatingwhere terminating should be true.generate_fixtures.TUFTestFixtureBase.delegate_role()didn't take this into account.2.
The paths here 'level_2_.txt' will never have a match for the role was delegated from 'unclaimed' which has a patch 'level_1_.txt'.
File must match all level of the chain so it will not be found because of that not because it is after the delegation.
This is part of the logic for evaluating each delegate role.
At the top check if the path matches if it does not we go to the next delegated role.
At the bottom we check if the role is terminating and return null if it is.
So if we have terminating role that does not match target path its termination will not take affect. I think this is wrong but we should check.