Skip to content

Commit 97f0fdb

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 226c9ae commit 97f0fdb

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
@@ -2024,7 +2024,9 @@ def _update_metadata_if_changed(self, metadata_role,
20242024

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

26252627
roles_to_update = []
26262628

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

26302636
if refresh_all_delegated_roles:

0 commit comments

Comments
 (0)