-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
fix(s3): Add validations for S3 bucket names #2256
Conversation
Bucket names are verified to conform with rules published by S3 - https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html fixes #1308
if (/\.-|-\.|\.\./.test(bucketName)) { | ||
errors.push('Bucket name must not have dash next to period, or period next to dash, or consecutive periods'); | ||
} | ||
if (/\d+\.\d+\.\d+\.\d+/.test(bucketName)) { |
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.
Is this how S3 validates? I feel like this might be prohibiting certain options that S3 would permit...
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.
Not sure if this is how S3 does it. I've reversed engineered their validations based on their rules here and manually trying out combinations.
Some of these are pretty straight forward, like length and character set, but the ones around IP and symbol combinations get more tricky.
I've picked combinations and regex that I should be more liberal than S3 (in that, S3 might have additional/stricter checks I don't have here), but would be ok with dropping the more tricky ones if you think they could potentially break customers.
What do you think?
Misused the wrong assertion method previously. `ok` assertions don't fail when the conditional throws an exception.
Each class of failed bucket name validation shows the offset of the offending character.
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.
Looks great!
As suggested on the PR review, current set of tests only validate that the offsets are computed correctly. This test verifies that the message is generated as expected.
Bucket names are verified to conform with rules published by S3 -
https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html
fixes #1308
Pull Request Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license.