-
Notifications
You must be signed in to change notification settings - Fork 298
Fix incorrect delegation in diamond-shape case #2978
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
Open
jku
wants to merge
2
commits into
theupdateframework:develop
Choose a base branch
from
jku:fix-diamond-delegation
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -330,6 +330,52 @@ def test_invalid_metadata(self, test_data: DelegationsTestCase) -> None: | |
| finally: | ||
| self.teardown_subtest() | ||
|
|
||
| def test_shared_delegation_signature_check(self) -> None: | ||
| """Test that a role delegated by multiple parents is signature-checked | ||
| for each delegator link. | ||
| """ | ||
| test_case = DelegationsTestCase( | ||
| delegations=[ | ||
| TestDelegation("targets", "parent-a", paths=["path-a"]), | ||
| TestDelegation("targets", "parent-b", paths=["path-b"]), | ||
| TestDelegation("parent-a", "release", paths=["path-a"]), | ||
| TestDelegation("parent-b", "release", paths=["path-b"]), | ||
| ], | ||
| target_files=[ | ||
| TestTarget("release", b"content-a", "path-a"), | ||
| TestTarget("release", b"malicious-content-b", "path-b"), | ||
| ], | ||
| ) | ||
| self._init_repo(test_case) | ||
|
|
||
| # Client happy path: Both delegation paths work since release is signed | ||
| # by both parents | ||
| updater = self._init_updater() | ||
| target_a = updater.get_targetinfo("path-a") | ||
| self.assertIsNotNone(target_a) | ||
| target_b = updater.get_targetinfo("path-b") | ||
| self.assertIsNotNone(target_b) | ||
|
|
||
| # Create release v2: only signed by parent-a | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A comment here may help differentiate from the above test, but... I'm okay either way. |
||
| first_keyid = next(iter(self.sim.signers["release"].keys())) | ||
| self.sim.signers["release"] = { | ||
| first_keyid: self.sim.signers["release"][first_keyid] | ||
| } | ||
| self.sim.md_delegates["release"].signed.version += 1 | ||
| self.sim.update_snapshot() | ||
|
|
||
| # Client step 1: Get path-a targetinfo via parent-a -> release | ||
| # This primes TrustedMetadataSet to contain release v2 | ||
| updater = self._init_updater() | ||
| target_a = updater.get_targetinfo("path-a") | ||
| self.assertIsNotNone(target_a) | ||
|
|
||
| # Client step 2: Get path-b targetinfo via parent-b -> release | ||
| # Must fail because release while loaded in TrustedMetadataSet, is not signed | ||
| # by parent-b's keys | ||
| with self.assertRaises(UnsignedMetadataError): | ||
| updater.get_targetinfo("path-b") | ||
|
|
||
| def test_safely_encoded_rolenames(self) -> None: | ||
| """Test that delegated roles names are safely encoded in the filenames | ||
| and URLs. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.