Commit graph

1687 commits

Author SHA1 Message Date
Sebastien Awwad
264186fa51
Session index: hostname-indexed --> scheme+hostname-indexed
In order to avoid re-using session data from an HTTPS connection
in an HTTP connection. Some cookies may not be HTTP-safe.

Signed-off-by: Sebastien Awwad <sebastien.awwad@gmail.com>
2018-09-10 16:56:02 -04:00
Sebastien Awwad
4595ab839a
Remove unused os import in tuf.download
It is not longer used, and pylint complains if it's left in.

Signed-off-by: Sebastien Awwad <sebastien.awwad@gmail.com>
2018-09-10 16:30:32 -04:00
Sebastien Awwad
a5416d4baa
Raise helpful error in download.py if cannot parse URL
to extract hostname. After commit
"use a different session per hostname",
the code no longer raises MissingSchema if a URL is malformed in
certain cases. Since it parses URLs to extract the hostname and
would have raised securesystemslib.exceptions.FormatError, so the
test would have to check for that error instead of requests's
MissingSchema.

However, it's best to use a different error type, since while that
would be, true enough, a formatting error, FormatError is customarily
reserved for the automatic detection based on schemas in formats.py
(using <SCHEMA>.check_match()), and in any case it is not a
securesystemslib error.

So this commit adds error type tuf.exceptions.URLParsingError and
raises it if the hostname cannot be isolated in a URL, and checks
for it in test_download.py.

Signed-off-by: Sebastien Awwad <sebastien.awwad@gmail.com>
2018-09-10 16:30:32 -04:00
Sebastien Awwad
d199610f94
DOC: Clarify and correct comments on download timeouts
and call out need for more testing in a comment.

Signed-off-by: Sebastien Awwad <sebastien.awwad@gmail.com>
2018-09-10 16:30:32 -04:00
Sebastien Awwad
8951e8b9a8
Style fixes in download.py within PR 781 changes
- Remove trailing whitespace
- Fix indent sizes (4 if continuing line, else 2)
- Fix line continuation to match PEP 8 and lab code guidelines

Also fixes one minor typo.

Signed-off-by: Sebastien Awwad <sebastien.awwad@gmail.com>
2018-09-10 16:30:32 -04:00
Sebastien Awwad
cc4628735a
Raise ReadTimeoutError from requests as TUF SlowRetrievalError
so as to preserve 'API' of expected errors.

Signed-off-by: Sebastien Awwad <sebastien.awwad@gmail.com>
2018-09-10 16:30:32 -04:00
Trishank K Kuppusamy
f29622b2c6
add debug statements
Signed-off-by: Sebastien Awwad <sebastien.awwad@gmail.com>
2018-09-10 16:30:27 -04:00
Trishank K Kuppusamy
c25ce7c3be
use a different session per hostname
Signed-off-by: Sebastien Awwad <sebastien.awwad@gmail.com>
2018-09-10 16:30:06 -04:00
Sebastien Awwad
314f6e71b9
Remove partial single-source version; add comments explaining
Previous commit isn't going to work: read wasn't defined. Code
provided was from here:
https://packaging.python.org/guides/single-sourcing-package-version/

and is a little more complicated than is ideal. It'll also match
comment lines if they exist. Single-sourcing version number isn't
necessary for this pull request, but if I was going to do it, I'd
probably add a VERSION file and have tuf/__init__.py and setup.py
each read that in. There could be problems with that, too. I'm
going to punt on this and keep the version in two places and we
can fix that less urgently. (Also, the user agent reporting a
version seems less critical in any case than the rest of the PR.)

Version info will now be in two locations and require update in
tandem.

Signed-off-by: Sebastien Awwad <sebastien.awwad@gmail.com>
2018-09-10 16:29:59 -04:00
Trishank K Kuppusamy
34e0ec7c62
Add TUF version number, and user agent
Signed-off-by: Sebastien Awwad <sebastien.awwad@gmail.com>
2018-09-10 16:29:48 -04:00
Sebastien Awwad
1e97275b9a
minor: undo some import/dependency re-ordering
(sorry -- just to keep things simple)

Signed-off-by: Sebastien Awwad <sebastien.awwad@gmail.com>
2018-08-31 13:28:43 -04:00
Trishank K Kuppusamy
b9bc8602c2
Update TUF to handle HTTPS proxies
Signed-off-by: Trishank K Kuppusamy <trishank.kuppusamy@datadoghq.com>
2018-08-31 13:18:35 -04:00
Sebastien Awwad
d98152bc9d
Remove some unnecessary try-reraise constructions; thanks, pylint!
These changes simplify logic, removing some try/except structures
that were unnecessary and potentially confusing, and get us back
to passing pylint's test.

pylint 2.0.0 adds try-except-raise tests, to catch immediate
re-raising after catching an exception, outside of some special
cases. See this GitHub comment for more info:
https://github.com/theupdateframework/tuf/pull/770#issuecomment-412993992

Signed-off-by: Sebastien Awwad <sebastien.awwad@gmail.com>
2018-08-21 14:59:29 -04:00
Sebastien Awwad
85c9c3aeee
Have repository_tool.get_filepaths_in_directory use absolute paths
as its docstring says that it does. I'm not sure if this changed through
some accident along the way, but in any case, before this commit, the
docstring said that it yielded a list of absolute paths, but it did not.

Now it does.

