From 3accf60c7e108807c922e30ed1f2b3dcd2198a75 Mon Sep 17 00:00:00 2001 From: Lukas Puehringer Date: Thu, 10 Sep 2020 15:52:59 +0200 Subject: [PATCH] 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 --- tuf/api/metadata.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tuf/api/metadata.py b/tuf/api/metadata.py index 07042bced8..ee5ab8eed1 100644 --- a/tuf/api/metadata.py +++ b/tuf/api/metadata.py @@ -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.