-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add Owner ID check for bucket with path when prefix is provided #5146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
# Conflicts: # src/sagemaker/serve/model_server/multi_model_server/inference.py # src/sagemaker/serve/model_server/torchserve/inference.py # src/sagemaker/serve/model_server/torchserve/xgboost_inference.py
**Description** Previously we called the head_bucket call to ensure the owner ID check, but this doesnt take into consideration cases where the s3 path is provided through the prefix. This change makes sure that director level permissions are supported. **Testing Done** Tested through unit tests, integ tests and manual testing through the installation file. Yes
src/sagemaker/session.py
Outdated
s3.meta.client.list_objects_v2( | ||
Bucket=bucket_name, | ||
Prefix=self.default_bucket_prefix, | ||
ExpectedBucketOwner=expected_bucket_owner_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this check is a bit different in this method. Looks like it just checks for general permission to the bucket rather than checking for ExpectedBucketOwner
. For this case, probably need to remove the ExpectedBucketOwner=expected_bucket_owner_id
to match the behavior of the second block which just does a regular head bucket check - s3.meta.client.head_bucket(Bucket=bucket_name)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good callout. Updated the PR.
src/sagemaker/session.py
Outdated
@@ -668,7 +678,7 @@ def expected_bucket_owner_id_bucket_check(self, bucket_name, s3, expected_bucket | |||
raise | |||
|
|||
def general_bucket_check_if_user_has_permission( | |||
self, bucket_name, s3, bucket, region, bucket_creation_date_none | |||
self, bucket_name, s3, bucket, region, bucket_creation_date_none, expected_bucket_owner_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this extra parameter is unused
Description
Previously we called the head_bucket call to ensure the owner ID check, but this doesnt take into consideration cases where the s3 path is provided through the prefix.
This change makes sure that director level permissions are supported.
Testing Done
Tested through unit tests, integ tests and manual testing through the installation file.
General
Tests
unique_name_from_base
to create resource names in integ tests (if appropriate)By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.