Skip to content

Commit

Permalink
WIP: Consistency
Browse files Browse the repository at this point in the history
Ensure a delegation only has paths or path_hash_prefixes in roledb

Signed-off-by: Joshua Lock <[email protected]>
  • Loading branch information
joshuagl committed Mar 30, 2020
1 parent 5ea1f63 commit 74d6973
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tuf/repository_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -2334,13 +2334,14 @@ def delegate(self, rolename, public_keys, paths, threshold=1,
'terminating': terminating,
'paths': list(roleinfo['paths'].keys())}

# A role in a delegations must list either 'path_hash_prefixes'
# or 'paths'.
if paths:
roleinfo['paths'] = paths
del roleinfo['path_hash_prefixes']

if path_hash_prefixes:
roleinfo['path_hash_prefixes'] = path_hash_prefixes
# A role in a delegations must list either 'path_hash_prefixes'
# or 'paths'.
del roleinfo['paths']

current_roleinfo['delegations']['roles'].append(roleinfo)
Expand Down

0 comments on commit 74d6973

Please sign in to comment.