glideinWMS / glideinwms

The glideinWMS Project
http://tinyurl.com/glideinwms
Apache License 2.0
16 stars 46 forks source link

Outdated Openssl Algorithm in unit test #409

Open mambelli opened 6 months ago

mambelli commented 6 months ago

Describe the bug Unit tests are failing on EL9 (openssl3) due to the use of algorithms moved to the legacy section. Specifically, the test failing is unittests/test_lib_symCrypto.py Should the fix be reflected also in the code or only the unit test? Triage should evaluate if the code is affected first. If not skipping the tests may be acceptable

Running tests...
----------------------------------------------------------------------
.......S.....E.E
======================================================================
ERROR [0.859s]: test_symmetric (__main__.TestSymBlowfishKey)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/glideinwms-ci/glideinwms/unittests/././test_lib_symCrypto.py", line 153, in test_symmetric
    def test_symmetric(self, data):
  File "/home/glideinwms-ci/venv-3.9.18/lib64/python3.9/site-packages/hypothesis/core.py", line 1638, in wrapped_test
    raise the_error_hypothesis_found
  File "/home/glideinwms-ci/glideinwms/unittests/././test_lib_symCrypto.py", line 156, in test_symmetric
    self.assertEqual(data, sk2.decrypt(self.key.encrypt(data)))
  File "/home/glideinwms-ci/glideinwms/lib/symCrypto.py", line 200, in encrypt
    e = b.read()
  File "/usr/lib64/python3.9/site-packages/M2Crypto/BIO.py", line 204, in read
    return m2.bio_read(self.bio, m2.bio_ctrl_pending(self.bio))
M2Crypto.BIO.BIOError: unsupported (Global default library context, Algorithm (BF-CBC : 13), Properties ())
Falsifying example: test_symmetric(
    self=<__main__.TestSymBlowfishKey testMethod=test_symmetric>,
    data='0',  # or any other generated value
)

======================================================================
ERROR [0.659s]: test_symmetric (__main__.TestSymDESKey)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/glideinwms-ci/glideinwms/unittests/././test_lib_symCrypto.py", line 206, in test_symmetric
    def test_symmetric(self, data):
  File "/home/glideinwms-ci/venv-3.9.18/lib64/python3.9/site-packages/hypothesis/core.py", line 1638, in wrapped_test
    raise the_error_hypothesis_found
  File "/home/glideinwms-ci/glideinwms/unittests/././test_lib_symCrypto.py", line 209, in test_symmetric
    self.assertEqual(data, sk2.decrypt(self.key.encrypt(data)))
  File "/home/glideinwms-ci/glideinwms/lib/symCrypto.py", line 200, in encrypt
    e = b.read()
  File "/usr/lib64/python3.9/site-packages/M2Crypto/BIO.py", line 204, in read
    return m2.bio_read(self.bio, m2.bio_ctrl_pending(self.bio))
M2Crypto.BIO.BIOError: unsupported (Global default library context, Algorithm (DES-CBC : 11), Properties ())
Falsifying example: test_symmetric(
    self=<__main__.TestSymDESKey testMethod=test_symmetric>,
    data='0',  # or any other generated value
)

----------------------------------------------------------------------
Ran 16 tests in 2.096s

FAILED (errors=2, skipped=1)

To Reproduce On an AlmaLinux9 container, e.g. gwms-ci-el9 run the unit tests: glideinwms/build/ci/runtest.sh -vI pyunittest -a

Expected behavior No failures in unit tests. Maybe some tests should be platform dependent depending on what openssl supports

Screenshots NA

Info (please complete the following information): Stakeholders and components can be a comma separated list or on multiple lines. If you add a new stakeholder or component, not on the sample list, add it on a line by its own.

Additional context Some links: https://help.heroku.com/88GYDTB2/how-do-i-configure-openssl-to-allow-the-use-of-legacy-cryptographic-algorithms https://stackoverflow.com/questions/70064335/des-command-on-openssl-3-0-unsupported-crypto-error

mambelli commented 3 months ago

SymBlowfishKey, bf_cbc and SymDESKey, des_cbc, were removed in PR #408 because not supported in openssl3 (EL9): [[https://github.com/glideinWMS/glideinwms/pull/408/files#diff-601b5f7ed69cd9a4431ea0eba55bfa3e9c2ff3a32969ed028fae3875fdd61b3c]]

There is only to doublecheck w/ Bruno who revised the credentials if there is any reference to these credentials or if new ones should be introduced and tested. Email sent