Skip to content

Commit b158c08

Browse files
committed
Metadata API: Make sanity checks in root verification
Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
1 parent 42d3a75 commit b158c08

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

tuf/api/metadata.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,11 +986,16 @@ def get_root_verification_result(
986986
signatures: Signatures over payload bytes
987987
988988
Raises:
989-
ValueError: no delegation was found for ``delegated_role``.
989+
ValueError: no delegation was found for ``root`` or given Root
990+
versions are not sequential.
990991
"""
991992

992993
if previous is None:
993994
previous = self
995+
elif self.version != previous.version + 1:
996+
versions = f"v{previous.version} and v{self.version}"
997+
raise ValueError(
998+
f"Expected sequential root versions, got {versions}.")
994999

9951000
return RootVerificationResult(
9961001
self.get_verification_result(Root.type, payload, signatures),

0 commit comments

Comments
 (0)