st2 icon indicating copy to clipboard operation
st2 copied to clipboard

st2api encrypt of £ (and other utf-8 chars) fails with python stacktrace

Open dswebbthg opened this issue 7 years ago • 3 comments

SUMMARY

Provide a quick summary of your bug or feature request.

ISSUE TYPE

Pick one below and delete the rest:

  • Bug Report
STACKSTORM VERSION

Paste the output of st2 --version: root@stackstorm-ha-st2client-68fdcb57f-xnxkv:/opt/stackstorm# st2 --version st2 3.0dev (9577ff944), on Python 3.6.7

OS / ENVIRONMENT / INSTALL METHOD

kubernetes using ubuntu 18.04 using helm

STEPS TO REPRODUCE

root@stackstorm-ha-st2client-68fdcb57f-xnxkv:/opt/stackstorm# st2 key set --scope=system --encrypt test '£' ERROR: 400 Client Error: Bad Request MESSAGE: The length of the provided data is not a multiple of the block length. for url: http://stackstorm-ha-st2api:9101/keys/test

During handling of the above exception, another exception occurred:

error log from the st2api container

2019-01-23 16:06:14,301 ERROR [-] Failed to call controller function "put" for operation "st2api.controllers.v1.keyvalue:key_value_pair_controller.put": The length of the provided data is not a multiple of the block length. Traceback (most recent call last): File "/opt/stackstorm/st2/lib/python3.6/site-packages/st2api/controllers/v1/keyvalue.py", line 301, in put kvp_db = KeyValuePairAPI.to_model(kvp) File "/opt/stackstorm/st2/lib/python3.6/site-packages/st2common/models/api/keyvalue.py", line 175, in to_model value = symmetric_encrypt(KeyValuePairAPI.crypto_key, value) File "/opt/stackstorm/st2/lib/python3.6/site-packages/st2common/util/crypto.py", line 186, in symmetric_encrypt return cryptography_symmetric_encrypt(encrypt_key=encrypt_key, plaintext=plaintext) File "/opt/stackstorm/st2/lib/python3.6/site-packages/st2common/util/crypto.py", line 237, in cryptography_symmetric_encrypt ciphertext_bytes = encryptor.update(data) + encryptor.finalize() File "/opt/stackstorm/st2/lib/python3.6/site-packages/cryptography/hazmat/primitives/ciphers/base.py", line 159, in finalize data = self._ctx.finalize() File "/opt/stackstorm/st2/lib/python3.6/site-packages/cryptography/hazmat/backends/openssl/ciphers.py", line 173, in finalize "The length of the provided data is not a multiple of " ValueError: The length of the provided data is not a multiple of the block length.

EXPECTED RESULTS

we should be able to encrypt the £ sign

ACTUAL RESULTS

http 400 and a python stacktrace on the api

dswebbthg avatar Jan 23 '19 16:01 dswebbthg

make that utf-8 special characters

dswebbthg avatar Jan 23 '19 16:01 dswebbthg

Update: the tests failed for that pull request, I added a comment describing the issue but don't have a solution yet.

nickbaum avatar Jan 31 '19 05:01 nickbaum

Thanks for reporting this issue and sorry for the delay.

We will have a look as soon as we get a chance.

Kami avatar Jan 31 '19 09:01 Kami