swift/test/unit/common
Ade Lee 5320ecbaf2 replace md5 with swift utils version
md5 is not an approved algorithm in FIPS mode, and trying to
instantiate a hashlib.md5() will fail when the system is running in
FIPS mode.

md5 is allowed when in a non-security context.  There is a plan to
add a keyword parameter (usedforsecurity) to hashlib.md5() to annotate
whether or not the instance is being used in a security context.

In the case where it is not, the instantiation of md5 will be allowed.
See https://bugs.python.org/issue9216 for more details.

Some downstream python versions already support this parameter.  To
support these versions, a new encapsulation of md5() is added to
swift/common/utils.py.  This encapsulation is identical to the one being
added to oslo.utils, but is recreated here to avoid adding a dependency.

This patch is to replace the instances of hashlib.md5() with this new
encapsulation, adding an annotation indicating whether the usage is
a security context or not.

While this patch seems large, it is really just the same change over and
again.  Reviewers need to pay particular attention as to whether the
keyword parameter (usedforsecurity) is set correctly.   Right now, all
of them appear to be not used in a security context.

Now that all the instances have been converted, we can update the bandit
run to look for these instances and ensure that new invocations do not
creep in.

With this latest patch, the functional and unit tests all pass
on a FIPS enabled system.

Co-Authored-By: Pete Zaitcev
Change-Id: Ibb4917da4c083e1e094156d748708b87387f2d87
2020-12-15 09:52:55 -05:00
..
middleware replace md5 with swift utils version 2020-12-15 09:52:55 -05:00
ring replace md5 with swift utils version 2020-12-15 09:52:55 -05:00
__init__.py Initial commit of Swift code 2010-07-12 17:03:45 -05:00
corrupted_example.db Real files for bad databases. 2011-08-02 18:21:25 +00:00
malformed_example.db Real files for bad databases. 2011-08-02 18:21:25 +00:00
malformed_schema_example.db Quarantine malformed database schema SQLite errors 2016-12-01 14:17:02 +11:00
missing_container_info.db Quarantine DB without *_stat row 2018-02-07 19:35:05 +01:00
test_base_storage_server.py Allow replication servers to handle all request methods 2020-07-23 09:11:07 -07:00
test_bufferedhttp.py bufferedhttp: ensure query params are properly quoted 2019-09-12 11:48:03 -07:00
test_constraints.py Deprecate per-service auto_create_account_prefix 2020-01-05 09:53:30 -06:00
test_container_sync_realms.py Python3: Fix test/unit/common/test_container_sync_realms.py 2019-01-29 09:04:36 -06:00
test_daemon.py Clean up HASH_PATH_* patching 2018-11-01 20:52:33 +00:00
test_db.py Breakup reclaim into batches 2020-05-22 21:15:57 +00:00
test_db_replicator.py replication: Allow databases_per_second to be a float 2020-05-15 13:23:17 -07:00
test_direct_client.py replace md5 with swift utils version 2020-12-15 09:52:55 -05:00
test_exceptions.py pep8: Turn on E305 2020-04-03 21:22:38 +02:00
test_header_key_dict.py py3: Fix title-casing in HeaderKeyDict 2019-07-25 12:55:03 -07:00
test_internal_client.py Log storage policy with s3api requests 2020-10-01 17:18:13 -07:00
test_linkat.py Fix tests using O_TMPFILE 2018-03-13 12:06:07 +00:00
test_manager.py Get unit tests passing on py39 2020-10-18 21:42:21 -07:00
test_memcached.py replace md5 with swift utils version 2020-12-15 09:52:55 -05:00
test_request_helpers.py Allow direct and internal clients to use the replication network 2020-08-04 21:22:04 +00:00
test_splice.py No longer import nose 2017-11-07 15:39:25 +11:00
test_storage_policy.py Fix invalid assert states 2019-07-01 09:20:02 +08:00
test_swob.py Simplify wsgify() 2020-05-27 03:19:13 +00:00
test_utils.py replace md5 with swift utils version 2020-12-15 09:52:55 -05:00
test_wsgi.py Use socket_timeout kwarg instead of useless eventlet.wsgi.WRITE_TIMEOUT 2020-11-11 14:23:40 -08:00