Skip to content

Examples: Add repository uploader - #2241

Merged
lukpueh merged 10 commits into
theupdateframework:developfrom
jku:repository-lib-uploader
Feb 8, 2023
Merged

lukpueh merged 10 commits into
theupdateframework:developfrom
jku:repository-lib-uploader

Conversation

@jku

@jku jku commented Dec 19, 2022 •

Copy link
Copy Markdown
Member

This is a maintainer tool example using the repository module

It's slightly larger than I wish it was but still manageable:

  • the existing repository example now provides a small "uploader API" (two endpoints)
  • the uploader tool uses the API provided by repository
  • uploader tool slightly abuses ngclient Updater to get client-like interaction with the repository
  • uploader tool is a very different example of Repository class implementation: here open() gets the metadata from ngclient Updater, and close() submits to repository server
  • See README for usage example: https://github.com/jku/python-tuf/blob/repository-lib-uploader/examples/uploader/README.md

@jku
jku requested review from kairoaraujo and lukpueh December 19, 2022 17:43
@coveralls

coveralls commented Dec 19, 2022 •

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 4122381770

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 3 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.001%) to 97.683%

Files with Coverage Reduction New Missed Lines %
examples/manual_repo/hashed_bin_delegation.py 1 97.26%
tuf/api/metadata.py 2 97.67%
Totals Coverage Status
Change from base Build 4074496200: 0.001%
Covered Lines: 1315
Relevant Lines: 1338

💛 - Coveralls

Comment thread examples/uploader/_localrepo.py Outdated
Comment thread examples/uploader/uploader
@jku
jku force-pushed the repository-lib-uploader branch from 01e6101 to 0859ddc Compare December 27, 2022 12:18
@jku
jku marked this pull request as ready for review December 27, 2022 12:19
jku added 6 commits February 2, 2023 16:21
Also use ThreadingHTTPServer: Using Chrome utterly breaks the non-threading
server.

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
The API doesn't modify the repository yet but the data flow is there now.

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
This tool works with the example repository: it can be used to
* Add a delegation (this is an unsafe API corresponding to e.g.
  project creation in PyPI)
* Submit new delegated role version (this requires using signing keys
  already submitted with the delegation)

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
uploader API has two POST endpoints

/api/delegation/<ROLE>
    Accepts new delegation keys for targetpath "<ROLE>/*" to role <ROLE>.
    This data is not signed in any way: In a real service this action would
    require some external authentication.

    POST content:
        { <KEYID>: <TUF KEY> }

/api/role/<ROLE>
    accepts uploads of new versions of <ROLE> metadata. The metadata
    must be correctly signed by the keys assigned to this delegation.

    POST content:
        TUF targets metadata as json

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
@jku
jku force-pushed the repository-lib-uploader branch from 0859ddc to d36c0cf Compare February 2, 2023 14:42
@jku

jku commented Feb 2, 2023

Copy link
Copy Markdown
Member Author

rebased, updated for the recent Key changes

@lukpueh lukpueh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is super cool! Here's a first batch of comments. I still need to take a closer look at _simplerepo.py and repo changes.

Comment thread examples/uploader/README.md
Comment thread examples/uploader/README.md Outdated
Comment thread examples/uploader/README.md Outdated
Comment thread examples/uploader/README.md
Comment thread examples/uploader/README.md Outdated
Comment thread examples/uploader/README.md Outdated
Comment thread examples/uploader/_localrepo.py Outdated
Comment thread examples/repository/README.md Outdated
Comment thread examples/uploader/_localrepo.py
Comment thread examples/uploader/uploader Outdated

@lukpueh lukpueh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looked at repo and _simplerepo.py now and can only repeat what I said before: This is super cool! 🎉

Note that this was a pure CR, so I didn't actually try this out. Let's catch any issues I missed here when addressing #2228.

Comment thread examples/repository/_simplerepo.py
jku added 2 commits February 8, 2023 10:27
Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
Comment thread examples/uploader/README.md Outdated
jku added 2 commits February 8, 2023 10:53
Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
@jku
jku requested a review from lukpueh February 8, 2023 09:04
@lukpueh
lukpueh merged commit dd855b1 into theupdateframework:develop Feb 8, 2023
@jku
jku deleted the repository-lib-uploader branch December 30, 2024 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants