Skip to content

Add root metadata class to new TUF metadata model #1137

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

Closed
lukpueh opened this issue Sep 10, 2020 · 3 comments · Fixed by #1193
Closed

Add root metadata class to new TUF metadata model #1137

lukpueh opened this issue Sep 10, 2020 · 3 comments · Fixed by #1193
Labels
enhancement good first issue Bite-sized items for first time contributors
Milestone

Comments

@lukpueh
Copy link
Member

lukpueh commented Sep 10, 2020

Description of issue or feature request:

Add root metadata class to tuf.api.metadata module and implement (de)serialisation methods (to_dict and from_dict) and adequate metadata update methods (see tuf.api.Signed-subclasses for inspiration).

Current behavior:
No Root class in tuf.api.metadata

Expected behavior:

# In tuf/api/metdata.py
class Root(Signed):
    ...
@lukpueh lukpueh added enhancement good first issue Bite-sized items for first time contributors labels Sep 10, 2020
@lukpueh lukpueh added this to the Foundations milestone Sep 10, 2020
lukpueh added a commit to lukpueh/tuf that referenced this issue Sep 10, 2020
See:
Add root metadata class to new TUF metadata model theupdateframework#1137
Add classes for complex metadata fields theupdateframework#1139
Add input validation to simple metadata api theupdateframework#1140

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
MVrachev pushed a commit to MVrachev/tuf that referenced this issue Sep 17, 2020
See:
Add root metadata class to new TUF metadata model theupdateframework#1137
Add classes for complex metadata fields theupdateframework#1139
Add input validation to simple metadata api theupdateframework#1140

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
@sechkova
Copy link
Contributor

Apologies if I had ruined someone's first issue but I needed this so I opened #1193 😁

I want to mention that in the tests I had to fix dictionaries passed by reference and afterwards used as expected updated values.
For example:

        fileinfo = snapshot.signed.meta // by reference
        hashes = {'sha256': 'c2986576f5fdfd43944e2b19e775453b96748ec4fe2638a6d2f32f1310967095'}
        fileinfo['role1.json']['version'] = 2
        fileinfo['role1.json']['hashes'] = hashes
        fileinfo['role1.json']['length'] = 123

        snapshot.signed.update('role1', 2, 123, hashes) // does not do anything really
        self.assertEqual(snapshot.signed.meta, fileinfo)

I think we should design the metadata classes in a way that discourages such usage.
Maybe #1139 is where this can take place?

@joshuagl
Copy link
Member

I want to mention that in the tests I had to fix dictionaries passed by reference and afterwards used as expected updated values.
For example:

        fileinfo = snapshot.signed.meta // by reference
        hashes = {'sha256': 'c2986576f5fdfd43944e2b19e775453b96748ec4fe2638a6d2f32f1310967095'}
        fileinfo['role1.json']['version'] = 2
        fileinfo['role1.json']['hashes'] = hashes
        fileinfo['role1.json']['length'] = 123

        snapshot.signed.update('role1', 2, 123, hashes) // does not do anything really
        self.assertEqual(snapshot.signed.meta, fileinfo)

I think we should design the metadata classes in a way that discourages such usage.
Maybe #1139 is where this can take place?

Good catch, thanks! That does seem like another good argument for using classes for metadata fields, rather than passing dicts around.

@joshuagl
Copy link
Member

fat-fingered the wrong button 🤦

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement good first issue Bite-sized items for first time contributors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants