-
Notifications
You must be signed in to change notification settings - Fork 278
Targets delegations are not updated when adding a new delegation key #1037
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
Comments
Wow, this is a great find. Thanks, @sechkova!! I just dug through repo tool and repo lib to see why and how this works with root-to-top-level-role delegations, as shown in the Tutorial: >>> repository.targets.add_verification_key(import_rsa_publickey_from_file('targets_key.pub'))
>>> repository.snapshot.add_verification_key(import_rsa_publickey_from_file('snapshot_key.pub'))
>>> repository.timestamp.add_verification_key(import_rsa_publickey_from_file('timestamp_key.pub')) We use the same The secret is that As a quick-and-dirty fix we could patch In the course of a rewrite that enhances the representation of the delegation graph, we should come up with a less roundabout way. What do you think? |
Totally agree with this analysis. As for the fix, I see two possibilities:
Maybe @lukpueh @joshuagl, you can give some hints on option 1, since you were involved in fixing the performance issue :) |
Iterating roledb shouldn't cause major performance regressions, it's the many calls to #1005 includes a sample script for measuring the performance of |
Great observation, @sechkova! Assuming that we use the same signing key for all hashed bins and the deepcopies in "roledb" remain the bottleneck (see 1005), then I think we're better off with 1), which might look something like this: # in generate_targets_metadata (simplified)
roleinfo = roledb.get_roleinfo(targets_role) # very expensive
for delegation in delegations_for_targets_role: # not so expensive
if has_new_keys(delegation):
add_keys_to_roleinfo()
roledb.update_roleinfo(roleinfo) # very expensive
# ... add fileinfo and write delegating role OTOH, in 2) we'll have an additional read/write cycle for each hashed bin, e.g: def add_verification_key(self, new_key): # (simplified)
# ...
# ...
roleinfo = roledb.get_roleinfo(self.get_delegating_role())
add_keys_to_role_info()
roledb.update_roleinfo(role_info)
for hashed_bin_name in hashed_bin_names: # eg. 16k iterations (very expensive)
repository.targets(hashed_bin_name).add_verification_key(new_key) Does this make sense? Please let me know what you think. |
Oh, didn't see that you commented before me, @joshuagl. But it seems like we came to the same conclusion. :) |
Now I see it, same or most likely bigger overhead plus the additional complications in 2) 👀 Thank you both, let's go for 1) and I will share what are the performance results using the script @joshuagl pointed. |
It is worth mentioning that the approach we agreed upon here (collecting and updating the delegations metadata during |
Resolved in #1074 |
Uh oh!
There was an error while loading. Please reload this page.
Description of issue:
When adding a new key to a delegated role e.g.:
repository.targets('unclaimed').add_verification_key(public_new_key)
the delegating role metadata (e.g.
targets.json
) is not updated with the new key.Steps to reproduce:
Delegated role's internal metadata:
targets.json:
Delegated role's metadata is updated:
targets.json keeps the old key:
Current behavior:
The delegating role metadata is not updated when a delegation key is updated
Expected behavior:
The delegating role metadata is kept up to date with the latest delegation keys
The text was updated successfully, but these errors were encountered: