Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] Aimstack crashing on FIPS enabled servers. #3217

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dushyantbehl
Copy link
Contributor

This PR tries to solve the issue #3143.

Using Aim on a FIPS compatible server, RHEL 9 FIPS enabled server in our case results in error due to lack of flexibility in the FIPS compatible version of blake2 hash algorithm used in aim currently.

Post further investigation we found out that on our FIPS servers the hashlib library used openssl version of the constructors for blake2 which doesn't provide digest_size argument which is used in Aim to customize the size of hash digest to 8 bytes.

In this patch we introduce use of a FIPS compatible hashing algorithm shake_256 which supports variable lengths digests and is available in FIPS mode under the SHA3 algorithms.
Currently the code is written to keep using blake2 in normal execution mode but if FIPS mode is detected it switches to shake_256.

support for aim hashing library.

Signed-off-by: Dushyant Behl <dushyantbehl@users.noreply.github.com>
@dushyantbehl
Copy link
Contributor Author

Code is tested on both FIPS and non FIPS servers and below are the unit test results.

On FIPS Server -

Before -

ERROR tests/storage/test_query.py::TestQuery::test_syntax_error_handling - TypeError: 'digest_size' is an invalid keyword argument for openssl_blake2b()
ERROR tests/storage/test_query.py::TestQueryDefaultExpression::test_default_query_metric_results - TypeError: 'digest_size' is an invalid keyword argument for openssl_blake2b()
ERROR tests/storage/test_query.py::TestQueryDefaultExpression::test_default_query_run_results - TypeError: 'digest_size' is an invalid keyword argument for openssl_blake2b()
ERROR tests/storage/test_query.py::TestQueryDefaultExpression::test_query_with_archived_expression_run_results - TypeError: 'digest_size' is an invalid keyword argument for openssl_blake2b()
ERROR tests/storage/test_query.py::TestQueryDefaultExpression::test_query_without_archived_expression_metric_results - TypeError: 'digest_size' is an invalid keyword argument for openssl_blake2b()
ERROR tests/storage/test_structured_db.py::TestStructuredDatabase::test_context_manager_nesting - TypeError: 'digest_size' is an invalid keyword argument for openssl_blake2b()
ERROR tests/storage/test_structured_db.py::TestStructuredDatabase::test_entity_chaining_syntax - TypeError: 'digest_size' is an invalid keyword argument for openssl_blake2b()
ERROR tests/storage/test_structured_db.py::TestStructuredDatabase::test_entity_relations - TypeError: 'digest_size' is an invalid keyword argument for openssl_blake2b()
============================================================================================== 34 failed, 25 passed, 3 skipped, 7 warnings, 89 errors in 24.49s ===============================================================================================

After applying the patch

=================================================================================================================== short test summary info ===================================================================================================================
FAILED tests/api/test_run_images_api.py::RunImagesURIBulkLoadApi::test_images_uri_bulk_load_api_0 - TypeError: Population must be a sequence.  For dicts or sets, use sorted(d).
FAILED tests/api/test_run_images_api.py::RunImagesURIBulkLoadApi::test_images_uri_bulk_load_api_1 - TypeError: Population must be a sequence.  For dicts or sets, use sorted(d).
FAILED tests/api/test_run_images_api.py::RunImagesURIBulkLoadApi::test_images_uri_bulk_load_api_2 - TypeError: Population must be a sequence.  For dicts or sets, use sorted(d).
FAILED tests/api/test_run_images_api.py::TestRunInfoApi::test_run_info_get_all_sequences_api_0 - AssertionError: 'floats' != 'integers'
FAILED tests/api/test_run_images_api.py::TestRunInfoApi::test_run_info_get_all_sequences_api_1 - AssertionError: 'floats' != 'integers'
=============================================================================================== 5 failed, 143 passed, 3 skipped, 6 warnings in 75.84s (0:01:15)

I noticed a few tests failing at the end but am not sure of what exactly is behind those and am looking into if ths was introduced by our patch as I have no way of testing this without our patch on FIPS servers.

I am open to any suggestions or fixes related to the patch.

Signed-off-by: Dushyant Behl <dushyantbehl@users.noreply.github.com>
@dushyantbehl
Copy link
Contributor Author

I noticed that the test data was in a different order in case of different python versions hence added some changes to the test here 891cbd3 ..if you appreciate this as a separate PR please let me know and I am happy to move it separately.

@dushyantbehl
Copy link
Contributor Author

Hi @SGevorg @alberttorosyan @mihran113 a friendly bump.

Can I request you to please review these changes. Thanks!

@dushyantbehl dushyantbehl changed the title Fix FIPS compatibility issue with Aimstack. [fix] Aimstack crashing on FIPS enabled servers. Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant