Commit graph

35 commits

Author SHA1 Message Date
pakagronglb
acd7ed08d1 Update Python shebangs to explicitly use python3
Signed-off-by: pakagronglb <pakagronglebel@gmail.com>
2025-02-19 19:44:21 +07:00
Jussi Kukkonen
1d81a04707 Use __future.annotations module
This allows using some more nice annotations from 3.10
while still being compatible with even Python 3.8.

These are all annotation changes, should not modify any functionality.

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2024-11-29 12:41:09 +02:00
NicholasTanz
5c71f4f062 update python annotations
Signed-off-by: NicholasTanz <nicholastanzillo@gmail.com>
2024-11-03 23:21:23 -05:00
Jussi Kukkonen
38f309bbbf WIP: Update to new securesystemslib API
* API changes covered:
  * keys and interface modules removed
  * SSlibSigner removed
  * CryptoSigner added: this replaces the removed functionality
  * DSSE "signatures" container type changed
* Currently pins a securesystemslib main branch commit:
  this shoudl be reverted before merging, when securesystemslib
  has made a release
* tests/generated_data/generate_md.py was simplified
* Encrypted test keys in tests/repository_data/keystore were replaced
  with the unencrypted PEM versions of the same keys
* The public test keys in tests/repository_data/keystore were removed
  as they were not used anymore

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2024-04-25 14:27:54 +03:00
Nurgaleev_Mansur_908
53ac05d5d3 change utcnow() to now(timezone.utc)
Signed-off-by: Nurgaleev_Mansur_908 <mansur0158@gmail.com>
2024-02-27 21:57:46 +03:00
E3E
206c9424f1 Add to linting Configuration:
- adpot changes in dependabot.yml and remove --diff from ruff check.
- select pydocstyle, isort, pyflakes, pep8-naming, pycodestyle for ruff and ignore some small issues / add inline comments.
- adjust docstring length to 80 in various files

Signed-off-by: E3E <ntanzill@purdue.edu>
2024-02-20 00:34:47 -05:00
Jussi Kukkonen
f60fb4abc8 Metadata API: Tweak get_root_verification_result args
Change the "other" argument to optional "previous" and
handle the None case in code.

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2024-02-05 13:51:28 +02:00
Jussi Kukkonen
b8dbe307db examples: Use verification results in repo example
This is an example of using the verification resutls in a repository.

The only remaining tricky part is in _get_verification_result():
* has to figure out the delegating metadata (something we currently
  cannot provide in repository.Repository for the general case)
* Needs a special case for first root

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2024-02-03 17:10:12 +02:00
Lukas Puehringer
15dd931609 Metadata API: make new verify_delegate unaware of Metadata
Change new _Delegator.verify_delegate to take payload bytes and
signatures instead of a Metadata object and a payload serializer.

