Commit graph

4034 commits

Author SHA1 Message Date
Joshua Lock
8ee8e862af updater: remove magic number
Remove the magic number, a whence value of 2 for file.seek(), and instead
use the io.SEEK_END constant from the io module.

Signed-off-by: Joshua Lock <jlock@vmware.com>
2021-03-03 09:37:21 +00:00
Joshua Lock
16bd3c2358 Remove Python 2.7 from GitHub CI configuration
- Drop Python 2.7 from GitHub Actions workflows. Note: There is likely
  additional cleanup that can be done to the workflow now we no longer
  care about supporting Python 2.7.
- No longer tell dependabot to ignore idna updates.

Signed-off-by: Joshua Lock <jlock@vmware.com>
2021-03-03 09:37:21 +00:00
Joshua Lock
58aac6ee12 Update supported Python versions
Remove references to, and handling of, Python 2.7 in our project scaffolding:
- updated python_requires in setup.py to state our intent to support
  Python 3.6 and above (but not Python 4, yet)
- Drop no longer required dependencies in setup.py, and requirements-*.txt
  (further refinement of requirements files will be handled in #1161)
- Remove Python 2.7 from our tox environments

Signed-off-by: Joshua Lock <jlock@vmware.com>
2021-03-03 09:37:21 +00:00
Jussi Kukkonen
ab1520e2a7
Merge pull request #1250 from sechkova/fetcher
Abstract out the network IO
2021-03-03 09:39:25 +02:00
lukpueh
8308f85652
Merge pull request #1292 from MVrachev/patch-1
Bump securesystemslib to 0.20.0
2021-02-26 16:59:00 +01:00
Martin Vrachev
be2eba8329 Bump securesystemslib to 0.20.0
https://github.com/secure-systems-lab/securesystemslib/releases/tag/v0.20.0
https://pypi.org/project/securesystemslib/0.20.0/

Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
2021-02-26 17:48:05 +02:00
Joshua Lock
60875f912b
Merge pull request #1284 from joshuagl/joshuagl/release-v0.17.0
Prepare v0.17.0 release
2021-02-25 11:35:07 +00:00
Joshua Lock
76c0a54e75 Prepare v0.17.0 release
Signed-off-by: Joshua Lock <jlock@vmware.com>
2021-02-25 10:49:12 +00:00
Teodora Sechkova
93c6573008
Apply the new code style to fetcher docstrings
Ensure that the newly added files' docstrings adhere to the
recently adopted code style guideline (#1232).

Small code style improvements in comments and imports.

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
2021-02-24 11:41:35 +02:00
Teodora Sechkova
2af63cfd8d
Add host address as a test level constant
Use a common test level constant for defining
the host address forming the download URL on
the client side.

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
2021-02-24 11:41:34 +02:00
Jussi Kukkonen
1677ce0bf8
Move fetcher components to make API boundary clearer
* Move FetcherInterface to tuf/client/ directory: This way everything
  inside that directory is clearly part of client API, and everything
  outside _may_ be more of an implementation detail (settings is still
  an unfortunate exception)
* Keep RequestsFetcher in tuf/ for same reasons: it's just the default
  implementation, not explicitly part of client API

An even clearer division would be if we moved all the client specific
implementation details (download.py, mirrors.py, requests_fetcher.py)
to tuf/client/_internal/ but that's a larger change...

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2021-02-24 11:41:34 +02:00
Jussi Kukkonen
e9b294b57c
Add an HTTP error for Fetcher interface
A custom error is required so that updater is able to special case
403 & 404 status codes.

Rewrite the test case a bit to be more readable.

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2021-02-24 11:41:34 +02:00
Teodora Sechkova
055280b2af
Close temp file in test_proxy_use.py
Calls to safe_download and unsafe_download leave
a temporary file unclosed.

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
2021-02-24 11:41:33 +02:00
Teodora Sechkova
50b3b19392
Test downloading data in more than one chunk
Add test cases to test_fetcher and test_download that
decrease default chunk size and download data in more
than one chunk.

Small code-style improvements.

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
2021-02-24 11:41:22 +02:00
Teodora Sechkova
29e3419c7a
Apply a defensive data length check in fetch()
Use '>=' as the defensive version of the equality check.

Add a comment describing the need of a chunks() generator.

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
2021-02-23 17:58:42 +02:00
Teodora Sechkova
4f02e1ee4c
Avoid 'localhost' lookup in tests
On Windows (Github Actions) the lookup for 'localhost' takes 1 second.
This is because:
- Windows retries connect() with a timeout
- the machine has IPv6 and IPv4 but Testserver only binds the port on IPv4
- the test clients connect to 'localhost'

Since socketserver.TCPServer does not seem to support IPv6 before 3.8,
just replace 'localhost' with '127.0.0.1' in client-side URLs.

See #1257

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
2021-02-23 17:58:41 +02:00
Teodora Sechkova
aaddbd3f64
Take out connection time from download speed calculation
- Update RequestsFetcher.fetch to return a generator object.
- Update _download_file to skip connection time when calculating
average download speed.
- Write chunk to temp file before exiting the fetcher loop
on error.

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
2021-02-23 17:58:41 +02:00
Teodora Sechkova
7dc5ef6e1c
Add test_fetcher
Add unit test for requests_fetcher.py

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
2021-02-23 17:58:40 +02:00
Teodora Sechkova
6c49792776
Update tests importing tuf.download
Pass RequestsFetcher object to tuf.download functions.

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
2021-02-23 17:58:40 +02:00
Teodora Sechkova
33b89a8b99
Add fetcher as parameter to Updater class
Initialize Updater with an external implementation of
FetcherInterface. If not provided, tuf.fetcher.RequestsFetcher
is used.

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
2021-02-23 17:58:40 +02:00
Teodora Sechkova
815fe24f00
Move network IO logic to RequestsFetcher
Abstract the network IO. Move the network operations from
tuf.download to the RequestsFercher class which is TUF's
implementation of the abstract FetcherInterface.

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
2021-02-23 17:58:39 +02:00
Teodora Sechkova
41ffe7aab1
Implement RequestsFetcher class
A concrete implementation of FetcherInterface based on
the Requests library.

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
2021-02-23 17:58:39 +02:00
Teodora Sechkova
84957c87b2
Add FetcherInterface class
The new class FetcherInterface defines an interface for
abstract network download which can be implemented for a
variety of network libraries and configurations.

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
2021-02-23 17:58:38 +02:00
lukpueh
74b1549c00
Merge pull request #1288 from CrossStream/sandbox/rzr/review/master
git: Ignore generated files
2021-02-18 13:14:54 +01:00
Philippe Coval
99f12aba90 git: Ignore generated files
This will help packaging effort

Relate-to: https://github.com/theupdateframework/tuf/issues/263
Signed-off-by: Philippe Coval <rzr@users.sf.net>
Change-Id: I60cf8c5fdbe6aa4b44aebadb7f4bc13c546ad159
2021-02-18 11:38:58 +01:00
lukpueh
768f9d8b20
Merge pull request #1286 from theupdateframework/dependabot/pip/cryptography-3.4.6
Bump cryptography from 3.4.5 to 3.4.6
2021-02-17 13:26:19 +01:00
dependabot[bot]
b6fbbef903
Bump cryptography from 3.4.5 to 3.4.6
Bumps [cryptography](https://github.com/pyca/cryptography) from 3.4.5 to 3.4.6.
- [Release notes](https://github.com/pyca/cryptography/releases)
- [Changelog](https://github.com/pyca/cryptography/blob/main/CHANGELOG.rst)
- [Commits](https://github.com/pyca/cryptography/compare/3.4.5...3.4.6)

Signed-off-by: dependabot[bot] <support@github.com>
2021-02-17 10:04:12 +00:00
lukpueh
8101c9e3f4
Merge pull request #1285 from joshuagl/joshuagl/sslib-bump
Bump securesystemslib to 0.19.0
2021-02-17 10:14:26 +01:00
Joshua Lock
9dd2ef6cb1 Bump securesystemslib to 0.19.0
Bump securesystemslib to the recently released 0.19.0
https://pypi.org/project/securesystemslib/0.19.0/
https://github.com/secure-systems-lab/securesystemslib/releases/tag/v0.19.0

Signed-off-by: Joshua Lock <jlock@vmware.com>
2021-02-17 09:05:54 +00:00
Joshua Lock
021803e020
Merge pull request #1283 from jku/build-on-push-to-develop-only
CI: Limit build-on-push to develop branch only
2021-02-16 14:01:58 +00:00
Jussi Kukkonen
7c5416d5c3 CI: Limit build-on-push to develop branch only
Dependabot pushes to main repository and ends up triggering two builds
every time (one for PR, one for push): limit the rule for build-on-push
to apply to develop branch only.

If release branches are used later on they should be added to list here.

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2021-02-16 15:40:35 +02:00
Joshua Lock
ac8525a72a
Merge pull request #1280 from theupdateframework/dependabot/pip/cffi-1.14.5
Bump cffi from 1.14.4 to 1.14.5
2021-02-16 13:36:36 +00:00
dependabot[bot]
90ba71ca69
Bump cffi from 1.14.4 to 1.14.5
Bumps [cffi](https://github.com/python-cffi/release-doc) from 1.14.4 to 1.14.5.
- [Release notes](https://github.com/python-cffi/release-doc/releases)
- [Commits](https://github.com/python-cffi/release-doc/commits)

Signed-off-by: dependabot[bot] <support@github.com>
2021-02-16 13:16:07 +00:00
Joshua Lock
70f2f3951c
Merge pull request #1282 from jku/pin-cryptography
Bump Cryptography, pin the py2 version separately
2021-02-16 13:15:19 +00:00
Jussi Kukkonen
b5304e42a4 Bump Cryptography, pin the py2 version separately
On Python3 bump cryptography from 3.3.1 to 3.4.5.

On python2 bump from 3.3.1 to 3.3.2 (3.3-branch is the last branch
with python2 support).

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2021-02-16 11:57:45 +02:00
lukpueh
4ae675cb31
Merge pull request #1271 from MVrachev/setup-doc-update
Docs: change the editable venv installation order
2021-02-02 14:54:30 +01:00
Martin Vrachev
9ad55bdd84 Docs: change the editable venv installation order
If you follow the instructions we provide for our contributors in
docs/CONTRIBUTORS.rst your sys.path (used to search for imports)
will put securesystemlib project directory first and tuf directory
second.
This creates a problem with imports from tuf modules because we can
import the wrong file or on relative imports (as currently we
use in the tests when we import utils), the imports cannot be resolved.

If we change the installation order, then tuf directory will be the
first in the import resolution path and those problems will be fixed.

PS: I want to express my gratitude towards Jussi who helped me find
this problem.

Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
2021-02-02 15:10:42 +02:00
lukpueh
9401059101
Merge pull request #1268 from theupdateframework/dependabot/pip/urllib3-1.26.3
Bump urllib3 from 1.26.2 to 1.26.3
2021-01-27 11:39:43 +01:00
dependabot[bot]
dbd8575aab
Bump urllib3 from 1.26.2 to 1.26.3
Bumps [urllib3](https://github.com/urllib3/urllib3) from 1.26.2 to 1.26.3.
- [Release notes](https://github.com/urllib3/urllib3/releases)
- [Changelog](https://github.com/urllib3/urllib3/blob/1.26.3/CHANGES.rst)
- [Commits](https://github.com/urllib3/urllib3/compare/1.26.2...1.26.3)

Signed-off-by: dependabot[bot] <support@github.com>
2021-01-27 10:04:35 +00:00
lukpueh
9fe83574f0
Merge pull request #1264 from lukpueh/rm-dependabot-badge
Temporarily remove broken Dependabot badge
2021-01-18 15:46:06 +01:00
lukpueh
c72448ae41
Merge pull request #1265 from jku/maintainership-application
MAINTAINERS: Add myself
2021-01-18 15:44:38 +01:00
Jussi Kukkonen
9e34c5fd9b MAINTAINERS: Add myself
I'd like to apply for this position, let me know if you need a CV :)

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2021-01-18 12:30:56 +02:00
Lukas Puehringer
f6b93830e7 Temporarily remove Dependabot badge
The Dependabot status badge no longer works, since having
migrated from stand-alone to GitHub native in #1258.

The issue is tracked upstream in dependabot/dependabot-core#1912.

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
2021-01-18 11:15:51 +01:00
lukpueh
322c096ef7
Merge pull request #1252 from lukpueh/gh-actions-coveralls
Reinstate publishing coverage on coveralls.io
2021-01-15 14:34:31 +01:00
Joshua Lock
d524412d56
Merge pull request #1259 from lukpueh/pin-idna
Configure dependabot to ignore 'idna'
2021-01-14 12:25:18 +00:00
Lukas Puehringer
d97c2872db Re-add coveralls.io badge
A recent commit reinstates publishing of coverage data to
coveralls.io. This commit re-adds the corresponding badge which
was temporarily removed in #1242.

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
2021-01-13 13:45:03 +01:00
Lukas Puehringer
8bb0187a69 Use py3 coveralls to publish coverage on py2
Prior to this commit our GitHub workflow would set up one Python
version only for each build, which means that the commands to run
the tests and publish coverage (tox and coveralls) were run with
the same Python version as tox runs the tests in.

Given that the coveralls CLI tool dropped py2 a couple of releases
ago, this commit sets up an additional service py3 to run coveralls
(and tox) on when building for py2.

To prevent tox from using the wrong Python version to run the tests
on, this commit changes the toxenv value from the generic 'py'
(uses default python on path) to 'py27'.

For convenience and readability we use the environment variable
TOXENV instead of the tox -e option.

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
2021-01-13 13:43:46 +01:00
Lukas Puehringer
32452c4142 Configure GitHub workflow to publish coverage
Re-add coverage publishing on coveralls.io, formerly performed by
Travis CI (prior to #1242), using the coveralls cli tool according
to the documentation:
https://coveralls-python.readthedocs.io/en/latest/usage/configuration.html#github-actions-gotcha

**Considered alternatives:**
- Official coveralls GitHub action, which does not seem to work
  well for Python:
  https://github.com/coverallsapp/github-action/issues/4
  https://github.com/coverallsapp/github-action/issues/30

- Inofficial fork of that action, which seems to work better
  but had issues finding the coverage data in the tests folder,
  or the covered code respectively.
  https://github.com/AndreMiras/coveralls-python-action

Besides aforementioned issues of these actions the use of cli tools
from curated package managers seems slightly preferable over
actions from the GitHub Marketplace (see #1246).

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
2021-01-13 13:43:39 +01:00
Lukas Puehringer
cb164ec1f7 Configure dependabot to ignore 'idna'
New releases of the transitive (via 'requests') dependency 'idna'
break Python 2.7 builds. To fix this we configure dependabot to not
bump 'idna' in requirements-pinned.txt, which lists and
auto-updates all immediate and transitive dependencies for CI/CD
testing.

An alternative would be to add and restrict 'idna' in
'requirements.txt' but this is less preferable because
'requirements.txt' should only have direct dependencies.

For consulted dependabot config docs see:
https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/enabling-and-disabling-version-updates#disabling-dependabot-version-updates

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
2021-01-12 13:47:36 +01:00
lukpueh
b5f5e3f77c
Merge pull request #1258 from theupdateframework/dependabot/add-v2-config-file
Create Dependabot config file
2021-01-11 17:42:17 +01:00