Skip to content

Commit eb4834d

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 2aec25e commit eb4834d

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
@@ -2117,10 +2117,13 @@ def get_delegated_role(self, delegated_role: str) -> Role:
21172117
if self.delegations is None:
21182118
raise ValueError("No delegations found")
21192119

2120+
role: Optional[Role] = None
21202121
if self.delegations.roles is not None:
2121-
role: Optional[Role] = self.delegations.roles.get(delegated_role)
2122-
else:
2123-
role = self.delegations.succinct_roles
2122+
role = self.delegations.roles.get(delegated_role)
2123+
elif self.delegations.succinct_roles is not None:
2124+
succinct = self.delegations.succinct_roles
2125+
if succinct.is_delegated_role(delegated_role):
2126+
role = succinct
21242127

21252128
if not role:
21262129
raise ValueError(f"Delegated role {delegated_role} not found")

0 commit comments

Comments
 (0)