Skip to content

Commit a5db472

Browse files
committed
Don't use snapshot metadata when snapshot merkle trees are used.
This commit ensures that when snapshot merkle trees are used, the client is not looking for version information in the snapshot file, but instead waiting to download version information from the snapshot merkle tree. Another approach could be to download the snapshot merkle file early to ensure that it exists before continuing the verification. Signed-off-by: marinamoore <[email protected]>
1 parent 780f883 commit a5db472

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tuf/client/updater.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2025,7 +2025,9 @@ def _update_metadata_if_changed(self, metadata_role,
20252025

20262026
# Ensure the referenced metadata has been loaded. The 'root' role may be
20272027
# updated without having 'snapshot' available.
2028-
if referenced_metadata not in self.metadata['current']:
2028+
# When snapshot merkle trees are used, there will not be a snapshot file.
2029+
# Instead, if the snapshot merkle file is missing, this will error below.
2030+
if 'merkle_root' not in self.metadata['current']['timestamp'] and referenced_metadata not in self.metadata['current']:
20292031
raise tuf.exceptions.RepositoryError('Cannot update'
20302032
' ' + repr(metadata_role) + ' because ' + referenced_metadata + ' is'
20312033
' missing.')
@@ -2625,7 +2627,11 @@ def _refresh_targets_metadata(self, rolename='targets',
26252627

26262628
roles_to_update = []
26272629

2628-
if rolename + '.json' in self.metadata['current']['snapshot']['meta']:
2630+
# Add the role if it is listed in snapshot. If snapshot merkle
2631+
# trees are used, the snaphot check will be done later when
2632+
# the merkle tree is verified
2633+
if 'merkle_root' in self.metadata['current']['timestamp'] or
2634+
rolename + '.json' in self.metadata['current']['snapshot']['meta']:
26292635
roles_to_update.append(rolename)
26302636

26312637
if refresh_all_delegated_roles:

0 commit comments

Comments
 (0)