Signed-off-by: Sebastien Awwad <sebastien.awwad@gmail.com>
2018-08-20 13:29:09 -04:00
Vladimir Diaz
e42874db46
Catch tuf.exceptions.Error in client.py to prevent printing exception trace
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-06-28 12:38:55 -04:00
Vladimir Diaz
a300122978
Reorder the parsed command-line arguments and add missing options to docstring
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-06-28 12:37:54 -04:00
Vladimir Diaz
d24f826009
Condense the code that sets the logging level
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-06-28 11:51:19 -04:00
Vladimir Diaz
56aa91239b
Use guard clause and comment on expected exceptions raised by try block
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-06-28 11:34:59 -04:00
Vladimir Diaz
839c646204
Convert lists to sets, use == instead of membership operator, remove unneeded write()
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-06-28 11:02:36 -04:00
Vladimir Diaz
16071e0421
Use set() instead list() for supported key types, and revise comment
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-06-27 17:58:38 -04:00
Vladimir Diaz
609889fa24
Use guard clause and set a constant for the list of supported CLI key types
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-06-27 17:44:28 -04:00
Vladimir Diaz
5e94dd3f08
Use consistent number of blank lines between functions
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-06-27 17:28:47 -04:00
Vladimir Diaz
8a7e0fc4b0
Add constants for the keytypes specified on the command line
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-06-27 16:54:32 -04:00
Vladimir Diaz
52ed7a2a04
Add note about using multile options in invocation, and add TODO
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-06-27 16:06:10 -04:00
Vladimir Diaz
725d809c65
Rename process_arguments() and revise docstring, remove TODO, minor changes
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-06-27 15:42:03 -04:00
Vladimir Diaz
97021b4e16
Revise help description for --init
It should mention the files/directories that are created.

Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-06-26 17:20:33 -04:00
Vladimir Diaz
4ee3537d6d
Prompt for password if one isn't given and the key file is encrypted
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-06-21 14:58:36 -04:00
Vladimir Diaz
1197ab9cf8
Make sure importing a private key follows the behavior covered in TUTORIAL.md
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-06-21 13:58:19 -04:00
Vladimir Diaz
31f8f0566d
Add/revise entries in docstrings
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-06-18 10:41:05 -04:00
Vladimir Diaz
75f95391a4
Verify the format of the log_filename argument to enable_file_logging()
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-06-15 16:03:03 -04:00
Vladimir Diaz
203fb11815
Revise exception message in enable_file_loggin()
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-06-15 15:49:40 -04:00
Vladimir Diaz
57b9cb4620
Raise an exception if a user tries to changer an unset filehandler's log level
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-06-15 14:58:07 -04:00
Vladimir Diaz
9b35d2c1e6
Add a file handler if one hasn't already been added
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-06-15 14:45:40 -04:00
Vladimir Diaz
6291b35ca8
Add disable_file_logging()
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-06-14 17:32:29 -04:00
Vladimir Diaz
fd23a54082
Add enable_file_logging() to log.py
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-06-14 11:50:41 -04:00
Vladimir Diaz
14f795db57
Disable file logging, by default, in settings.py
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-06-14 11:46:09 -04:00
Vladimir Diaz
1d0f863ef3
Edit README in tuf/client/
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-06-12 13:59:45 -04:00
Vladimir Diaz
9604224a5d
Remove all_targets() example used in docstring
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-06-12 13:07:23 -04:00
Vladimir Diaz
c7a57ec65d
Remove the remaining references to all_targets() and targets_of_role()
Note: The update example in the docstring must be revised to use get_one_valid_targetinfo()
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-06-12 12:00:58 -04:00
Vladimir Diaz
28e5fe6564
Add deprecation warning to all_targets() and targets_of_role()
Also remove references to them from a couple docstrings

Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-06-12 11:53:32 -04:00
Vladimir Diaz
6373c26032
Merge branch 'develop' into fix_736_freeze 2018-06-11 13:03:54 -04:00
Vladimir Diaz
f49316177f
Wrap the refresh() line that sets consistent snapshot
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-06-11 10:32:06 -04:00
Vladimir Diaz
9b6c91a015
Refresh delegated metadata to fix test_mix_and_match_attack.py failure
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-06-11 10:27:22 -04:00
Vladimir Diaz
e92680f850
Fix test_multiple_repositories_integration and edit whitespace in updater.py
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-06-11 10:02:11 -04:00
Vladimir Diaz
43efa42489
Document new refresh() change in its docstring
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-06-11 09:56:09 -04:00
Vladimir Diaz
18a5aa4809
Make slight revision to comment about always refreshing top-level metadata in refresh()
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-06-11 09:42:15 -04:00
Vladimir Diaz
47dbdbaf5c
Discuss the special case where metadata is marked obselete and deleted
Also document the assumption that the metadata store is the latest and exists in _update_metadata()

Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-06-08 10:20:34 -04:00
Vladimir Diaz
d7feacbff5
Verify --no_release with --sign, edit comment in repo.py and document change in CLI.md
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-06-07 11:03:20 -04:00
Vladimir Diaz
2e2b1dd232
Add --no_release option to repo.py
The --no_release option applies to:
(1) delegate()
(2) revoke()
(3) sign_role()
(4) add_targets()
(5) remove_targets()

Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-06-06 17:14:58 -04:00
Sebastien Awwad
e18d3db1db
Fix 736: Rebuild roledb in refresh() even if root unchanged
In order to avoid freezes if role info is deleted due to prior
validation failures, make sure that roledb is rebuilt during
client tuf.client.updater.refresh(), even if root did not need
to be updated.

See Issue 736 for more details.

Signed-off-by: Sebastien Awwad <sebastien.awwad@gmail.com>
2018-05-30 16:24:39 -04:00