Commit graph

4754 commits

Author SHA1 Message Date
Kairo de Araujo
2f4565e100 Add to CI check for specification version.
This commit adds to the CI an automatic check for the TUF
specification version and compares it with the python-tuf metadata
API version.

If the version does not match and there is not a issue already open,
a new issue is opened.

Closes #1598

Signed-off-by: Kairo de Araujo <kdearaujo@vmware.com>
2022-01-11 08:51:40 +01:00
Jussi Kukkonen
61ffc9ff81
Merge pull request #1762 from MVrachev/fix-pylint-warning
Fix two new pylint warnings
2022-01-11 09:08:12 +02:00
Martin Vrachev
b47ef92833 Fix pylint warnings
New pylint warnings appeared related to changes
in urlib3:
- tests/test_fetcher_ng.py:128: error: Argument 1 to "ReadTimeoutError"
has incompatible type "None"; expected "ConnectionPool"  [arg-type]
- tests/test_fetcher_ng.py:128: error: Argument 2 to "ReadTimeoutError"
has incompatible type "None"; expected "str"  [arg-type]
I noticed these error in this CI run:
https://github.com/theupdateframework/python-tuf/runs/4764931441?check_suite_focus=true

I fixed them by creating a urllib3.HTTPConnectionPool() instance as
the first argument and replaced the second argument with an empty
string.
This seems to do the job.

Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
2022-01-10 19:56:29 +02:00
Jussi Kukkonen
45cf6076e3
Merge pull request #1703 from ivanayov/test_loading_of_cached_metadata
Test loading of cached metadata in ngclient
2022-01-07 16:13:01 +02:00
Ivana Atanasova
d27c0fd585 Test loading of cached metadata in ngclient
After making a successful update of valid metadata which stores it
in cache and performing a second update with a new updater while
the metadata is already stored in cache, this test verifies that
timestamp, snaphot and targets are loaded from cache and not
downloaded

Fixes #1681

Signed-off-by: Ivana Atanasova <iyovcheva@vmware.com>
2022-01-07 16:02:55 +02:00
Jussi Kukkonen
3d4df876c2
Merge pull request #1741 from sechkova/remove-updater-with-sim
Remove test_updater_with_simulator.py
2022-01-07 12:54:43 +02:00
Jussi Kukkonen
d8591e78a9
Merge pull request #1742 from kairoaraujo/issue#1713/test_fast-forward_recovery_targets
test targets fast-forward attack recovery
2022-01-07 11:23:40 +02:00
Jussi Kukkonen
4917a5c134
Merge pull request #1749 from MVrachev/custom-doc
Add TargetFile.custom() documentation when building readthedocs
2022-01-07 10:47:45 +02:00
Jussi Kukkonen
f0f58386d6
Merge pull request #1755 from jku/trivial-doc-fix
docs: Fix Updater.find_cached_target() docstring
2022-01-07 10:44:11 +02:00
Jussi Kukkonen
b12a67c047
Merge pull request #1738 from kairoaraujo/issue#1713/test_fast-forward_recovery_snapshot
test snapshot fast-forward attack recovery
2022-01-07 10:43:55 +02:00
Martin Vrachev
0c9764925d Make make TargetFile.custom() visible in the docs
By adding a docstring to the property RTD noticed custom and
documented it.

Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
2022-01-05 16:45:25 +02:00
Martin Vrachev
79df859078 Metadata API simplify dictionary.get() call
Dictionary.get() by default will return "None" if the key is not
found as documented in:
https://docs.python.org/3/library/stdtypes.html#dict.get
This means we don't get anything by passing the default type.

Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
2022-01-05 16:21:04 +02:00
Joshua Lock
537a0198b4
Merge pull request #1743 from lukpueh/rm-metadata-api-bump_expiration
Metadata API: Remove Signed.bump_expiration() method
2022-01-05 12:08:24 +00:00
Jussi Kukkonen
c46ee17f70 docs: Fix Updater.find_cached_target() docstring
This fixes broken layout on RTD.

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2022-01-05 13:04:56 +02:00
Kairo de Araujo
5b4a47a067 test targets fast-forward attack recovery
This test simulates the targets fast-forward attack recovery.
It simulates that the targets keys were compromised, the attacker
generated a new high version of the targets.

The repository generates new key for snapshot to rollback the
targets version to the initial version.

