@@ -44,8 +44,8 @@ def __init__(self, consistent_snapshot: bool = True, expiration: relativedelta =
44
44
# And you would use this method to populate it from a file.
45
45
def read_from_json (self , filename : str ) -> None :
46
46
signable = load_json_file (filename )
47
+ tuf .formats .SIGNABLE_SCHEMA .check_match (signable )
47
48
48
- # TODO: use some basic schema checks
49
49
self .signatures = signable ['signatures' ]
50
50
self .signed = signable ['signed' ]
51
51
@@ -130,6 +130,10 @@ class Timestamp(Metadata):
130
130
def __init__ (self , consistent_snapshot : bool = True , expiration : relativedelta = relativedelta (days = 1 ), keyring : KeyRing = None , version : int = 1 ):
131
131
super ().__init__ (consistent_snapshot , expiration , keyring , version )
132
132
133
+ def read_from_json (self , filename : str ) -> None :
134
+ super ().read_from_json (filename )
135
+ tuf .formats .TIMESTAMP_SCHEMA .check_match (self .signed )
136
+
133
137
def signable (self ):
134
138
expires = self .expiration .replace (tzinfo = None ).isoformat ()+ 'Z'
135
139
filedict = self .signed ['meta' ]
@@ -151,6 +155,8 @@ def __init__(self, consistent_snapshot: bool = True, expiration: relativedelta =
151
155
152
156
def read_from_json (self , filename : str ) -> None :
153
157
super ().read_from_json (filename )
158
+ tuf .formats .SNAPSHOT_SCHEMA .check_match (self .signed )
159
+
154
160
meta = self .signed ['meta' ]
155
161
for target_role in meta :
156
162
version = meta [target_role ]['version' ]
@@ -175,13 +181,13 @@ def __init__(self, consistent_snapshot: bool = True, expiration: relativedelta =
175
181
self .targets = {}
176
182
self .delegations = {}
177
183
178
-
179
184
def read_from_json (self , filename : str ) -> None :
180
185
super ().read_from_json (filename )
186
+ tuf .formats .TARGETS_SCHEMA .check_match (self .signed )
187
+
181
188
self .targets = self .signed ['targets' ]
182
189
self .delegations = self .signed .get ('delegations' , None )
183
190
184
- # FIXME
185
191
def signable (self ):
186
192
# TODO: probably want to generalise this, a @property.getter in Metadata?
187
193
expires = self .expiration .replace (tzinfo = None ).isoformat ()+ 'Z'
0 commit comments