-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for custom object in tuf targets metadata #99
Comments
Although #100 works, it would probably be more convenient only to allow custom metadata for archives. This would simplify the interface, and it makes more sense, because all the client app will ever see is the Perhaps keep the patch option for internal use? |
In some cases it is convenient to store custom metadata for tufup's internal use. Examples are the tar size and hash data from #105 and the "required" flag from #111. To prevent key clashes, it would be preferable to separate this internal custom metadata from any user-specified custom metadata. Moreover, the internal metadata should be hidden from casual users, to prevent confusion. The cleanest approach would probably be to separate the TUF CUSTOM object into a TUFUP object and a USER object, as follows: {
"custom": {
"tufup": {},
"user": {}
}
} Methods need to be updated to ensure the casual user is only aware of the USER object. |
Description
TUF targets metadata objects support an optional
custom
object, which can be used to specify additional information about the individual target files.From the TUF spec:
This offers endless possibilities, for example:
Implementation
This requires changes both on the repo side and on the client side:
Repository.add_bundle()
.Client.check_for_updates()
method returns aTargetMeta
, which looks like the perfect place to include the custom metadata. DO NOTE: theTargetMeta
object returned is always that of the full archive, even if a patch update will be applied. So, on the repo-side, any custom metadata required by the user application would need to be added to the archive target, not the patch target.Notes
In python-tuf (
tuf.api.metadata
), the custom object is represented by theTargetFile.custom
property.Judging from the source, the
custom
property can be set by adding a'custom'
member to theTargetFile.unrecognized_fields
dictionary. For example:EDIT:
Actually, all
unrecognized_fields
are included in the metadata, as can be seen in the source.So,
custom
is nothing special in that respect, but it's the only "unrecognized field" that's defined in the spec and has a corresponding property.Also note that python-tuf does not check whether the value assigned to
custom
is actually adict
(which maps to a JSON object). The spec does not provide an explicit definition of the term object, but it uses "a subset of the JSON object format", so we'll assume object implies the equivalent of a JSON object (which is adict
in Python).The text was updated successfully, but these errors were encountered: