16
16
disable check as there might be a justified reason to write WIP
17
17
metadata to json.
18
18
19
+ - consider using in-toto style ValidationMixin, e.g.:
20
+ https://github.com/in-toto/in-toto/blob/74da7a/in_toto/models/common.py#L27-L40
21
+ https://github.com/in-toto/in-toto/blob/74da7a/in_toto/models/layout.py#L420-L438
22
+
19
23
* Add Root metadata class
20
24
21
25
* Add classes for other complex metadata attributes, see 'signatures' (in
22
26
Metadata) 'meta'/'targets' (in Timestamp, Snapshot, Targets), 'delegations'
23
27
(in Targets), 'keys'/'roles' (in not yet existent 'Delegation'), ...
24
28
29
+ * Ticketize this todo list (on GitHub)
30
+
25
31
"""
26
32
# Imports
27
33
from datetime import datetime , timedelta
39
45
)
40
46
from securesystemslib .storage import StorageBackendInterface
41
47
from securesystemslib .keys import create_signature , verify_signature
42
- from tuf .repository_lib import (
43
- _strip_version_number
44
- )
45
48
46
- import iso8601
47
49
import tuf .formats
48
50
import tuf .exceptions
49
51
@@ -213,8 +215,9 @@ def sign(self, key: JsonDict, append: bool = False) -> JsonDict:
213
215
214
216
Arguments:
215
217
key: A securesystemslib-style private key object used for signing.
216
- append: A boolean indicating if the signature should be appended
217
- to the list of signatures or replace them.
218
+ append: A boolean indicating if the signature should be appended to
219
+ the list of signatures or replace any existing signatures. The
220
+ default behaviour is to replace signatures.
218
221
219
222
Raises:
220
223
securesystemslib.exceptions.FormatError: Key argument is malformed.
@@ -275,7 +278,7 @@ def verify(self, key: JsonDict) -> bool:
275
278
class Signed :
276
279
"""A base class for the signed part of TUF metadata.
277
280
278
- Objects with base class Signed are usually included in a Metablock object
281
+ Objects with base class Signed are usually included in a Metadata object
279
282
on the signed attribute. This class provides attributes and methods that
280
283
are common for all TUF metadata types (roles).
281
284
@@ -284,7 +287,7 @@ class Signed:
284
287
version: The metadata version number.
285
288
spec_version: The TUF specification version number (semver) the
286
289
metadata format adheres to.
287
- expires: The metadata expiration date in 'YYYY-MM-DDTHH:MM:SSZ' format.
290
+ expires: The metadata expiration datetime object
288
291
289
292
"""
290
293
# NOTE: Signed is a stupid name, because this might not be signed yet, but
@@ -308,14 +311,15 @@ def __init__(
308
311
309
312
# Deserialization (factories).
310
313
@classmethod
311
- def from_dict (cls , signed_dict ) -> 'Signed' :
314
+ def from_dict (cls , signed_dict : JsonDict ) -> 'Signed' :
312
315
"""Creates Signed object from its JSON/dict representation. """
313
316
314
317
# Convert 'expires' TUF metadata string to a datetime object, which is
315
318
# what the constructor expects and what we store. The inverse operation
316
319
# is implemented in 'to_dict'.
317
- signed_dict ['expires' ] = iso8601 .parse_date (
318
- signed_dict ['expires' ]).replace (tzinfo = None )
320
+ signed_dict ['expires' ] = datetime .strptime (
321
+ signed_dict ['expires' ],
322
+ "%Y-%m-%dT%H:%M:%SZ" ).replace (tzinfo = None )
319
323
# NOTE: We write the converted 'expires' back into 'signed_dict' above
320
324
# so that we can pass it to the constructor as '**signed_dict' below,
321
325
# along with other fields that belong to Signed subclasses.
0 commit comments