robotframework-crypto 0.4.1__tar.gz → 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- robotframework_crypto-1.0.0/.gitignore +130 -0
- robotframework_crypto-1.0.0/.hgignore +6 -0
- {robotframework-crypto-0.4.1 → robotframework_crypto-1.0.0}/PKG-INFO +106 -34
- robotframework-crypto-0.4.1/src/robotframework_crypto.egg-info/PKG-INFO → robotframework_crypto-1.0.0/README.rst +80 -41
- robotframework_crypto-1.0.0/atest/__init__.robot +6 -0
- robotframework_crypto-1.0.0/atest/check_leaks.py +26 -0
- robotframework_crypto-1.0.0/atest/issues/_nested/issue_23_suite.robot +22 -0
- robotframework_crypto-1.0.0/atest/issues/issue_14_plugin_arguments.robot +16 -0
- robotframework_crypto-1.0.0/atest/issues/issue_14_plugin_conceals_password.robot +17 -0
- robotframework_crypto-1.0.0/atest/issues/issue_14_plugin_uses_library_password.robot +27 -0
- robotframework_crypto-1.0.0/atest/issues/issue_14_plugin_with_library_alias.robot +17 -0
- robotframework_crypto-1.0.0/atest/issues/issue_15_regenerate_key_pair.robot +41 -0
- robotframework_crypto-1.0.0/atest/issues/issue_22_import_in_suite_setup.robot +34 -0
- robotframework_crypto-1.0.0/atest/issues/issue_22_wrong_password_at_import.robot +13 -0
- robotframework_crypto-1.0.0/atest/issues/issue_23_undecryptable_variable.robot +15 -0
- robotframework_crypto-1.0.0/atest/issues/issue_28_decrypt_on_use.robot +67 -0
- robotframework_crypto-1.0.0/atest/issues/issue_28_decrypt_on_use_same_keyword_name.robot +18 -0
- robotframework_crypto-1.0.0/atest/issues/issue_28_decrypt_on_use_with_variable_decryption.robot +27 -0
- robotframework_crypto-1.0.0/atest/issues/issue_29_private_key_import_from_path.robot +70 -0
- robotframework_crypto-1.0.0/atest/issues/issue_51_robot_syntax_in_secrets.robot +22 -0
- robotframework_crypto-1.0.0/atest/log_masking.robot +71 -0
- robotframework_crypto-1.0.0/atest/resources/CliDriver.py +73 -0
- robotframework_crypto-1.0.0/atest/resources/EncryptedVariables.py +50 -0
- robotframework_crypto-1.0.0/atest/resources/FakeTextField.py +47 -0
- robotframework_crypto-1.0.0/atest/resources/KeyPath.py +14 -0
- robotframework_crypto-1.0.0/atest/resources/NestedRobot.py +54 -0
- robotframework_crypto-1.0.0/atest/resources/SameNameKeywords.py +6 -0
- robotframework_crypto-1.0.0/atest/resources/TestKeyStore.py +75 -0
- robotframework_crypto-1.0.0/atest/variable_decryption.robot +28 -0
- robotframework_crypto-1.0.0/docs/CryptoLibrary.html +484 -0
- robotframework_crypto-1.0.0/pyproject.toml +192 -0
- {robotframework-crypto-0.4.1 → robotframework_crypto-1.0.0}/src/CryptoClient/__main__.py +29 -19
- robotframework_crypto-1.0.0/src/CryptoLibrary/Plugin.py +111 -0
- robotframework_crypto-1.0.0/src/CryptoLibrary/__init__.py +668 -0
- {robotframework-crypto-0.4.1 → robotframework_crypto-1.0.0}/src/CryptoLibrary/__main__.py +96 -37
- robotframework_crypto-1.0.0/src/CryptoLibrary/utils/__init__.py +17 -0
- robotframework_crypto-1.0.0/src/CryptoLibrary/utils/cryptoutility.py +382 -0
- robotframework_crypto-1.0.0/src/CryptoLibrary/version.py +1 -0
- robotframework_crypto-1.0.0/tasks.py +155 -0
- robotframework_crypto-1.0.0/utest/conftest.py +125 -0
- robotframework_crypto-1.0.0/utest/test_cli.py +631 -0
- robotframework_crypto-1.0.0/utest/test_cryptoutility.py +479 -0
- robotframework_crypto-1.0.0/utest/test_library.py +1050 -0
- robotframework_crypto-1.0.0/utest/test_plugin.py +148 -0
- robotframework-crypto-0.4.1/MANIFEST.in +0 -12
- robotframework-crypto-0.4.1/Readme.rst +0 -212
- robotframework-crypto-0.4.1/create_readme.py +0 -5
- robotframework-crypto-0.4.1/docs/CryptoLibrary.html +0 -1876
- robotframework-crypto-0.4.1/pyproject.toml +0 -76
- robotframework-crypto-0.4.1/setup.cfg +0 -4
- robotframework-crypto-0.4.1/setup.py +0 -47
- robotframework-crypto-0.4.1/src/CryptoLibrary/Plugin.py +0 -59
- robotframework-crypto-0.4.1/src/CryptoLibrary/__init__.py +0 -337
- robotframework-crypto-0.4.1/src/CryptoLibrary/utils/__init__.py +0 -1
- robotframework-crypto-0.4.1/src/CryptoLibrary/utils/cryptoutility.py +0 -249
- robotframework-crypto-0.4.1/src/robotframework_crypto.egg-info/SOURCES.txt +0 -22
- robotframework-crypto-0.4.1/src/robotframework_crypto.egg-info/dependency_links.txt +0 -1
- robotframework-crypto-0.4.1/src/robotframework_crypto.egg-info/entry_points.txt +0 -3
- robotframework-crypto-0.4.1/src/robotframework_crypto.egg-info/requires.txt +0 -3
- robotframework-crypto-0.4.1/src/robotframework_crypto.egg-info/top_level.txt +0 -2
- {robotframework-crypto-0.4.1 → robotframework_crypto-1.0.0}/COPYRIGHT.txt +0 -0
- {robotframework-crypto-0.4.1 → robotframework_crypto-1.0.0}/LICENSE +0 -0
- {robotframework-crypto-0.4.1 → robotframework_crypto-1.0.0}/docs/index.html +0 -0
- {robotframework-crypto-0.4.1 → robotframework_crypto-1.0.0}/src/CryptoClient/__init__.py +0 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
.hypothesis/
|
|
50
|
+
.pytest_cache/
|
|
51
|
+
|
|
52
|
+
# Translations
|
|
53
|
+
*.mo
|
|
54
|
+
*.pot
|
|
55
|
+
|
|
56
|
+
# Django stuff:
|
|
57
|
+
*.log
|
|
58
|
+
local_settings.py
|
|
59
|
+
db.sqlite3
|
|
60
|
+
|
|
61
|
+
# Flask stuff:
|
|
62
|
+
instance/
|
|
63
|
+
.webassets-cache
|
|
64
|
+
|
|
65
|
+
# Scrapy stuff:
|
|
66
|
+
.scrapy
|
|
67
|
+
|
|
68
|
+
# Sphinx documentation
|
|
69
|
+
docs/_build/
|
|
70
|
+
|
|
71
|
+
# PyBuilder
|
|
72
|
+
target/
|
|
73
|
+
|
|
74
|
+
# Jupyter Notebook
|
|
75
|
+
.ipynb_checkpoints
|
|
76
|
+
|
|
77
|
+
# IPython
|
|
78
|
+
profile_default/
|
|
79
|
+
ipython_config.py
|
|
80
|
+
|
|
81
|
+
# pyenv
|
|
82
|
+
.python-version
|
|
83
|
+
|
|
84
|
+
# celery beat schedule file
|
|
85
|
+
celerybeat-schedule
|
|
86
|
+
|
|
87
|
+
# SageMath parsed files
|
|
88
|
+
*.sage.py
|
|
89
|
+
|
|
90
|
+
# Environments
|
|
91
|
+
.env
|
|
92
|
+
.venv
|
|
93
|
+
env/
|
|
94
|
+
venv/
|
|
95
|
+
ENV/
|
|
96
|
+
env.bak/
|
|
97
|
+
venv.bak/
|
|
98
|
+
|
|
99
|
+
# Spyder project settings
|
|
100
|
+
.spyderproject
|
|
101
|
+
.spyproject
|
|
102
|
+
|
|
103
|
+
# Rope project settings
|
|
104
|
+
.ropeproject
|
|
105
|
+
|
|
106
|
+
# mkdocs documentation
|
|
107
|
+
/site
|
|
108
|
+
|
|
109
|
+
# mypy
|
|
110
|
+
.mypy_cache/
|
|
111
|
+
|
|
112
|
+
.idea/
|
|
113
|
+
createLibDoc.bat
|
|
114
|
+
|
|
115
|
+
.dmypy.json
|
|
116
|
+
dmypy.json
|
|
117
|
+
|
|
118
|
+
# Pyre type checker
|
|
119
|
+
.pyre/
|
|
120
|
+
|
|
121
|
+
### Python Patch ###
|
|
122
|
+
.venv/
|
|
123
|
+
CreatePiPWheel.bat
|
|
124
|
+
src/CryptoLibrary/keys/
|
|
125
|
+
results/
|
|
126
|
+
|
|
127
|
+
# Key stores must never be committed (also throw-away keys created by tests or IDE tooling).
|
|
128
|
+
private_key.json
|
|
129
|
+
public_key.key
|
|
130
|
+
password_hash.json
|
|
@@ -1,25 +1,35 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: robotframework-crypto
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 1.0.0
|
|
4
4
|
Summary: A library for secure password handling.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
Project-URL: Homepage, https://github.com/Snooz82/robotframework-crypto
|
|
6
|
+
Project-URL: Documentation, https://snooz82.github.io/robotframework-crypto/CryptoLibrary.html
|
|
7
|
+
Project-URL: Source, https://github.com/Snooz82/robotframework-crypto
|
|
8
|
+
Project-URL: Issues, https://github.com/Snooz82/robotframework-crypto/issues
|
|
9
|
+
Author-email: "René Rohner (Snooz82)" <snooz@posteo.de>
|
|
10
|
+
License-Expression: Apache-2.0
|
|
11
|
+
License-File: COPYRIGHT.txt
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: crypto,password,robotframework,secrets,test automation,testing
|
|
14
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
15
|
+
Classifier: Framework :: Robot Framework
|
|
16
|
+
Classifier: Framework :: Robot Framework :: Library
|
|
12
17
|
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
25
|
+
Classifier: Topic :: Security :: Cryptography
|
|
13
26
|
Classifier: Topic :: Software Development :: Testing
|
|
14
27
|
Classifier: Topic :: Software Development :: Testing :: Acceptance
|
|
15
|
-
|
|
16
|
-
Requires-
|
|
28
|
+
Requires-Python: >=3.11
|
|
29
|
+
Requires-Dist: pynacl>=1.5.0
|
|
30
|
+
Requires-Dist: questionary>=2.0.1
|
|
31
|
+
Requires-Dist: robotframework>=7.1
|
|
17
32
|
Description-Content-Type: text/x-rst
|
|
18
|
-
License-File: LICENSE
|
|
19
|
-
Requires-Dist: robotframework>=3.2.2
|
|
20
|
-
Requires-Dist: PyNaCl>=1.4.0
|
|
21
|
-
Requires-Dist: questionary>=1.9.0
|
|
22
|
-
|
|
23
33
|
|
|
24
34
|
===================================================
|
|
25
35
|
robotframework-crypto
|
|
@@ -37,17 +47,11 @@ For more information about Robot Framework, see http://robotframework.org.
|
|
|
37
47
|
Installation
|
|
38
48
|
------------
|
|
39
49
|
|
|
40
|
-
|
|
41
|
-
run:
|
|
50
|
+
CryptoLibrary requires Python >= 3.11 and Robot Framework >= 7.1.
|
|
51
|
+
If you have Python with pip installed, you can simply run:
|
|
42
52
|
|
|
43
53
|
``pip install --upgrade robotframework-crypto``
|
|
44
54
|
|
|
45
|
-
or if you have Python 2 and 3 installed in parallel you may use
|
|
46
|
-
|
|
47
|
-
``pip3 install --upgrade robotframework-crypto``
|
|
48
|
-
|
|
49
|
-
If you have Python 2 ... i am very sorry! Please update!
|
|
50
|
-
|
|
51
55
|
|
|
|
52
56
|
|
|
53
57
|
How it works
|
|
@@ -83,6 +87,57 @@ All Data that is decrypted by CryptoLibrary is replaced in the log by ``***``
|
|
|
83
87
|
This works always and can not be disabled.
|
|
84
88
|
No need to use special keywords for this.
|
|
85
89
|
|
|
90
|
+
Concealed are log messages, variable assignments, FOR loop variables, failure messages of
|
|
91
|
+
keywords, tests and suites (also on the console), documentation, tags and metadata.
|
|
92
|
+
Escaped forms of a value, as in the ``repr`` of lists and dictionaries or in JSON, are
|
|
93
|
+
concealed as well.
|
|
94
|
+
|
|
95
|
+
Decrypting on use
|
|
96
|
+
~~~~~~~~~~~~~~~~~
|
|
97
|
+
|
|
98
|
+
With ``decrypt_on_use=True`` encrypted variables stay encrypted. A value is only decrypted at
|
|
99
|
+
the moment a keyword is called with it, so the plain text never ends up in a variable of the
|
|
100
|
+
suite or test, ``Log Variables`` or a variable that another suite can see.
|
|
101
|
+
|
|
102
|
+
**Only a complete argument value is decrypted:** a variable whose whole value is a cipher
|
|
103
|
+
text, or a literal cipher text, given as positional argument or as named argument that the
|
|
104
|
+
keyword accepts:
|
|
105
|
+
|
|
106
|
+
.. code :: robotframework
|
|
107
|
+
|
|
108
|
+
Login ${PASSWORD} # decrypted
|
|
109
|
+
Login password=${PASSWORD} # decrypted, if Login has an argument "password"
|
|
110
|
+
Login crypt:nkpEPOVKfOko3t04Xx... # decrypted
|
|
111
|
+
|
|
112
|
+
**Not decrypted** (the keyword gets the cipher text):
|
|
113
|
+
|
|
114
|
+
- a cipher text inside a longer value: ``Bearer ${TOKEN}``, ``${USER}:${PASSWORD}``,
|
|
115
|
+
or ``token=${TOKEN}`` for a keyword without an argument ``token``
|
|
116
|
+
- list and dictionary variables or items: ``@{SECRETS}``, ``&{LOGIN}``, ``${LOGIN}[password]``
|
|
117
|
+
- extended variable syntax, e.g. ``${PASSWORD.strip()}``
|
|
118
|
+
- expressions: ``IF``/``WHILE`` conditions, ``Evaluate``, ``Should Be True``, ``${{ ... }}``
|
|
119
|
+
- ``VAR``, default values of user keyword arguments and keywords with embedded arguments
|
|
120
|
+
- the keywords of CryptoLibrary itself, e.g. ``Get Decrypted Text ${PASSWORD}``
|
|
121
|
+
|
|
122
|
+
Keywords that run other keywords, e.g. ``Run Keyword`` or ``Wait Until Keyword Succeeds``,
|
|
123
|
+
get the decrypted value and pass it on. A keyword that gets a decrypted value can return it,
|
|
124
|
+
e.g. ``Set Variable``; such values are concealed in the logs like every decrypted value.
|
|
125
|
+
Together with ``variable_decryption=True``, variables are decrypted at suite and test start
|
|
126
|
+
as before, and cipher texts that come up later are decrypted on use.
|
|
127
|
+
|
|
128
|
+
Known limitations:
|
|
129
|
+
|
|
130
|
+
- Concealing only works in suites that import CryptoLibrary. A decrypted value that is passed
|
|
131
|
+
on, e.g. with ``Set Global Variable``, is visible in suites without the import.
|
|
132
|
+
- ``Log To Console`` and ``Log`` with ``console=True`` write to the console directly. The
|
|
133
|
+
console output is not concealed.
|
|
134
|
+
- Test names and ``GROUP`` names are written before CryptoLibrary is notified, so a secret in
|
|
135
|
+
a name is visible.
|
|
136
|
+
- Failure messages are concealed before ``Run Keyword And Expect Error`` or ``TRY/EXCEPT``
|
|
137
|
+
see them. Patterns that contain the plain value no longer match; match on ``***``
|
|
138
|
+
or use a glob pattern instead.
|
|
139
|
+
- Values that were logged before ``Conceal Text In Logs`` was called stay visible.
|
|
140
|
+
|
|
86
141
|
|
|
|
87
142
|
|
|
88
143
|
Usage in Test
|
|
@@ -118,6 +173,10 @@ Usage in Test
|
|
|
118
173
|
in this case the decryption password for the private key.
|
|
119
174
|
It can also be saved on test env persistently as a hash.
|
|
120
175
|
|
|
176
|
+
**Be aware:** the saved password (``password_hash.json`` in the key path) unlocks the
|
|
177
|
+
private key just like the password itself. Protect it like the password: whoever can read
|
|
178
|
+
``private_key.json`` and ``password_hash.json`` can decrypt all secrets.
|
|
179
|
+
|
|
121
180
|
The parameter **variable_decryption** in the Library call, if set to true it will automatically decode ALL passwords defined in the variables section
|
|
122
181
|
and then ``"Get Decrypted Text"`` isn't needed.
|
|
123
182
|
|
|
@@ -126,15 +185,22 @@ and then ``"Get Decrypted Text"`` isn't needed.
|
|
|
126
185
|
Importing of CryptoLibrary
|
|
127
186
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
128
187
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
188
|
+
*Arguments:*
|
|
189
|
+
|
|
190
|
+
- ``password``: Password of the private key. Treat it as a secret: give it as environment
|
|
191
|
+
variable, e.g. ``%{PRIVATE_KEY_PASSWORD}``, instead of writing it into the test data.
|
|
192
|
+
An empty value is ignored. Without a password, the password saved with the
|
|
193
|
+
CryptoLibrary command line tool is used.
|
|
194
|
+
- ``variable_decryption``: If set to ``True``, all variables that are available at the
|
|
195
|
+
start of a suite or test and contain a cipher text are decrypted automatically. When
|
|
196
|
+
CryptoLibrary is imported with ``Import Library``, e.g. in a Suite Setup, the variables
|
|
197
|
+
of the current suite (or test) are decrypted during the import.
|
|
198
|
+
- ``key_path``: Directory of the key pair. An absolute path, or relative to the current
|
|
199
|
+
working directory. Default is the ``keys`` directory of the installed package.
|
|
200
|
+
- ``decrypt_on_use``: If set to ``True``, a keyword argument whose complete value is a
|
|
201
|
+
cipher text is decrypted when the keyword is called, e.g. ``Login ${PASSWORD}`` or
|
|
202
|
+
``password=${PASSWORD}``. Variables stay encrypted. Works alone or together with
|
|
203
|
+
``variable_decryption``. See `Decrypting on use` for what is not decrypted.
|
|
138
204
|
|
|
139
205
|
|
|
|
140
206
|
|
|
@@ -207,6 +273,13 @@ SeleniumLibrary Plugin
|
|
|
207
273
|
CryptoLibrary.Plugin is a SeleniumLibrary Plugin.
|
|
208
274
|
When taken into usage, the ``Input Password`` Keyword can now handle decrypted cipher texts as well.
|
|
209
275
|
|
|
276
|
+
If CryptoLibrary is imported (also with an alias), the plugin uses its password and
|
|
277
|
+
``key_path`` and the typed password is concealed in the logs. Without the import, give them
|
|
278
|
+
as plugin arguments: ``plugins=CryptoLibrary.Plugin;key_path=<path>;password=<password>``.
|
|
279
|
+
Prefer the import: plugin arguments are not concealed in the logs, a password given there
|
|
280
|
+
is visible in the import line, and SeleniumLibrary does not support ``=``, ``;`` or ``,``
|
|
281
|
+
in plugin argument values.
|
|
282
|
+
|
|
210
283
|
Example:
|
|
211
284
|
|
|
212
285
|
.. code :: robotframework
|
|
@@ -231,4 +304,3 @@ Example:
|
|
|
231
304
|
It may happen that keywords changes.
|
|
232
305
|
i try not to do, but it can happen in major releases.
|
|
233
306
|
Feel free to make a pull Request to improve docs or write some tests for it.
|
|
234
|
-
|
|
@@ -1,26 +1,3 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: robotframework-crypto
|
|
3
|
-
Version: 0.4.1
|
|
4
|
-
Summary: A library for secure password handling.
|
|
5
|
-
Home-page: https://github.com/Snooz82/robotframework-crypto
|
|
6
|
-
Author: René Rohner(Snooz82)
|
|
7
|
-
Author-email: snooz@posteo.de
|
|
8
|
-
Classifier: Programming Language :: Python :: 3
|
|
9
|
-
Classifier: Programming Language :: Python :: 3.6
|
|
10
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
11
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
-
Classifier: Operating System :: OS Independent
|
|
13
|
-
Classifier: Topic :: Software Development :: Testing
|
|
14
|
-
Classifier: Topic :: Software Development :: Testing :: Acceptance
|
|
15
|
-
Classifier: Framework :: Robot Framework
|
|
16
|
-
Requires-Python: >=3.6
|
|
17
|
-
Description-Content-Type: text/x-rst
|
|
18
|
-
License-File: LICENSE
|
|
19
|
-
Requires-Dist: robotframework>=3.2.2
|
|
20
|
-
Requires-Dist: PyNaCl>=1.4.0
|
|
21
|
-
Requires-Dist: questionary>=1.9.0
|
|
22
|
-
|
|
23
|
-
|
|
24
1
|
===================================================
|
|
25
2
|
robotframework-crypto
|
|
26
3
|
===================================================
|
|
@@ -37,17 +14,11 @@ For more information about Robot Framework, see http://robotframework.org.
|
|
|
37
14
|
Installation
|
|
38
15
|
------------
|
|
39
16
|
|
|
40
|
-
|
|
41
|
-
run:
|
|
17
|
+
CryptoLibrary requires Python >= 3.11 and Robot Framework >= 7.1.
|
|
18
|
+
If you have Python with pip installed, you can simply run:
|
|
42
19
|
|
|
43
20
|
``pip install --upgrade robotframework-crypto``
|
|
44
21
|
|
|
45
|
-
or if you have Python 2 and 3 installed in parallel you may use
|
|
46
|
-
|
|
47
|
-
``pip3 install --upgrade robotframework-crypto``
|
|
48
|
-
|
|
49
|
-
If you have Python 2 ... i am very sorry! Please update!
|
|
50
|
-
|
|
51
22
|
|
|
|
52
23
|
|
|
53
24
|
How it works
|
|
@@ -83,6 +54,57 @@ All Data that is decrypted by CryptoLibrary is replaced in the log by ``***``
|
|
|
83
54
|
This works always and can not be disabled.
|
|
84
55
|
No need to use special keywords for this.
|
|
85
56
|
|
|
57
|
+
Concealed are log messages, variable assignments, FOR loop variables, failure messages of
|
|
58
|
+
keywords, tests and suites (also on the console), documentation, tags and metadata.
|
|
59
|
+
Escaped forms of a value, as in the ``repr`` of lists and dictionaries or in JSON, are
|
|
60
|
+
concealed as well.
|
|
61
|
+
|
|
62
|
+
Decrypting on use
|
|
63
|
+
~~~~~~~~~~~~~~~~~
|
|
64
|
+
|
|
65
|
+
With ``decrypt_on_use=True`` encrypted variables stay encrypted. A value is only decrypted at
|
|
66
|
+
the moment a keyword is called with it, so the plain text never ends up in a variable of the
|
|
67
|
+
suite or test, ``Log Variables`` or a variable that another suite can see.
|
|
68
|
+
|
|
69
|
+
**Only a complete argument value is decrypted:** a variable whose whole value is a cipher
|
|
70
|
+
text, or a literal cipher text, given as positional argument or as named argument that the
|
|
71
|
+
keyword accepts:
|
|
72
|
+
|
|
73
|
+
.. code :: robotframework
|
|
74
|
+
|
|
75
|
+
Login ${PASSWORD} # decrypted
|
|
76
|
+
Login password=${PASSWORD} # decrypted, if Login has an argument "password"
|
|
77
|
+
Login crypt:nkpEPOVKfOko3t04Xx... # decrypted
|
|
78
|
+
|
|
79
|
+
**Not decrypted** (the keyword gets the cipher text):
|
|
80
|
+
|
|
81
|
+
- a cipher text inside a longer value: ``Bearer ${TOKEN}``, ``${USER}:${PASSWORD}``,
|
|
82
|
+
or ``token=${TOKEN}`` for a keyword without an argument ``token``
|
|
83
|
+
- list and dictionary variables or items: ``@{SECRETS}``, ``&{LOGIN}``, ``${LOGIN}[password]``
|
|
84
|
+
- extended variable syntax, e.g. ``${PASSWORD.strip()}``
|
|
85
|
+
- expressions: ``IF``/``WHILE`` conditions, ``Evaluate``, ``Should Be True``, ``${{ ... }}``
|
|
86
|
+
- ``VAR``, default values of user keyword arguments and keywords with embedded arguments
|
|
87
|
+
- the keywords of CryptoLibrary itself, e.g. ``Get Decrypted Text ${PASSWORD}``
|
|
88
|
+
|
|
89
|
+
Keywords that run other keywords, e.g. ``Run Keyword`` or ``Wait Until Keyword Succeeds``,
|
|
90
|
+
get the decrypted value and pass it on. A keyword that gets a decrypted value can return it,
|
|
91
|
+
e.g. ``Set Variable``; such values are concealed in the logs like every decrypted value.
|
|
92
|
+
Together with ``variable_decryption=True``, variables are decrypted at suite and test start
|
|
93
|
+
as before, and cipher texts that come up later are decrypted on use.
|
|
94
|
+
|
|
95
|
+
Known limitations:
|
|
96
|
+
|
|
97
|
+
- Concealing only works in suites that import CryptoLibrary. A decrypted value that is passed
|
|
98
|
+
on, e.g. with ``Set Global Variable``, is visible in suites without the import.
|
|
99
|
+
- ``Log To Console`` and ``Log`` with ``console=True`` write to the console directly. The
|
|
100
|
+
console output is not concealed.
|
|
101
|
+
- Test names and ``GROUP`` names are written before CryptoLibrary is notified, so a secret in
|
|
102
|
+
a name is visible.
|
|
103
|
+
- Failure messages are concealed before ``Run Keyword And Expect Error`` or ``TRY/EXCEPT``
|
|
104
|
+
see them. Patterns that contain the plain value no longer match; match on ``***``
|
|
105
|
+
or use a glob pattern instead.
|
|
106
|
+
- Values that were logged before ``Conceal Text In Logs`` was called stay visible.
|
|
107
|
+
|
|
86
108
|
|
|
|
87
109
|
|
|
88
110
|
Usage in Test
|
|
@@ -118,6 +140,10 @@ Usage in Test
|
|
|
118
140
|
in this case the decryption password for the private key.
|
|
119
141
|
It can also be saved on test env persistently as a hash.
|
|
120
142
|
|
|
143
|
+
**Be aware:** the saved password (``password_hash.json`` in the key path) unlocks the
|
|
144
|
+
private key just like the password itself. Protect it like the password: whoever can read
|
|
145
|
+
``private_key.json`` and ``password_hash.json`` can decrypt all secrets.
|
|
146
|
+
|
|
121
147
|
The parameter **variable_decryption** in the Library call, if set to true it will automatically decode ALL passwords defined in the variables section
|
|
122
148
|
and then ``"Get Decrypted Text"`` isn't needed.
|
|
123
149
|
|
|
@@ -126,15 +152,22 @@ and then ``"Get Decrypted Text"`` isn't needed.
|
|
|
126
152
|
Importing of CryptoLibrary
|
|
127
153
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
128
154
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
155
|
+
*Arguments:*
|
|
156
|
+
|
|
157
|
+
- ``password``: Password of the private key. Treat it as a secret: give it as environment
|
|
158
|
+
variable, e.g. ``%{PRIVATE_KEY_PASSWORD}``, instead of writing it into the test data.
|
|
159
|
+
An empty value is ignored. Without a password, the password saved with the
|
|
160
|
+
CryptoLibrary command line tool is used.
|
|
161
|
+
- ``variable_decryption``: If set to ``True``, all variables that are available at the
|
|
162
|
+
start of a suite or test and contain a cipher text are decrypted automatically. When
|
|
163
|
+
CryptoLibrary is imported with ``Import Library``, e.g. in a Suite Setup, the variables
|
|
164
|
+
of the current suite (or test) are decrypted during the import.
|
|
165
|
+
- ``key_path``: Directory of the key pair. An absolute path, or relative to the current
|
|
166
|
+
working directory. Default is the ``keys`` directory of the installed package.
|
|
167
|
+
- ``decrypt_on_use``: If set to ``True``, a keyword argument whose complete value is a
|
|
168
|
+
cipher text is decrypted when the keyword is called, e.g. ``Login ${PASSWORD}`` or
|
|
169
|
+
``password=${PASSWORD}``. Variables stay encrypted. Works alone or together with
|
|
170
|
+
``variable_decryption``. See `Decrypting on use` for what is not decrypted.
|
|
138
171
|
|
|
139
172
|
|
|
|
140
173
|
|
|
@@ -207,6 +240,13 @@ SeleniumLibrary Plugin
|
|
|
207
240
|
CryptoLibrary.Plugin is a SeleniumLibrary Plugin.
|
|
208
241
|
When taken into usage, the ``Input Password`` Keyword can now handle decrypted cipher texts as well.
|
|
209
242
|
|
|
243
|
+
If CryptoLibrary is imported (also with an alias), the plugin uses its password and
|
|
244
|
+
``key_path`` and the typed password is concealed in the logs. Without the import, give them
|
|
245
|
+
as plugin arguments: ``plugins=CryptoLibrary.Plugin;key_path=<path>;password=<password>``.
|
|
246
|
+
Prefer the import: plugin arguments are not concealed in the logs, a password given there
|
|
247
|
+
is visible in the import line, and SeleniumLibrary does not support ``=``, ``;`` or ``,``
|
|
248
|
+
in plugin argument values.
|
|
249
|
+
|
|
210
250
|
Example:
|
|
211
251
|
|
|
212
252
|
.. code :: robotframework
|
|
@@ -231,4 +271,3 @@ Example:
|
|
|
231
271
|
It may happen that keywords changes.
|
|
232
272
|
i try not to do, but it can happen in major releases.
|
|
233
273
|
Feel free to make a pull Request to improve docs or write some tests for it.
|
|
234
|
-
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
*** Settings ***
|
|
2
|
+
Documentation Acceptance tests for CryptoLibrary.
|
|
3
|
+
...
|
|
4
|
+
... Every suite works with a throw-away key pair in ``${OUTPUT_DIR}/keys``.
|
|
5
|
+
... Run them with ``invoke atest``, which also checks ``output.xml`` for leaked
|
|
6
|
+
... secrets with ``atest/check_leaks.py``.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"""Fails if a plain text secret created by ``TestKeyStore`` leaked into an output file."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
sys.path.insert(0, str(Path(__file__).parent / 'resources'))
|
|
7
|
+
|
|
8
|
+
from TestKeyStore import CANARY_MARKER
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def main(paths: list[str]) -> int:
|
|
12
|
+
leaks = 0
|
|
13
|
+
for path in paths:
|
|
14
|
+
# Case-insensitive, so that derived values like ``secret.upper()`` are found, too.
|
|
15
|
+
content = Path(path).read_text(encoding='utf-8').casefold()
|
|
16
|
+
count = content.count(CANARY_MARKER.casefold())
|
|
17
|
+
if count:
|
|
18
|
+
print(f'{path}: secret leaked {count} time(s)')
|
|
19
|
+
leaks += count
|
|
20
|
+
if not leaks:
|
|
21
|
+
print(f'No leaked secrets found in: {", ".join(paths)}')
|
|
22
|
+
return 1 if leaks else 0
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
if __name__ == '__main__':
|
|
26
|
+
sys.exit(main(sys.argv[1:]))
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
*** Settings ***
|
|
2
|
+
Documentation Run by issue_23_undecryptable_variable.robot in a separate process.
|
|
3
|
+
|
|
4
|
+
Variables ../../resources/EncryptedVariables.py ${OUTPUT_DIR} keys
|
|
5
|
+
# Encrypted with another key pair, like in GitHub #23.
|
|
6
|
+
Variables ../../resources/EncryptedVariables.py ${OUTPUT_DIR} other_keys OTHER_
|
|
7
|
+
Library CryptoLibrary ${CRYPTO_PASSWORD} variable_decryption=True
|
|
8
|
+
... key_path=${CRYPTO_KEYPATH}
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
*** Variables ***
|
|
12
|
+
${FROM_OTHER_KEY_PAIR} ${OTHER_SYS_PASSWORD}
|
|
13
|
+
${SAME_VALUE_AS_ABOVE} ${OTHER_SYS_PASSWORD}
|
|
14
|
+
${NOT_A_CIPHER_TEXT} crypt:dGhpcyBpcyBub3QgYSBjaXBoZXIgdGV4dA==
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
*** Test Cases ***
|
|
18
|
+
First
|
|
19
|
+
Should Not Start With ${SYS_PASSWORD} crypt:
|
|
20
|
+
|
|
21
|
+
Second
|
|
22
|
+
Should Not Start With ${SYS_PASSWORD} crypt:
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
*** Settings ***
|
|
2
|
+
Documentation GitHub #14: the plugin can get ``key_path`` and ``password`` as plugin
|
|
3
|
+
... arguments, e.g. when CryptoLibrary itself is not imported.
|
|
4
|
+
|
|
5
|
+
Variables ../resources/EncryptedVariables.py ${OUTPUT_DIR} keys_issue_14_args
|
|
6
|
+
Library SeleniumLibrary
|
|
7
|
+
... plugins=CryptoLibrary.Plugin;key_path=${CRYPTO_KEYPATH};password=${CRYPTO_PASSWORD}
|
|
8
|
+
Library ../resources/FakeTextField.py
|
|
9
|
+
|
|
10
|
+
Test Setup Use Fake Text Field
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
*** Test Cases ***
|
|
14
|
+
Input Password Decrypts With The Plugin Arguments
|
|
15
|
+
Input Password id:password ${SYS_PASSWORD}
|
|
16
|
+
Typed Text Should Be Plain Text Of ${SYS_PASSWORD} ${CRYPTO_KEYPATH} ${CRYPTO_PASSWORD}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
*** Settings ***
|
|
2
|
+
Documentation GitHub #14: a password that the plugin decrypts is concealed in the logs.
|
|
3
|
+
... Separate suite, so that no other test decrypts the value first.
|
|
4
|
+
... ``invoke atest`` fails if the typed secret shows up in output.xml.
|
|
5
|
+
|
|
6
|
+
Variables ../resources/EncryptedVariables.py ${OUTPUT_DIR} keys_issue_14_conceal
|
|
7
|
+
Library CryptoLibrary ${CRYPTO_PASSWORD} key_path=${CRYPTO_KEYPATH}
|
|
8
|
+
Library SeleniumLibrary plugins=CryptoLibrary.Plugin
|
|
9
|
+
Library ../resources/FakeTextField.py
|
|
10
|
+
|
|
11
|
+
Test Setup Use Fake Text Field
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
*** Test Cases ***
|
|
15
|
+
Password Typed By The Plugin Is Concealed In Logs
|
|
16
|
+
Input Password id:password ${SYS_PASSWORD}
|
|
17
|
+
Log Typed Text
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
*** Settings ***
|
|
2
|
+
Documentation GitHub #14: ``Input Password`` of the SeleniumLibrary plugin must use the
|
|
3
|
+
... password and ``key_path`` given to the CryptoLibrary import.
|
|
4
|
+
|
|
5
|
+
Variables ../resources/EncryptedVariables.py ${OUTPUT_DIR} keys_issue_14
|
|
6
|
+
Library CryptoLibrary ${CRYPTO_PASSWORD} key_path=${CRYPTO_KEYPATH}
|
|
7
|
+
Library SeleniumLibrary plugins=CryptoLibrary.Plugin
|
|
8
|
+
Library ../resources/FakeTextField.py
|
|
9
|
+
|
|
10
|
+
Test Setup Use Fake Text Field
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
*** Test Cases ***
|
|
14
|
+
Input Password Decrypts With The Password Of The Library Import
|
|
15
|
+
Input Password id:password ${SYS_PASSWORD}
|
|
16
|
+
${plain} Get Decrypted Text ${SYS_PASSWORD}
|
|
17
|
+
Typed Text Should Be ${plain}
|
|
18
|
+
|
|
19
|
+
Plain Text Passwords Are Typed Unchanged
|
|
20
|
+
Input Password id:password not encrypted
|
|
21
|
+
Typed Text Should Be not encrypted
|
|
22
|
+
|
|
23
|
+
Missing Password Is Reported Clearly
|
|
24
|
+
[Documentation] E.g. an empty ``%{PRIVATE_KEY_PASSWORD}``: an empty password is ignored.
|
|
25
|
+
Import Library CryptoLibrary ${EMPTY} key_path=${CRYPTO_KEYPATH} AS CryptoWithoutPassword
|
|
26
|
+
Run Keyword And Expect Error *No password found! Password must be set ahead! *save it*
|
|
27
|
+
... CryptoWithoutPassword.Get Decrypted Text ${SYS_PASSWORD}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
*** Settings ***
|
|
2
|
+
Documentation GitHub #14: the plugin also finds CryptoLibrary when it is imported with
|
|
3
|
+
... an alias.
|
|
4
|
+
|
|
5
|
+
Variables ../resources/EncryptedVariables.py ${OUTPUT_DIR} keys_issue_14_alias
|
|
6
|
+
Library CryptoLibrary ${CRYPTO_PASSWORD} key_path=${CRYPTO_KEYPATH} AS Crypto
|
|
7
|
+
Library SeleniumLibrary plugins=CryptoLibrary.Plugin
|
|
8
|
+
Library ../resources/FakeTextField.py
|
|
9
|
+
|
|
10
|
+
Test Setup Use Fake Text Field
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
*** Test Cases ***
|
|
14
|
+
Input Password Decrypts With The Password Of The Aliased Import
|
|
15
|
+
Input Password id:password ${SYS_PASSWORD}
|
|
16
|
+
${plain} Crypto.Get Decrypted Text ${SYS_PASSWORD}
|
|
17
|
+
Typed Text Should Be ${plain}
|