Remove iso8601 dependency from simple metadata api

Use builtin datetime instead of external iso6801 for simple
datetime string parsing. Also see
https://github.com/theupdateframework/tuf/issues/1065

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
This commit is contained in:
Lukas Puehringer 2020-09-10 15:52:59 +02:00
parent 228a4c72e0
commit f106435aa5

View file

@ -22,7 +22,6 @@
from securesystemslib.storage import StorageBackendInterface
from securesystemslib.keys import create_signature, verify_signature
import iso8601
import tuf.formats
import tuf.exceptions
@ -295,8 +294,9 @@ def from_dict(cls, signed_dict: JsonDict) -> 'Signed':
# Convert 'expires' TUF metadata string to a datetime object, which is
# what the constructor expects and what we store. The inverse operation
# is implemented in 'to_dict'.
signed_dict['expires'] = iso8601.parse_date(
signed_dict['expires']).replace(tzinfo=None)
signed_dict['expires'] = datetime.strptime(
signed_dict['expires'],
"%Y-%m-%dT%H:%M:%SZ").replace(tzinfo=None)
# NOTE: We write the converted 'expires' back into 'signed_dict' above
# so that we can pass it to the constructor as '**signed_dict' below,
# along with other fields that belong to Signed subclasses.