Skip to content

Commit

Permalink
add expected bucket owner to all operations
Browse files Browse the repository at this point in the history
  • Loading branch information
kdaily committed Apr 21, 2021
1 parent f90e44e commit af131ae
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .changes/next-release/enhancement-s3-1285.json
@@ -1,5 +1,5 @@
{
"category": "s3",
"type": "enhancement",
"description": "Adds `ExpectedBucketOwner` to the allowed `ExtraArgs` for uploads to protect against bucket sniping when uploading files. Fixes `#181 <https://github.com/boto/boto3/issues/181>`__."
"description": "Add support for ``ExpectedBucketOwner``. Fixes `#181 <https://github.com/boto/s3transfer/issues/181>`__."
}
1 change: 1 addition & 0 deletions s3transfer/constants.py
Expand Up @@ -22,6 +22,7 @@
'SSECustomerKey',
'SSECustomerKeyMD5',
'RequestPayer',
'ExpectedBucketOwner',
]

USER_AGENT = 's3transfer/%s' % s3transfer.__version__
Expand Down
7 changes: 5 additions & 2 deletions s3transfer/copies.py
Expand Up @@ -34,7 +34,8 @@ class CopySubmissionTask(SubmissionTask):
'CopySourceSSECustomerKey': 'SSECustomerKey',
'CopySourceSSECustomerAlgorithm': 'SSECustomerAlgorithm',
'CopySourceSSECustomerKeyMD5': 'SSECustomerKeyMD5',
'RequestPayer': 'RequestPayer'
'RequestPayer': 'RequestPayer',
'ExpectedBucketOwner': 'ExpectedBucketOwner'
}

UPLOAD_PART_COPY_ARGS = [
Expand All @@ -49,6 +50,7 @@ class CopySubmissionTask(SubmissionTask):
'SSECustomerAlgorithm',
'SSECustomerKeyMD5',
'RequestPayer',
'ExpectedBucketOwner'
]

CREATE_MULTIPART_ARGS_BLACKLIST = [
Expand All @@ -64,7 +66,8 @@ class CopySubmissionTask(SubmissionTask):
]

COMPLETE_MULTIPART_ARGS = [
'RequestPayer'
'RequestPayer',
'ExpectedBucketOwner'
]

def _submit(self, client, config, osutil, request_executor,
Expand Down
1 change: 1 addition & 0 deletions s3transfer/manager.py
Expand Up @@ -199,6 +199,7 @@ class TransferManager(object):
'MFA',
'VersionId',
'RequestPayer',
'ExpectedBucketOwner'
]

def __init__(self, client, config=None, osutil=None, executor_cls=None):
Expand Down
4 changes: 3 additions & 1 deletion s3transfer/upload.py
Expand Up @@ -490,10 +490,12 @@ class UploadSubmissionTask(SubmissionTask):
'SSECustomerAlgorithm',
'SSECustomerKeyMD5',
'RequestPayer',
'ExpectedBucketOwner'
]

COMPLETE_MULTIPART_ARGS = [
'RequestPayer'
'RequestPayer',
'ExpectedBucketOwner'
]

def _get_upload_input_manager_cls(self, transfer_future):
Expand Down

0 comments on commit af131ae

Please sign in to comment.