Merge "Remove md5_factory function"
This commit is contained in:
commit
7a327f6285
@ -4882,10 +4882,6 @@ except TypeError:
|
||||
return hashlib.md5(string) # nosec
|
||||
|
||||
|
||||
def md5_factory():
|
||||
return md5(usedforsecurity=False)
|
||||
|
||||
|
||||
class ShardRange(object):
|
||||
"""
|
||||
A ShardRange encapsulates sharding state related to a container including
|
||||
|
@ -66,7 +66,7 @@ from swift.common.utils import mkdirs, Timestamp, \
|
||||
get_md5_socket, F_SETPIPE_SZ, decode_timestamps, encode_timestamps, \
|
||||
MD5_OF_EMPTY_STRING, link_fd_to_path, \
|
||||
O_TMPFILE, makedirs_count, replace_partition_in_path, remove_directory, \
|
||||
md5, md5_factory
|
||||
md5
|
||||
from swift.common.splice import splice, tee
|
||||
from swift.common.exceptions import DiskFileQuarantined, DiskFileNotExist, \
|
||||
DiskFileCollision, DiskFileNoSpace, DiskFileDeviceUnavailable, \
|
||||
@ -1116,7 +1116,7 @@ class BaseDiskFileManager(object):
|
||||
:param policy: storage policy used
|
||||
"""
|
||||
if six.PY2:
|
||||
hashes = defaultdict(md5_factory)
|
||||
hashes = defaultdict(lambda: md5(usedforsecurity=False))
|
||||
else:
|
||||
class shim(object):
|
||||
def __init__(self):
|
||||
|
@ -48,8 +48,7 @@ from swift.common.utils import (
|
||||
GreenAsyncPile, GreenthreadSafeIterator, Timestamp, WatchdogTimeout,
|
||||
normalize_delete_at_timestamp, public, get_expirer_container,
|
||||
document_iters_to_http_response_body, parse_content_range,
|
||||
quorum_size, reiterate, close_if_possible, safe_json_loads, md5,
|
||||
md5_factory)
|
||||
quorum_size, reiterate, close_if_possible, safe_json_loads, md5)
|
||||
from swift.common.bufferedhttp import http_connect
|
||||
from swift.common.constraints import check_metadata, check_object_creation
|
||||
from swift.common import constraints
|
||||
@ -3179,7 +3178,8 @@ class ECObjectController(BaseObjectController):
|
||||
bytes_transferred = 0
|
||||
chunk_transform = chunk_transformer(policy)
|
||||
chunk_transform.send(None)
|
||||
frag_hashers = collections.defaultdict(md5_factory)
|
||||
frag_hashers = collections.defaultdict(
|
||||
lambda: md5(usedforsecurity=False))
|
||||
|
||||
def send_chunk(chunk):
|
||||
# Note: there's two different hashers in here. etag_hasher is
|
||||
|
@ -32,7 +32,7 @@ from swift.common.middleware.s3api.s3request import S3Request, \
|
||||
from swift.common.middleware.s3api.s3response import InvalidArgument, \
|
||||
NoSuchBucket, InternalError, \
|
||||
AccessDenied, SignatureDoesNotMatch, RequestTimeTooSkewed
|
||||
from swift.common.utils import md5, md5_factory
|
||||
from swift.common.utils import md5
|
||||
|
||||
from test.unit import DebugLogger
|
||||
|
||||
@ -825,7 +825,7 @@ class TestHashingInput(S3ApiTestCase):
|
||||
def test_good(self):
|
||||
raw = b'123456789'
|
||||
wrapped = HashingInput(
|
||||
BytesIO(raw), 9, md5_factory,
|
||||
BytesIO(raw), 9, lambda: md5(usedforsecurity=False),
|
||||
md5(raw, usedforsecurity=False).hexdigest())
|
||||
self.assertEqual(b'1234', wrapped.read(4))
|
||||
self.assertEqual(b'56', wrapped.read(2))
|
||||
@ -851,7 +851,7 @@ class TestHashingInput(S3ApiTestCase):
|
||||
def test_too_long(self):
|
||||
raw = b'123456789'
|
||||
wrapped = HashingInput(
|
||||
BytesIO(raw), 8, md5_factory,
|
||||
BytesIO(raw), 8, lambda: md5(usedforsecurity=False),
|
||||
md5(raw, usedforsecurity=False).hexdigest())
|
||||
self.assertEqual(b'1234', wrapped.read(4))
|
||||
self.assertEqual(b'56', wrapped.read(2))
|
||||
@ -865,7 +865,7 @@ class TestHashingInput(S3ApiTestCase):
|
||||
def test_too_short(self):
|
||||
raw = b'123456789'
|
||||
wrapped = HashingInput(
|
||||
BytesIO(raw), 10, md5_factory,
|
||||
BytesIO(raw), 10, lambda: md5(usedforsecurity=False),
|
||||
md5(raw, usedforsecurity=False).hexdigest())
|
||||
self.assertEqual(b'1234', wrapped.read(4))
|
||||
self.assertEqual(b'56', wrapped.read(2))
|
||||
|
Loading…
Reference in New Issue
Block a user