Commit graph

79 commits

Author SHA1 Message Date
Kainaat Singh
ec68bd9316 Remove future module #1297
Signed-off-by: Kainaat Singh <kainaatsingh93@gmail.com>

remove unwanted lines
2021-04-11 11:37:45 +02:00
Velichka Atanasova
d8b3554662 Remove use of six
Remove use of six

Signed-off-by: Velichka Atanasova <avelichka@vmware.com>

Replace the use of dict.items(mydict) with mydict.items(), dict.keys(mydict) with mydict.keys() and dict.values(mydict) with mydict.values()

Signed-off-by: Velichka Atanasova <avelichka@vmware.com>

Replace 'import urllib' and 'import urllib.x' with 'from urllib import x' for vendor compatibility

Signed-off-by: Velichka Atanasova <avelichka@vmware.com>
2021-04-09 14:07:44 +03:00
Jussi Kukkonen
d5b6f91f6f imports: Remove unused imports
The linter now understands our imports (yay), and complains a lot (boo):
* Remove really unused imports
* disable lints for tuf.log and securesystemslib imports: these imports
  have logging side-effects (they set default loggers for tuf and
  securesystemslib respectively) and I'm cautious about just removing
  them

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2021-03-19 16:56:50 +02:00
Jussi Kukkonen
538623b6eb imports: Make 'keydb' imports vendoring-compatible
Use "from tuf import <module>" instead of "import tuf.<module>": this
makes it possible for vendoring tool to vendor tuf. Fix all references
to <module> in the code.

Also fix import orders so tuf internal imports are last.

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2021-03-19 16:56:50 +02:00
Jussi Kukkonen
4b66c173d8 imports: Fix securesystemslib.storage imports
Make them compatible with vendoring, use
  from securesystemslib import storage as sslib_storage
to have the same style as other securesystemslib imports.

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2021-03-19 16:56:50 +02:00
Jussi Kukkonen
46ebfd0461 imports: Fix securesystemslib.util imports
Make the import compatible with vendoring tool and alias the import so
it does not clash with the local module. Fix all references
to the module in the code.

In one instance import a specific function to avoid a more complex
redirection in the code.

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2021-03-19 16:56:50 +02:00
Jussi Kukkonen
f702fdfd0c imports: Fix securesystemslib.keys imports
Make them compatible with vendoring, use
  from securesystemslib import keys as sslib_keys
to have the same style as other securesystemslib imports.

Note that developer_tool already used a
   from securesystemslib.keys import ...
for some functions so that style was used consistently there.

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2021-03-19 16:56:50 +02:00
Jussi Kukkonen
79385cc10f imports: Fix securesystemslib.formats imports
Make the import compatible with vendoring tool and alias the import so
it does not clash with the local module. Fix all references
to the module in the code.

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2021-03-19 16:56:50 +02:00
Jussi Kukkonen
6faed27e0a imports: Fix securesystemslib.exceptions imports
Make the import compatible with vendoring tool and alias the import so
it does not clash with the local module. Fix all references
to the module in the code.

Remove a related repo.py comment that was badly duplicated from module
docstring.

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2021-03-19 16:56:50 +02:00
Jussi Kukkonen
9d7047ffc9 imports: Make 'sig' imports vendoring-compatible
Use "from tuf import <module>" instead of "import tuf.<module>": this
makes it possible for vendoring tool to vendor tuf. Fix all references
to <module> in the code.

Remove one unused import.

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2021-03-19 16:56:50 +02:00
Jussi Kukkonen
9550b1470d imports: Make 'roledb' imports vendoring-compatible
Use "from tuf import <module>" instead of "import tuf.<module>": this
makes it possible for vendoring tool to vendor tuf. Fix all references
to <module> in the code.

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2021-03-19 16:56:50 +02:00
Jussi Kukkonen
07b3aed03c imports: Make 'log' imports vendoring-compatible
Use "from tuf import <module>" instead of "import tuf.<module>": this
makes it possible for vendoring tool to vendor tuf. Fix all references
to <module> in the code.

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2021-03-19 16:56:50 +02:00
Jussi Kukkonen
4575637efd imports: Make 'formats' imports vendoring-compatible
Use "from tuf import <module>" instead of "import tuf.<module>": this
makes it possible for vendoring tool to vendor tuf. Fix all references
to <module> in the code.

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2021-03-19 16:56:47 +02:00
Jussi Kukkonen
4b078b0975 imports: Make 'exceptions' imports vendoring-compatible
Use "from tuf import <module>" instead of "import tuf.<module>": this
makes it possible for vendoring tool to vendor tuf. Fix all references
to <module> in the code.

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2021-03-19 16:54:39 +02:00
Lukas Puehringer
ff8819577b Adopt sslib keygen interface encryption changes
secure-systems-lab/securesystemslib#288 changes the key generation
interface functions in such a way that it is clear if a call opens
a blocking prompt, or writes the key unencrypted. To do this two
functions are added per key type:
 - `generate_and_write_*_keypair_with_prompt`
 - `generate_and_write_unencrypted_*_keypair`