This allows using verify_delegate for payloads that do not come in
a Metadata container, but e.g. in a DSSE envelope (see #2385).

Usage becomes a bit more cumbersome, but still feels reasonable with the
recently added shortcut for default canonical bytes representation of
Metadata.signed.

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
2023-08-01 15:31:59 +02:00
Jussi Kukkonen
a69ddf1f04 ngclient,tests,examples: Use new verify_delegate()
Avoid Metadata.verify_delegate() now that it's deprecated.

Note that this commit does not try to make any code cleanups
that are now possible: this is the minimal change to use the new
API.

Future improvements can make code in TrustedMetadataSet and
Updater slightly easier to read: as an example there's no need for
TrustedMetadataSet to actually store or expose actual Metadata in its
cache -- Signed is all that's needed.

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2023-08-01 13:08:13 +02:00
Jussi Kukkonen
ba949d950f examples: Keep mypy happy
Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2023-03-08 10:27:43 +02:00
Jussi Kukkonen
75ca67ef44 repository: Add default arg for targets() and edit_targets()
The default value "targets" makes sense because now the top-level
metadata can be accessed in a standard way:
  root(), timestamp(), snapshot() and targets()
and likewise for the edit_X() functions

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2023-03-08 10:27:43 +02:00
Jussi Kukkonen
79eb91d278 Add getter functions for Signed objects
These are equivalent to the edit_X() context managers but for cases
where user is not interested in creating a new version of the metadata.

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2023-03-08 10:27:43 +02:00
Jussi Kukkonen
c3411dc59e repository: Rename snapshot()/timestamp()
New names:
  do_snapshot()
  do_timestamp()
This is in preparation of using the old names for another purpose.

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2023-03-08 10:27:43 +02:00
Jussi Kukkonen
0262a8ac49 repository: Add typed edit_*() contextmanagers
The advantage here is that code within the context can take advantage
of the correct typing. This is already visible in the example code but
is even more useful in real applications.

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2023-03-08 10:27:43 +02:00
Jussi Kukkonen
b6465ddedf examples: Add missing link in repository README
Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2023-02-08 10:53:59 +02:00
Jussi Kukkonen
46930e56c4 examples: Improve repository README
Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2023-02-08 10:27:33 +02:00
Jussi Kukkonen
d36c0cfa02 examples: Rename client example directory
Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2023-02-02 16:25:47 +02:00
Jussi Kukkonen
0998c20731 examples: Explain uploader tool in READMEs
Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2023-02-02 16:25:47 +02:00
Jussi Kukkonen
92e03d2d20 examples: Implement the upload API
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>
2023-02-02 16:25:43 +02:00
Jussi Kukkonen
efcb3cfb80 examples: Add further scaffolding for upload API
The API doesn't modify the repository yet but the data flow is there now.

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2023-02-02 16:21:52 +02:00
Jussi Kukkonen
9ec8459379 examples: Add skeleton API endpoints
Also use ThreadingHTTPServer: Using Chrome utterly breaks the non-threading
server.

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2023-02-02 16:21:52 +02:00
Jussi Kukkonen
22642ed267 examples: Update one more from_securesystemslib_key() usage
This method is now in SSlibKey

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2023-01-17 15:27:06 +02:00
Jussi Kukkonen
fd02226acb repository: Improve dosctrings
Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2022-12-17 23:09:11 +02:00
Jussi Kukkonen
48865aede9 repository: Remove sign_only argument from close()
This is only needed for threshold signing and not even used in the
example: leave it to the implementations to handle for now.

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2022-12-14 20:05:56 +02:00
Jussi Kukkonen
9e9c156288 repository: remove init argument from open()
This no longer seems needed: if the metadata store does not contain
a single version of role, then open() can assume it is initializing.

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2022-12-14 19:53:43 +02:00
Jussi Kukkonen
c1bb46b6c2 repository: Improve docstrings
Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2022-12-05 13:45:27 +02:00
Jussi Kukkonen
fdf0affcad repository: Address review comments
This is a collection of comment, documentation and logging fixes.

The noteworthy part is making it clear that repository is not stable
API yet: I think this is a good idea.

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2022-12-03 11:34:21 +02:00
Jussi Kukkonen
0f94c03756 repository: Handle linting issues
Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2022-12-02 13:40:58 +02:00
Jussi Kukkonen
69cb140cb3 examples: Add README for repository example
Tweak comments as well

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2022-12-02 13:33:14 +02:00
Jussi Kukkonen
87c74a83bc examples: Maintain a meta info cache
This is not required for the demo but is more realistic: we keep
a cache of targets versions so that we can produce a new snapshot
whenever one is needed, without accessing all of the targets metadata
to do so.

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2022-11-30 21:19:43 +02:00
Jussi Kukkonen
df6b044c5a repository: Make snapshot/targets info required properties
This does not make the examples simpler now, but it will when
there are multiple locations where snapshot/timestamp are called.

* This way the snapshot/timestamp input material is an internal detail
  of Repository and the call sites will be simpler.
* Both methods now have a "force" argument that can be used to create a
  new version regardless of meta info changes
* but implementations are now required to implement snapshot_info
  and targets_infos properties that represent the current snapshot and
  targets versions in the repository

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2022-11-30 18:44:16 +02:00
Jussi Kukkonen
314efaf3da Examples: Add repository application example
This uses the repository module to create an app that
* generates everything from scratch
* serves metadata and targets from memory
* simulates a live repository by adding new targets every few seconds

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
2022-11-28 12:13:00 +02:00
Vladimir Diaz
709ada1e65
Remove example metadata
Instead of having duplicate metadata in examples/ and tests/repository_data, retain only the metadata in tests/repository_data and link to them from METADATA.md
2017-10-11 10:38:08 -04:00
vladdd
5f94d5be0d Support ISO 8601, vendor iso8601, clean codebase. 2014-04-19 14:27:53 -04:00