@@ -175,7 +175,7 @@ def _generate_and_write_metadata(rolename, metadata_filename,
175
175
else :
176
176
logger .debug ('Not incrementing ' + repr (rolename ) + '\' s version number.' )
177
177
178
- if rolename in [ 'root' , 'targets' , 'snapshot' , 'timestamp' ] and not allow_partially_signed :
178
+ if rolename in tuf . roledb . TOP_LEVEL_ROLES and not allow_partially_signed :
179
179
# Verify that the top-level 'rolename' is fully signed. Only a delegated
180
180
# role should not be written to disk without full verification of its
181
181
# signature(s), since it can only be considered fully signed depending on
@@ -394,18 +394,15 @@ def _delete_obsolete_metadata(metadata_directory, snapshot_metadata,
394
394
else :
395
395
logger .debug (repr (metadata_role ) + ' found in the snapshot role.' )
396
396
397
-
398
-
399
397
# Strip metadata extension from filename. The role database does not
400
398
# include the metadata extension.
401
399
if metadata_role .endswith (METADATA_EXTENSION ):
402
400
metadata_role = metadata_role [:- len (METADATA_EXTENSION )]
403
-
404
401
else :
405
402
logger .debug (repr (metadata_role ) + ' does not match'
406
403
' supported extension ' + repr (METADATA_EXTENSION ))
407
404
408
- if metadata_role in [ 'root' , 'targets' , 'snapshot' , 'timestamp' ] :
405
+ if metadata_role in tuf . roledb . TOP_LEVEL_ROLES :
409
406
logger .debug ('Not removing top-level metadata ' + repr (metadata_role ))
410
407
return
411
408
@@ -850,7 +847,7 @@ def get_delegated_roles_metadata_filenames(metadata_directory,
850
847
continue
851
848
852
849
# Skip top-level roles, only interested in delegated roles.
853
- if metadata_name in [ 'root' , 'snapshot' , 'targets' , 'timestamp' ] :
850
+ if metadata_name in tuf . roledb . TOP_LEVEL_ROLES :
854
851
continue
855
852
856
853
# Prevent reloading duplicate versions if consistent_snapshot is True
@@ -1131,7 +1128,7 @@ def generate_root_metadata(version, expiration_date, consistent_snapshot,
1131
1128
# Extract the role, threshold, and keyid information of the top-level roles,
1132
1129
# which Root stores in its metadata. The necessary role metadata is generated
1133
1130
# from this information.
1134
- for rolename in [ 'root' , 'targets' , 'snapshot' , 'timestamp' ] :
1131
+ for rolename in tuf . roledb . TOP_LEVEL_ROLES :
1135
1132
1136
1133
# If a top-level role is missing from 'tuf.roledb.py', raise an exception.
1137
1134
if not tuf .roledb .role_exists (rolename , repository_name ):
@@ -1507,7 +1504,7 @@ def generate_snapshot_metadata(metadata_directory, version, expiration_date,
1507
1504
# snapshot and timestamp roles are not listed in snapshot.json, do not
1508
1505
# list these roles found in the metadata directory.
1509
1506
if tuf .roledb .role_exists (rolename , repository_name ) and \
1510
- rolename not in [ 'root' , 'snapshot' , 'timestamp' , 'targets' ] :
1507
+ rolename not in tuf . roledb . TOP_LEVEL_ROLES :
1511
1508
fileinfodict [metadata_name ] = get_metadata_versioninfo (rolename ,
1512
1509
repository_name )
1513
1510
0 commit comments