Add exception if relative path is given to Azure storage engine

This commit is contained in:
Joseph Schorr 2018-02-06 13:38:00 -05:00
parent de47b13c24
commit 5a2f6f6faf

View file

@ -27,6 +27,7 @@ _MAX_BLOCK_SIZE = 1024 * 1024 * 100 # 100MB
_BLOCKS_KEY = 'blocks' _BLOCKS_KEY = 'blocks'
_CONTENT_TYPE_KEY = 'content-type' _CONTENT_TYPE_KEY = 'content-type'
class AzureStorage(BaseStorage): class AzureStorage(BaseStorage):
def __init__(self, context, azure_container, storage_path, azure_account_name, def __init__(self, context, azure_container, storage_path, azure_account_name,
azure_account_key=None, sas_token=None, connection_string=None, azure_account_key=None, sas_token=None, connection_string=None,
@ -50,6 +51,9 @@ class AzureStorage(BaseStorage):
socket_timeout=socket_timeout) socket_timeout=socket_timeout)
def _blob_name_from_path(self, object_path): def _blob_name_from_path(self, object_path):
if '..' in object_path:
raise Exception('Relative paths are not allowed; found %s' % object_path)
return os.path.join(self._storage_path, object_path).rstrip('/') return os.path.join(self._storage_path, object_path).rstrip('/')
def _upload_blob_name_from_uuid(self, uuid): def _upload_blob_name_from_uuid(self, uuid):