Skip to content

Commit 6c5d970

Browse files
committed
Metadata API: Add simple threshold validation
Probably there could be future API calls that modify "threshold" to a new value, but the problem is we don't have a clear idea if they would exist and what exactly they will do. That's why it makes sense to validate against the potential problems we can imagine - in this case, is passing a threshold below 1. Signed-off-by: Martin Vrachev <[email protected]>
1 parent 2a5bfb9 commit 6c5d970

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

tuf/api/metadata.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,8 @@ def __init__(
506506
f"keyids should be a list of unique strings,"
507507
f" instead got {keyids}"
508508
)
509+
if threshold < 1:
510+
raise ValueError("threshold should be at least 1!")
509511
self.keyids = keyids_set
510512
self.threshold = threshold
511513
self.unrecognized_fields: Mapping[str, Any] = unrecognized_fields or {}

0 commit comments

Comments
 (0)