Commit graph

118 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
996b2a0f91 imports: Fix securesystemslib.settings 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
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
a7c2b8d7d8 imports: Fix securesystemslib.interface imports
Make them compatible with vendoring, use
  from securesystemslib import interface as sslib_interface
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
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
fe3daccdb5 imports: Make 'updater' import vendoring-compatible
Make the updater imports compatible with vendoring tool by importing
the Updater class directly (don't import the whole module to avoid the
clash with the obvious variable name 'updater').

Also update the example: This is not required in the clients but tuf
source code will be vendored and this import line (even though in a
comment) might trigger an error in future vendoring tool releases.

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
c66c61f1d0 imports: Make 'settings' 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
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
Joshua Lock
d4705502fc repo: make colorama a soft dependency
Instead of using colorama directly for terminal colours, use the
constants in securesystemslib.interface which map to colorama colours
IFF colorama is installed.

This change results in a red password prompt when colorama is installed
and a standard terminal output coloured prompt when colorama is not
installed.

Signed-off-by: Joshua Lock <jlock@vmware.com>
2020-10-20 15:23:39 +01:00
Martin Vrachev
946d11bca4 Make confined_target_dirs optional field
The field confined_target_dirs from the MIRROR_SCHEMA  is
a list of strings. Those strings define the accessible target
paths for that mirror. For one target to be available for that mirror,
its path should have as a prefix at least one of the strings defined
in confined_target_dirs.

That's why when confined_target_dirs is a list with one element empty
string (e.g. ['']) this means all targets files on that mirror are
available and if confined_target_dirs is empty list (e.g. []) this
would be interpreted as none of the target files is available.

This is a confusing API that could easily lead to mistakes.
That's why it's better we promote to not set confined_target_dirs
at all if a user wants targets to be available.

Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
2020-10-16 15:35:24 +03:00
Teodora Sechkova
0ebe226fb6
Re-raise exceptions explicitly using the 'from' keyword
Versions 2.6.0 and later of pylint adhere to PEP 3134
and trigger a 'raise-missing-from' warning (W0707) when
chained exceptions are raised implicitly.

The 'from' keyword is a Python3.x feature, that is why
six.raise_from is used for Python2.x compatibility.

Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
2020-08-24 13:44:09 +03:00
Jussi Kukkonen
e662f4fda0 repo.py: Decode key bytes for SHA key as well
key bytes were decoded as utf-8 for the JSON keys. Do the same for SHA
key bytes.

Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
2020-07-03 11:45:12 +03:00
lukpueh
256aef8695
Merge pull request #989 from joshuagl/logger
Use __name__ for loggers, per convention
2020-03-11 14:33:35 +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
842f843210 Remove duplicate testing simple_server.py
tests/simple_server.py was copied to tuf/scripts/ to "make testing
easier" (cf84d3f51f), although with
the current test setup the original (and recently patched to fix an
Windows/Py2 test issue) test simple_server.py can be used just as
well.

This commit:
- removes tuf/scripts/simple_server.py
  Note: that version slightly differed from the original test
  server, probably due to demands by the linter that is only executed
  on the tuf core code and not on the tests. However, for the testing
  purposes of simple_server.py these changes (i.e., `SystemRandom()`,
  `if __name__ =='__main__':`) are not necessary.
- updates the tests that used tuf.scripts.simple_server to instead
  use tests.simple_server,
- updates setup.py to not install the simple_server module as
  script, when installing tuf, as it is only a testing script and
  not meant for end-user usage.

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
2020-02-25 14:55:36 +01:00
chentanjun
04019a1bd8 fix-up some spelling mistakes
Signed-off-by: chentanjun <2799194073@qq.com>
2019-09-26 00:52:21 +08:00
chentanjun
560d45dca2 fix-up the document spelling mistake
Signed-off-by: chentanjun <2799194073@qq.com>
2019-08-27 14:41:24 +08:00
Michael Zhou
bcbb213613 Added command-line option explanations and usage examples
Signed-off-by: Michael Zhou <myz227@nyu.edu>
2018-11-03 10:48:05 -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
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
Vladimir Diaz
6683d6e25f
Generate Ed25519 key with --key, by default
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-05-18 15:11:20 -04:00
Vladimir Diaz
55123ab73e
Generate Ed25519 keys in repo.py, by default
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-05-18 15:07:52 -04:00
Vladimir Diaz
0892812feb
Remove unused 'e' variable
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-04-18 10:53:49 -04:00
Vladimir Diaz
33734d31fd
Remove unused variables
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-04-18 10:52:26 -04:00
Vladimir Diaz
52519c8c34
Remove unused imports
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-04-18 10:48:56 -04:00
Vladimir Diaz
affc884c95
Fix 'tuf.exception' typo to resolve pylint warning
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-04-17 17:00:13 -04:00
Vladimir Diaz
dc9fedf9db
Resolve undefined variable warnings in repo.py
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-04-17 15:46:43 -04:00
Vladimir Diaz
9cd8a6d6a3
Resolve pylint warnings in client.py for 'redefined variable'
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-04-17 15:29:17 -04:00
Vladimir Diaz
7021dba285
Remove unused import statement in client.py
Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
2018-04-17 15:25:20 -04:00