Skip to content

Commit 77cb66b

Browse files
committed
Metadata API: Fix role lookup for succinct delegation
get_delegated_role() should not return a Role if the rolename is not a delegated role. This is already true for "normal" DelegatedRole but was not actually verified for SuccinctRoles. Signed-off-by: Jussi Kukkonen <[email protected]>
1 parent 929174c commit 77cb66b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tuf/api/metadata.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2044,10 +2044,13 @@ def get_delegated_role(self, delegated_role: str) -> Role:
20442044
if self.delegations is None:
20452045
raise ValueError("No delegations found")
20462046

2047+
role: Optional[Role] = None
20472048
if self.delegations.roles is not None:
2048-
role: Optional[Role] = self.delegations.roles.get(delegated_role)
2049-
else:
2050-
role = self.delegations.succinct_roles
2049+
role = self.delegations.roles.get(delegated_role)
2050+
elif self.delegations.succinct_roles is not None:
2051+
succinct = self.delegations.succinct_roles
2052+
if succinct.is_delegated_role(delegated_role):
2053+
role = succinct
20512054

20522055
if not role:
20532056
raise ValueError(f"Delegated role {delegated_role} not found")

0 commit comments

Comments
 (0)