|
73 | 73 | import securesystemslib.schema as SCHEMA |
74 | 74 |
|
75 | 75 | import tuf |
| 76 | +import tuf.formats |
76 | 77 |
|
77 | 78 | import six |
78 | 79 |
|
|
85 | 86 | # check, and an ISO8601 string should be fully verified when it is parsed. |
86 | 87 | ISO8601_DATETIME_SCHEMA = SCHEMA.RegularExpression(r'\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z') |
87 | 88 |
|
| 89 | +# An integer representing the numbered version of a metadata file. |
| 90 | +# Must be 1, or greater. |
| 91 | +METADATAVERSION_SCHEMA = SCHEMA.Integer(lo=0) |
| 92 | + |
| 93 | +VERSIONINFO_SCHEMA = SCHEMA.Object( |
| 94 | + object_name = 'VERSIONINFO_SCHEMA', |
| 95 | + version = METADATAVERSION_SCHEMA) |
| 96 | + |
88 | 97 | # A dict holding the version or file information for a particular metadata |
89 | 98 | # role. The dict keys hold the relative file paths, and the dict values the |
90 | 99 | # corresponding version numbers and/or file information. |
91 | 100 | FILEINFODICT_SCHEMA = SCHEMA.DictOf( |
92 | 101 | key_schema = securesystemslib.formats.RELPATH_SCHEMA, |
93 | | - value_schema = SCHEMA.OneOf([securesystemslib.formats.VERSIONINFO_SCHEMA, |
| 102 | + value_schema = SCHEMA.OneOf([VERSIONINFO_SCHEMA, |
94 | 103 | securesystemslib.formats.FILEINFO_SCHEMA])) |
95 | 104 |
|
96 | 105 | # A string representing a role's name. |
|
136 | 145 | minor = SCHEMA.Integer(lo=0), |
137 | 146 | fix = SCHEMA.Integer(lo=0)) |
138 | 147 |
|
139 | | -# An integer representing the numbered version of a metadata file. |
140 | | -# Must be 1, or greater. |
141 | | -METADATAVERSION_SCHEMA = SCHEMA.Integer(lo=0) |
142 | | - |
143 | 148 | # A value that is either True or False, on or off, etc. |
144 | 149 | BOOLEAN_SCHEMA = SCHEMA.Boolean() |
145 | 150 |
|
|
184 | 189 | key_schema = KEYID_SCHEMA, |
185 | 190 | value_schema = KEY_SCHEMA) |
186 | 191 |
|
| 192 | +# The format used by the key database to store keys. The dict keys hold a key |
| 193 | +# identifier and the dict values any object. The key database should store |
| 194 | +# key objects in the values (e.g., 'RSAKEY_SCHEMA', 'DSAKEY_SCHEMA'). |
| 195 | +KEYDB_SCHEMA = SCHEMA.DictOf( |
| 196 | + key_schema = KEYID_SCHEMA, |
| 197 | + value_schema = SCHEMA.Any()) |
| 198 | + |
| 199 | +# A schema holding the result of checking the signatures of a particular |
| 200 | +# 'SIGNABLE_SCHEMA' role. |
| 201 | +# For example, how many of the signatures for the 'Target' role are |
| 202 | +# valid? This SCHEMA holds this information. See 'sig.py' for |
| 203 | +# more information. |
| 204 | +SIGNATURESTATUS_SCHEMA = SCHEMA.Object( |
| 205 | + object_name = 'SIGNATURESTATUS_SCHEMA', |
| 206 | + threshold = SCHEMA.Integer(), |
| 207 | + good_sigs = KEYIDS_SCHEMA, |
| 208 | + bad_sigs = KEYIDS_SCHEMA, |
| 209 | + unknown_sigs = KEYIDS_SCHEMA, |
| 210 | + untrusted_sigs = KEYIDS_SCHEMA) |
| 211 | + |
187 | 212 |
|
188 | 213 | # A relative file path (e.g., 'metadata/root/'). |
189 | 214 | RELPATH_SCHEMA = SCHEMA.AnyString() |
@@ -811,7 +836,7 @@ def make_versioninfo(version_number): |
811 | 836 |
|
812 | 837 | # Raise 'securesystemslib.exceptions.FormatError' if 'versioninfo' is |
813 | 838 | # improperly formatted. |
814 | | - securesystemslib.formats.VERSIONINFO_SCHEMA.check_match(versioninfo) |
| 839 | + VERSIONINFO_SCHEMA.check_match(versioninfo) |
815 | 840 |
|
816 | 841 | return versioninfo |
817 | 842 |
|
|
0 commit comments