File tree Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -198,6 +198,22 @@ config.S3_RESTORE_REQUEST_MAX_DAYS = 30;
198
198
*/
199
199
config . S3_RESTORE_REQUEST_MAX_DAYS_BEHAVIOUR = 'TRUNCATE' ;
200
200
201
+ /**
202
+ * S3_MAX_KEY_LENGTH controls the maximum key length that will be accepted
203
+ * by NooBaa endpoints.
204
+ *
205
+ * This value is 1024 bytes for S3 but the default is `Infinity`
206
+ */
207
+ config . S3_MAX_KEY_LENGTH = Infinity ;
208
+
209
+ /**
210
+ * S3_MAX_BUCKET_NAME_LENGTH controls the maximum bucket name length that
211
+ * will be accepted by NooBaa endpoints.
212
+ *
213
+ * This value is 63 bytes for S3 but the default is `Infinity`
214
+ */
215
+ config . S3_MAX_BUCKET_NAME_LENGTH = Infinity ;
216
+
201
217
/////////////////////
202
218
// SECRETS CONFIG //
203
219
/////////////////////
Original file line number Diff line number Diff line change @@ -249,8 +249,8 @@ S3Error.InvalidURI = Object.freeze({
249
249
message : 'Couldn\'t parse the specified URI.' ,
250
250
http_code : 400 ,
251
251
} ) ;
252
- S3Error . KeyTooLong = Object . freeze ( {
253
- code : 'KeyTooLong ' ,
252
+ S3Error . KeyTooLongError = Object . freeze ( {
253
+ code : 'KeyTooLongError ' ,
254
254
message : 'Your key is too long.' ,
255
255
http_code : 400 ,
256
256
} ) ;
Original file line number Diff line number Diff line change @@ -362,6 +362,14 @@ function get_bucket_and_key(req) {
362
362
key = suffix ;
363
363
}
364
364
}
365
+
366
+ if ( key ?. length > config . S3_MAX_KEY_LENGTH ) {
367
+ throw new S3Error ( S3Error . KeyTooLongError ) ;
368
+ }
369
+ if ( bucket ?. length > config . S3_MAX_BUCKET_NAME_LENGTH ) {
370
+ throw new S3Error ( S3Error . InvalidBucketName ) ;
371
+ }
372
+
365
373
return {
366
374
bucket,
367
375
// decode and replace hadoop _$folder$ in key
You can’t perform that action at this time.
0 commit comments