Skip to content
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

[rgw]:Validate bucket names as per revised s3 spec #26787

Merged
merged 1 commit into from Aug 16, 2019

Conversation

soumyakoduri
Copy link
Contributor

As per amazon s3 spec -
https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-s3-bucket-naming-requirements.html

The s3 bucket names should not contain upper case letters or underscore.
Name cannot end with dash or have consecutive periods, or dashes adjacent to periods

This change is to enforce these rules if rgw_relaxed_s3_bucket_names is set to 'false'.

Fixes: https://tracker.ceph.com/issues/36293

Signed-off-by: Soumya Koduri skoduri@redhat.com

@soumyakoduri
Copy link
Contributor Author

@mattbenjamin @pritha-srivastava @cbodley @yehudasa .. kindly review the changes.

@cbodley cbodley added the rgw label Mar 6, 2019
@stale
Copy link

stale bot commented May 5, 2019

This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@stale stale bot added the stale label May 5, 2019
@stale stale bot removed the stale label May 6, 2019
@mattbenjamin
Copy link
Contributor

unstale this

@cbodley
Copy link
Contributor

cbodley commented May 6, 2019

we document our bucket name requirements in doc/radosgw/s3/bucketops.rst (see http://docs.ceph.com/docs/master/radosgw/s3/bucketops/#constraints) - could you please update that to reflect the changes? also worth mentioning which parts are conditional on rgw_relaxed_s3_bucket_names

@soumyakoduri
Copy link
Contributor Author

we document our bucket name requirements in doc/radosgw/s3/bucketops.rst (see http://docs.ceph.com/docs/master/radosgw/s3/bucketops/#constraints) - could you please update that to reflect the changes? also worth mentioning which parts are conditional on rgw_relaxed_s3_bucket_names

Sure. Will make the changes.

@soumyakoduri
Copy link
Contributor Author

@cbodley ..
Amazon spec states that bucket name can be between 3 and 63 characters long whereas in the code we currently seem to be allowing upto 255 characters. Do you suggest I limit the size too if the relaxed option is not set?

@cbodley
Copy link
Contributor

cbodley commented May 6, 2019

yes please, we should limit to 63 as well

@soumyakoduri
Copy link
Contributor Author

yes please, we should limit to 63 as well

Thanks. Will update.

@cbodley
Copy link
Contributor

cbodley commented May 14, 2019

jenkins render docs

@ceph-jenkins
Copy link
Collaborator

Doc render available at http://docs.ceph.com/ceph-prs/26787/

doc/radosgw/s3/bucketops.rst Outdated Show resolved Hide resolved
src/rgw/rgw_rest_s3.h Show resolved Hide resolved
@soumyakoduri soumyakoduri force-pushed the bucket_name_validation branch 2 times, most recently from ce57225 to bb855e0 Compare May 19, 2019 14:50
@soumyakoduri
Copy link
Contributor Author

jenkins render docs

@ceph-jenkins
Copy link
Collaborator

Doc render available at http://docs.ceph.com/ceph-prs/26787/

@cbodley
Copy link
Contributor

cbodley commented Jun 4, 2019

retest this please

@cbodley cbodley added needs-qa and removed needs-doc labels Jun 4, 2019
@cbodley
Copy link
Contributor

cbodley commented Jun 4, 2019

issue#36293

could you please replace this part of the commit message with:

Fixes: https://tracker.ceph.com/issues/36293

@soumyakoduri
Copy link
Contributor Author

Fixes: https://tracker.ceph.com/issues/36293

Done.

@soumyakoduri soumyakoduri force-pushed the bucket_name_validation branch 2 times, most recently from c76492b to 2b1bd35 Compare July 3, 2019 16:19
@soumyakoduri
Copy link
Contributor Author

@soumyakoduri one last piece of documentation that i'd like to see is in PendingReleaseNotes; we should make it clear that a) the bucket naming restrictions are changing, b) the changes are likely to cause InvalidBucketName errors, and c) that rgw_relaxed_s3_bucket_names=true is recommended as a workaround

Done. Please review.

@monschein
Copy link

Hi all. I've tested this PR locally and I see that it is missing one rule for bucket names. Per the AWS S3 specification:

Each label must start and end with a lowercase letter or a number.

https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html

$ s3cmd mb s3://nametest.
Bucket 's3://nametest./' created

I am able to create buckets that end with a period.

@soumyakoduri
Copy link
Contributor Author

Hi all. I've tested this PR locally and I see that it is missing one rule for bucket names. Per the AWS S3 specification:

Each label must start and end with a lowercase letter or a number.

https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html

$ s3cmd mb s3://nametest.
Bucket 's3://nametest./' created

I am able to create buckets that end with a period.

Thanks David. I was referring to https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-s3-bucket-naming-requirements.html while working on this. That page must not have been updated with this rule.

@cbodley .. please let me know your thoughts.

@cbodley
Copy link
Contributor

cbodley commented Jul 8, 2019

good catch @monschein!

@alimaredia
Copy link
Contributor

jenkins retest this please

@robbat2
Copy link
Contributor

robbat2 commented Jul 31, 2019

@soumyakoduri One of my asking items is that RGW gets TWO toggles for bucket names: one toggle for strict bucket names on creation, and the other that still permits access to pre-existing buckets with names that can no longer be created. Can you confirm this is implemented in your PR?

@cbodley
Copy link
Contributor

cbodley commented Aug 1, 2019

@robbat2 verifying that existing buckets with invalid names are still accessible is important, yeah. can you think of a reason, though, that an admin would want to deny access to existing buckets? what motivates that second toggle/config option?

@robbat2
Copy link
Contributor

robbat2 commented Aug 1, 2019

@robbat2 verifying that existing buckets with invalid names are still accessible is important, yeah. can you think of a reason, though, that an admin would want to deny access to existing buckets? what motivates that second toggle/config option?

Specifically announcing a migration plan, and locking the old names at part of the enforcement stick.

@soumyakoduri
Copy link
Contributor Author

@robbat2 verifying that existing buckets with invalid names are still accessible is important, yeah. can you think of a reason, though, that an admin would want to deny access to existing buckets? what motivates that second toggle/config option?

I verified this use-case -

  • Create relaxed bucket name (eg., bucket_underscore)
  • Toggle s3 relaxed bucket name option (to false)
  • Try to create an object in 'bucket_underscore'. The request fails now.

Seems like the s3 bucket name is validated for every request which contains bucket name in 'postauth_init()'. As of now there is no option to toggle that behavior. To let old buckets (with invalid names) to be used post migration/upgrade, admin needs to set option "rgw relaxed s3 bucket names" to true.

@soumyakoduri
Copy link
Contributor Author

jenkins retest this please

@soumyakoduri
Copy link
Contributor Author

@robbat2 verifying that existing buckets with invalid names are still accessible is important, yeah. can you think of a reason, though, that an admin would want to deny access to existing buckets? what motivates that second toggle/config option?

I verified this use-case -

* Create relaxed bucket name (eg., bucket_underscore)

* Toggle s3 relaxed bucket name option (to false)

* Try to create an object in 'bucket_underscore'. The request fails now.

Seems like the s3 bucket name is validated for every request which contains bucket name in 'postauth_init()'. As of now there is no option to toggle that behavior. To let old buckets (with invalid names) to be used post migration/upgrade, admin needs to set option "rgw relaxed s3 bucket names" to true.

To avoid the old names becoming inaccessible post migration, we decided to validate s3 bucket names only during bucket creation now. This way old buckets (with relaxed names) can still be operated post migration but no new buckets with those invalid names can be created by default.

If any need arises in future to enforce this validation for all requests , a new option can be added to toggle this behavior. But it is not being addressed as part of this PR.

src/rgw/rgw_rest_s3.cc Outdated Show resolved Hide resolved
As per amazon s3 spec -
https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html

* The s3 bucket names should not contain upper case letters or underscore.
* Name cannot end with dash or have consecutive periods, or dashes adjacent
  to periods.
* Each label in the bucket name must start and end with a lowercase
  letter or a number.
* Name cannot exceed 63 characters.

This change is to enforce these rules if rgw_relaxed_s3_bucket_names is set to
'false' which is by default.

Fixes: https://tracker.ceph.com/issues/36293

Signed-off-by: Soumya Koduri <skoduri@redhat.com>
@soumyakoduri
Copy link
Contributor Author

jenkins retest this please

@cbodley
Copy link
Contributor

cbodley commented Aug 9, 2019

jenkins test make check

1 similar comment
@soumyakoduri
Copy link
Contributor Author

jenkins test make check

@soumyakoduri
Copy link
Contributor Author

jenkins retest

@cbodley cbodley merged commit f0575a7 into ceph:master Aug 16, 2019
@cbodley
Copy link
Contributor

cbodley commented Aug 16, 2019

@soumyakoduri thanks for working through all the issues in testing!

cbodley pushed a commit to ceph/ragweed that referenced this pull request Aug 16, 2019
As per Amazon s3 spec, bucket names cannot contain
underscore.
https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-s3-bucket-naming-requirements.html

This (along with other naming convention mentioned in the doc) are being
enforced via ceph/ceph#26787

This patch is to correct the bucket name generated in ragweed
tests as well.

Signed-off-by: Soumya Koduri <skoduri@redhat.com>
(cherry picked from commit 7d4a729)
cbodley pushed a commit to cbodley/s3-tests that referenced this pull request Sep 24, 2019
As per amazon s3 spec -
https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-s3-bucket-naming-requirements.html

The s3 bucket names should not contain upper case letters or underscore.
Name cannot end with dash or have consecutive periods, or dashes adjacent to periods
Name length shouldn't exceed 63 characters.

These rules are being enforced via
- ceph/ceph#26787

This patch is to update the respective testcases as well.

Note: check_invalid_bucket_name() seems to have been broken. It should
try to create bucket using invalid name. Have addressed it in this
patch. Because of this few testcases (which were incorrectly passing
earlier) are failing in validate_bucket_name. Have marked them
'fails_on_rgw' as done for test_bucket_create_naming_bad_punctuation

Signed-off-by: Soumya Koduri <skoduri@redhat.com>
@soumyakoduri soumyakoduri deleted the bucket_name_validation branch June 17, 2021 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
7 participants