The default `generate_and_write_*_keypair` function now only allows
encrypted keys and only using a passed password. This respects the
principle of secure defaults and least surprise.

sslib#288 furthermore adds a protected
`_generate_and_write_*_keypair`, which is not exposed publicly
because it does not encrypt by default, but is more flexible and
thus convenient e.g. to consume all arguments from a key generation
command line tool such as 'repo.py'.

This commit adds the new public functions to the tuf namespace and
adopts their usage accordingly.

NOTE regarding repo.py:
This commit does not fix any problematic password behavior of
'repo.py' like default passwords, etc. (see #881). It only adopts
the sslib#288 changes to maintain the current behvior, plus
removing one glaringly obsolete password prompt.

NOTE regarding key import:
The securesystemslib private key import functions were also changed
to no longer auto-prompt for decryption passwords , TUF, however,
only exposes custom wrappers (see repository_lib) that do
auto-prompt. sslib#288 changes to the prompt texts are nevertheless
propagated to tuf and reflected in this commit.

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
2020-11-11 10:27:56 +01:00
Teodora Sechkova
e0086d64a5
Log warning on UnsignedMetadataError in repository_lib
Except the UnsignedMetadataError generated by
check_signable_object_format() and log a warning.

When creating metadata objects on the repository side of TUF,
a use case may exist where  metadata is generated unsigned on
one machine and signed on another.

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
2020-10-02 16:05:11 +03:00
Martin Vrachev
e650670f77 Fix prefix file_prefix to support "" value
If we run the tuf unit tests with latest, not yet released,
securesyslib changes we will see that one unit test is failing
because the file_prefix argument should confront the PATH_SCHEMA
(which requires a non-empty string) but an empty string value
is passed to it.

That happens, because in tuf/developer_tool.py create_new_project
function the "location_in_repository" arg has a default value of ''
and if not changed when creating a new object of type Project
on line 650 will cause an exception in the __init__ function
because of the file_prefix argument.

Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
2020-07-07 16:24:14 +03:00
Martin Vrachev
853cdd30a4 Fix failing unit tests
Corresponding to the securesyslib changes made in this pr:
https://github.com/secure-systems-lab/securesystemslib/pull/244
which changed the securesyslib.formats.PATH schema to be of type
AnyNonemptystring.
This made the tuf unit tests to fail because there are to places
where functional arguments should comply with the
securesyslib.formats.PATH schema, but have a default value of
an empty string.

Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
2020-06-30 21:32:50 +03:00
Joshua Lock
0c0aaa97eb Port to new securesystemslib w abstract filesystem
Switch to using the new abstract files and directories support in
securesystemslib by taking an object which implements
securesystemslib.storage.StorageBackendInterface in the Repository
constructor, passed in by tuf.repository_tool.create_new_repository() and
tuf.repository_tool.load_repository()

The Updater class in tuf.client.updater does not specify a storage backend
and instead allows the functions in securesystemslib to perform the
default action of instantiating a LocalFilesystemBackend, that is the
updater does not currently support abstract filesystem backends and always
defaults to using local storage.

Finally we drop support for tuf.settings.CONSISTENT_METHOD as it's not as
clear how different copying modes should work when the details of the
underlying storage are abstracted away.

Signed-off-by: Joshua Lock <jlock@vmware.com>
2020-05-12 22:16:50 +01:00
Joshua Lock
292b18926b Use __name__ for loggers, per convention
Replace hard-coded logger names with __name__. For the most part this just uses
the standard conventions to create the same logger hierarchy as existed before.
The only real difference is that loggers created for printing during tests are
no longer part of the 'tuf' hierarchy.

Signed-off-by: Joshua Lock <jlock@vmware.com>
2020-03-03 10:36:39 +00:00
Lukas Puehringer
7306446118 Refactor repository and developer tool API
Import some API functions from repository_lib and securesystemslib
directly into repository_tool and developer_tool, instead of
providing them via wrapper.

Also short-circuit some functions that used to point to
securesystemslib through repository_lib.

This reverts parts of 6f7ba76b9b,
which introduced some of the wrappers to appease the linter.
Here we just disable that specific linter check (unused-import).

The advantage of importing over wrapping is:
- no duplication of hardcoded defaults for keyword arguments
- no duplication of docstrings
- less code --> easier maintenance

This should also pave the way for more serious refactoring
of the repository- and developer-tools:
https://github.com/theupdateframework/tuf/issues/840

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
2019-09-18 18:08:54 +02:00
lukpueh
f6bd090960
Merge pull request #912 from joshuagl/joshuagl/sslcompat
Use TUF specific formats as they have been removed from securesystemslib
2019-09-17 12:20:26 +02:00
Joshua Lock
ecb6d26206 Remove deprecated securesystemslib.formats schemas
TUF specific schemas have moved to tuf.formats, ensure they are used
throughout and remove stray references to no longer supported schemas
in securesystemslib.format

Signed-off-by: Joshua Lock <jlock@vmware.com>
2019-09-17 10:28:10 +01:00
Sebastien Awwad
a9d7053d78 Use TUF exceptions instead of SSL exceptions where appropriate
Removal of securesystemslib exceptions that are TUF-specific
occurs in securesystemslib PR #165
https://github.com/secure-systems-lab/securesystemslib/pull/165

This commit adapts to those changes.  Exceptions that are specific
to TUF should be in TUF and not in securesystemslib.  This commit
uses those already-existing TUF exceptions instead of pointing to
securesystemslib exceptions that will be removed.

For example, securesystemslib has no notion of repositories, so
it's ridiculous to have a RepositoryError in securesystemslib and
ridiculous for TUF to use
securesystemslib.exceptions.RepositoryError.

Signed-off-by: Sebastien Awwad <sebastien.awwad@gmail.com>
2019-09-17 11:19:04 +02:00
chentanjun
560d45dca2 fix-up the document spelling mistake
Signed-off-by: chentanjun <2799194073@qq.com>
2019-08-27 14:41:24 +08:00
Sebastien Awwad
a7cb2dd4ce
Resolve pylint error: remove outdated exception subscript
Python3 does not support exception subscripting:
  e.g. except ... as e:
         e[1]       # does not work in Python3

This line of code was presumably not covered by testing,
allowing it to persist.

Signed-off-by: Sebastien Awwad <sebastien.awwad@gmail.com>
2019-03-26 12:10:15 -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
Vladimir Diaz
751079fa82
Fix unit test failures in test_developer_tool.py
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-04-27 11:41:11 -04:00
Vladimir Diaz
fe5d335555
Modify modules to remove/expect no leading path separators
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-04-06 13:16:41 -04:00
Vladimir Diaz
8f65fa4154
Rename license files in modules
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-02-05 11:31:19 -05:00
Vladimir Diaz
3894bc4e31
Add copyright and license info to module files
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2017-11-30 13:23:38 -05:00
Vladimir Diaz
21a8dcacb9
Resolve remaining Pylint warning in developer_tool.py
* Fix parameter list in overridden add_verification_key so that is matches ancestor.

Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2017-11-27 14:39:23 -05:00
Vladimir Diaz
6f7ba76b9b
Resolve many Pylint warnings for developer_tool
* Remove unused import statements
* Add wrapper for interface functions
* Remove unused variables
* Fix incorrect number of arguments to modified function
* Convert non-public attributes

Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2017-11-27 11:37:46 -05:00
Vladimir Diaz
5a71ba7d68
Resolve unused and junk variables in developer_tool.py
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2017-11-20 14:10:28 -05:00
Vladimir Diaz
bb8729487d
Resolve Pylint's identified [E]rrors in the codebase
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2017-11-15 16:34:34 -05:00
Vladimir Diaz
a602d449f3
Remove compression from developer_tool.py 2017-08-25 16:59:16 -04:00
Vladimir Diaz
bcf43e63a2
Edit metadata and code for developer_tool.py 2017-08-23 12:47:20 -04:00
Vladimir Diaz
f0bf2bc65a Support multiple repositories in developer_tool.py 2017-02-08 16:45:23 -05:00
Vladimir Diaz
4abe845daf Fix import statements in various test modules 2017-01-11 17:05:46 -05:00
Vladimir Diaz
1e0cde9279 Ensure developer_tool.py imports the correct tuf.formats module 2016-11-09 14:53:07 -05:00
Artiom Baloian
299ff68edd Now crypto related files are in ssl_crypto and ssl_commons 2016-11-02 17:44:32 -04:00
Artiom Baloian
b0156944bb Moved util.py, now it is common 2016-11-02 09:49:37 -04:00
Artiom Baloian
b793c81739 Added simple_settings, now it is a requirement of TuF.
Rename conf.py into the settings.py an changed import call.
2016-11-01 15:38:40 -04:00
Artiom Baloian
b07d9a5d0f Move some part of tufformats into the common formats 2016-10-31 19:04:14 -04:00
Artiom Baloian
8247a02737 Moved TuF exceptions and schem into the ssl_commons 2016-10-31 11:58:05 -04:00
Artiom Baloian
7098cdbc3a Move _vendor dir and split formats into the formats and tufformats 2016-10-28 18:37:28 -04:00
Vladimir Diaz
f6ec7fb578 Remove _delete_obsolete_metadata() from developer_tool.py and update MANIFEST.in to list scripts. 2016-08-25 14:34:36 -04:00
Vladimir Diaz
5c7333b062 Fix unit tests for developer_tool.py 2016-07-01 12:52:04 -04:00
Vladimir Diaz
e27371113f Update developer tool 2016-04-14 16:53:48 -04:00
Vladimir Diaz
18844f6453 Initial refactor of developer tool 2016-04-05 20:23:37 -04:00