Signed-off-by: Kairo de Araujo <kdearaujo@vmware.com>
2022-01-04 15:14:16 +01:00
lukpueh
d51b19f4a2
Merge pull request #1744 from lukpueh/fix-1.0.0-announcement-links
doc: fix broken links in 1.0.0-ANNOUNCEMENT.md
2021-12-22 12:44:08 +01:00
Lukas Puehringer
d3ef746f7c doc: fix broken links in 1.0.0-ANNOUNCEMENT.md
The recent move of 1.0.0-ANNOUNCEMENT.md (#1732) broke the
relative links in the document.

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
2021-12-22 12:28:25 +01:00
Teodora Sechkova
672df74ce8
Remove test_updater_with_simulator.py
Move the remaining
test_snapshot_rollback_with_local_snapshot_hash_mismatch
to test_updater_top_level_update.py and remove the file.

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
2021-12-22 13:23:36 +02:00
Teodora Sechkova
aadc6fdc70
Remove test_keys_and_signatures
Key rotations and metadata update are now extesively tested in:
- test_updater_key_rotations.py
- test_updater_top_level_update.py

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
2021-12-22 13:23:35 +02:00
Teodora Sechkova
1cfa249dea
Move test_not_loading_targets_twice
Move test_not_loading_targets_twice to
test_updater_top_level_update.py.

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
2021-12-22 13:23:35 +02:00
Teodora Sechkova
21ad93779f
Move test_fishy_rolenames
Move test_fishy_rolenames to test_updater_delegation_graphs.py
and update the test setup.

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
2021-12-22 13:23:33 +02:00
Teodora Sechkova
82a68a6f95
Remove TestUpdater.test_reftesh
Remove TestUpdater.test_refresh from test_updater_with_simulator.
Testing refresh() is now extensively covered in the newly added
test_updater_top_level_update.py.

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
2021-12-22 13:21:58 +02:00
Teodora Sechkova
e752193088
Merge pull request #1728 from sechkova/test-fetch-target
ngtests: Test fetch target
2021-12-22 13:10:31 +02:00
Teodora Sechkova
ed15d111aa
Merge pull request #1711 from sechkova/test-targetfile-search
Extend delegations tests
2021-12-22 13:00:07 +02:00
Lukas Puehringer
b754c37533 doc: display inherited members on RTD
Update sphinx/rtd conf to display inherited members. This is
enabled specifically for the newly added `expires` property,
which has a useful code snippet in the docstring.

We don't display
- them on the tuf.api automodule overview page (avoid duplicates)
- members inherited from the built-in Exception class

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
2021-12-22 11:40:46 +01:00
Lukas Puehringer
9f2c593813 Metadata API: Remove Signed.bump_expiration()
Remove `bump_expiration()` method, which is unlikely to be used as
is, i.e.  bump to "current expiration date plus delta". A more
realistic use case is to bump to "now plus delta" (see #1727 for
details).

Moreover, bump_expiration can either way easily be replaced by a
one-liner expression using the 'datetime' module. A corresponding
code snippet is added to the `expires` property's docstring.  Note:
`expires` became a property with a millisec-removing setter (for
spec conformance) in  #1712, which further reduces the need for a
convenience bump_expiration method.

This patch also removes a related unit test and updates another
one.

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
2021-12-22 11:40:36 +01:00
Kairo de Araujo
ac7a804525 remove roles names as str, snapshot order
This commit removes the role names as strings. Also do a slight
change for clarity.

Signed-off-by: Kairo de Araujo <kdearaujo@vmware.com>
2021-12-21 14:35:33 +01:00
Teodora Sechkova
d1bc20111c
Define a TestTarget dataclass
Use a dataclass for a better representation of
the target files in the test data set.

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
2021-12-21 13:25:51 +02:00
Teodora Sechkova
adcaf583ef
Add test_invalid_target*
Add test cases covering downloading and loading from cache
targets with non-matching hash and length.

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
2021-12-21 12:57:27 +02:00
Teodora Sechkova
e513460be4
Rename and simplify test_targets
Remove parts of the test case which are covered in other
tests, this way making its purpose clearer.

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
2021-12-21 12:57:26 +02:00
Teodora Sechkova
7af7836537
Add tests/test_updater_fetch_target.py
Add a new test file and class for testing target files
fetching.
Move test_targets from test_updater_with_simulator.py to
tests/test_updater_fetch_targets.py.

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
2021-12-21 12:57:26 +02:00
Teodora Sechkova
36eaffaa64
Add TestTargetCase dataclass
Use a dataclass for a better visual representation of
the test case data set.

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
2021-12-21 12:12:08 +02:00
lukpueh
cc2326d3ca
Merge pull request #1736 from lukpueh/rm-metadata-api-update
Metadata API: Remove 3 'update' methods + tests
2021-12-21 10:52:32 +01:00
lukpueh
1f3654fb97
Merge pull request #1712 from ivanayov/no_microseconds_in_api_for_signed_expires
Remove microseconds from metadata API Signed.expires
2021-12-21 10:14:42 +01:00
Lukas Puehringer
f22f357934 Metadata API: Remove 3 'update' methods + tests
Remove ambiguous, unspecific, opinionated and trivial 'update'
methods, which can be replaced by feasible one-liners that assign
values directly to the object attribute to be *updated*. (see #1627
for details).

Reasons to have these methods would be increased usability in terms of
- reduced work
- immediate feedback on invalid assignments

However, given above described issues, the reasons against the
methods as they are now seem to outweigh the reasons for them.
Furthermore, it seems easier to re-add similar methods, which
addressed these issues, after the upcoming 1.0.0 release than to
remove or modify them.

This patch also removes the corresponding tests as they become
irrelevant (there is no need to test object assignment).  In the
case of the timestamp test, the removal also includes redundant
test logic, which is already tested in `test_metadata_base`.

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
2021-12-21 09:48:31 +01:00
Kairo de Araujo
8a8fff303a test snapshot fast-forward attack recovery
This test simulates the snapshot fast-forward attack recovery.
It simulates that the snapshot keys were compromised, the attacker
generated a new high version of the snapshot.

The repository generates new keys for snapshot and timestamp and
rollbacks the snapshot version to the initial version.

Signed-off-by: Kairo de Araujo <kdearaujo@vmware.com>
2021-12-21 09:13:02 +01:00
Jussi Kukkonen
2e5ddd34df
Merge pull request #1735 from kairoaraujo/issue#1713/test_fast-forward_recovery
test timestamp fast-forward attack recovery
2021-12-21 10:08:14 +02:00
Teodora Sechkova
d10c8e980d
Use raw string in TestTargetFileSearch docstirng
Using a raw string allows the use of backslashes
in the docstring comment whithout them being interpreted
as an escape character.

It also silences pylint W1401: anomalous-backslash-in-string.

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
2021-12-20 19:04:09 +02:00
Teodora Sechkova
7eea3f908b
Add tests for invalid delegated role metadata
Extend TestDelegationsGraphs with a test case for
unsigned metadata.

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
2021-12-20 19:04:09 +02:00
Teodora Sechkova
6fa5d3ddd2
Add TestTargetFileSearch class
Extend test_updater_delegation_graphs.py with tests
for targets metadata search.
- create a new test class TestTargetFileSearch which creates
  a single repository and pefrorms multiple file searches in
  subtests.
- group the common functionality in a base class TestDelegations.
- extend the data classes to accomodate for target_files.

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
2021-12-20 19:04:08 +02:00
Teodora Sechkova
4fc2c19ba4
Modify delegations traversal loop condition
Reduce the number of variables in the while loop by using
len(visited_role_names) instead of number_of_delegations.
Include equality in the comparison with config.max_delegations
to account for visiting "targets". Shorten the commit message.

Add max number of delegations test case.

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
2021-12-20 19:04:06 +02:00
Kairo de Araujo
76a3e6dae2 test timestamp fast-forward attack recovery
This test simulates the timestamp fast-forward attack recovery.
It simulates that the timestamp keys were compromised, the attacker
generated a new high version of the timestamp.

The repository generates a new key and rollbacks the timestamp
version to the initial version.

Signed-off-by: Kairo de Araujo <kdearaujo@vmware.com>
2021-12-20 16:58:20 +01:00
Jussi Kukkonen
4f8d494c47
Merge pull request #1718 from jku/workflow-use-builtin-pip-cache
CI: Use builtin package cache support
2021-12-20 10:33:14 +02:00
Jussi Kukkonen
0f1fc6e33c
Merge pull request #1689 from sechkova/test_delegated_roles
Test delegation graphs
2021-12-16 11:20:20 +02:00
Jussi Kukkonen
3823fd6353
Merge pull request #1724 from kairoaraujo/doc_warnings_to_errors
turn doc build warnings into errors
2021-12-16 11:20:04 +02:00
Kairo de Araujo
7dc5940827 update CONTRIBUTORS.rst related to tox
The mention of testing using multiple Python versions by default was
removed.

Signed-off-by: Kairo de Araujo <kdearaujo@vmware.com>
2021-12-16 10:04:58 +01:00
Kairo de Araujo
4187494de9 Simplify the tox envlist and add docs
Simplified ``tox`` environ list not to expect that developer has
all multiple Python version, but instead run with the python version
available.

Also, it adds docs build to environ list.

Running ``tox`` will run the lint, docs, and py.
The CI covers the multiple supported Python versions, and the
developers still can use tox -e py{version}

Signed-off-by: Kairo de Araujo <kdearaujo@vmware.com>
2021-12-16 10:04:58 +01:00
Kairo de Araujo
9955c1af55 Add the fail on warning to the readthedocs conf
CI uses the integrated webhooks from readthedocs.

Signed-off-by: Kairo de Araujo <kdearaujo@vmware.com>
2021-12-16 10:04:58 +01:00
Kairo de Araujo
d7ab1043d9 turn doc build warnings into errors
This commit adds to the docs tox session the flag ``-W``, which
turns the warnings into errors.

The CI will fail once it gets errors.

Signed-off-by: Kairo de Araujo <kdearaujo@vmware.com>
2021-12-16 10:04:58 +01:00
lukpueh
febe6c3dc3
Merge pull request #1732 from jku/release-0.20.0
Release 0.20.0
2021-12-16 09:16:43 +01:00