Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _process_content(blob, start_offset, end_offset, require_encryption, key_encryption_key, key_resolver_function):
if key_encryption_key is not None or key_resolver_function is not None:
try:
return _decrypt_blob(
require_encryption,
key_encryption_key,
key_resolver_function,
blob,
start_offset,
end_offset)
except Exception as error:
raise HttpResponseError(
message="Decryption failed.",
response=blob.response,
error=error)
else:
return b"".join(list(blob))
# For range gets, only look at 'x-ms-blob-content-md5' for overall MD5
content_settings = getattr(props, 'content_settings')
if 'content-range' in response.headers:
if 'x-ms-blob-content-md5' in response.headers:
setattr(content_settings, 'content_md5', _to_str(response.headers['x-ms-blob-content-md5']))
else:
delattr(content_settings, 'content_md5')
if validate_content:
computed_md5 = _get_content_md5(response.body)
_validate_content_match(response.headers['content-md5'], computed_md5)
if key_encryption_key is not None or key_resolver_function is not None:
try:
response.body = _decrypt_blob(require_encryption, key_encryption_key, key_resolver_function,
response, start_offset, end_offset)
except:
raise AzureException(_ERROR_DECRYPTION_FAILURE)
return Blob(name, snapshot, response.body, props, metadata)