Raise error on empty 'signatures' list

Modify  check_signable_object_format() to raise an error
if signable has an empty 'signatures' list.

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
This commit is contained in:
Teodora Sechkova 2020-07-16 11:23:11 +03:00
parent 461663f363
commit d3c612bb53
No known key found for this signature in database
GPG key ID: 65F78F613EA1914E

View file

@ -938,6 +938,9 @@ def check_signable_object_format(signable):
securesystemslib.exceptions.FormatError, if 'signable' does not have the
correct format.
tuf.exceptions.UnsignedMetadataError, if 'signable' does not have any
signatures
<Side Effects>
None.
@ -965,6 +968,10 @@ def check_signable_object_format(signable):
six.raise_from(securesystemslib.exceptions.FormatError(
'Unrecognized type ' + repr(role_type)), error)
if not signable['signatures']:
raise tuf.exceptions.UnsignedMetadataError('Signable object of type ' +
repr(role_type) + ' has no signatures ', signable)
# 'securesystemslib.exceptions.FormatError' raised if 'signable' does not
# have a properly formatted role schema.
schema.check_match(signable['signed'])