From f7c406bec9d4d1a6b37a284bd4cd088e3dcae3c5 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Wed, 27 May 2020 16:58:27 -0700 Subject: [PATCH] s3: bucket name cannot contain _ or capitals or . we can make it more elaborate, but not sure if it's needed https://blogs.easydynamics.com/2016/10/24/aws-s3-bucket-name-validation-regex/ --- src/storage/s3.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/storage/s3.js b/src/storage/s3.js index 06865385e..a39c66145 100644 --- a/src/storage/s3.js +++ b/src/storage/s3.js @@ -416,6 +416,11 @@ function testConfig(apiConfig, callback) { // the node module seems to incorrectly accept bucket name with '/' if (apiConfig.bucket.includes('/')) return callback(new BoxError(BoxError.BAD_FIELD, 'bucket name cannot contain "/"', { field: 'bucket' })); + // names must be lowercase and start with a letter or number. can contain dashes + if (apiConfig.bucket.includes('_') || apiConfig.bucket.match(/[A-Z]/)) return callback(new BoxError(BoxError.BAD_FIELD, 'bucket name cannot contain "_" or capitals', { field: 'bucket' })); + + if (apiConfig.bucket.includes('.')) return callback(new BoxError(BoxError.BAD_FIELD, 'Use of bucket names with "." is discouraged. Use the "S3 API Compatible" provider and accept self-signed certificate if you really need this', { field: 'bucket' })); + if (typeof apiConfig.prefix !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'prefix must be a string', { field: 'prefix' })); if ('signatureVersion' in apiConfig && typeof apiConfig.signatureVersion !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'signatureVersion must be a string', { field: 'signatureVersion' })); if ('endpoint' in apiConfig && typeof apiConfig.endpoint !== 'string') return callback(new BoxError(BoxError.BAD_FIELD, 'endpoint must be a string', { field: 'endpoint' }));