Skip to content

Commit cd4b15e

Browse files
committed
Merge branch 'bug/CLDSRV-699' into q/9.1
2 parents 4edfe4c + c0b1d0c commit cd4b15e

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

constants.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,20 @@ const constants = {
8989
// Maximum HTTP headers size allowed
9090
maxHttpHeadersSize: 14122,
9191

92+
// AWS sets the maximum number of objects deleted to 1000 for multiDeleteObjects
93+
// https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObjects.html
94+
maxMultiObjectDeleteLen: 1000,
95+
96+
oneMegaBytes: 1024 * 1024,
97+
halfMegaBytes: 512 * 1024,
98+
99+
// Some apis may need a custom body length limit :
100+
apisLengthLimits: {
101+
// Multi Objects Delete request can be large : up to 1000 keys of 1024 bytes is
102+
// already 1mb, with the other fields it could reach 2mb
103+
'multiObjectDelete': 2 * 1024 * 1024,
104+
},
105+
92106
// hex digest of sha256 hash of empty string:
93107
emptyStringHash: crypto.createHash('sha256')
94108
.update('', 'binary').digest('hex'),
@@ -252,4 +266,5 @@ const constants = {
252266
onlyOwnerAllowed: ['bucketDeletePolicy', 'bucketGetPolicy', 'bucketPutPolicy'],
253267
};
254268

269+
255270
module.exports = constants;

lib/api/api.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ const parseCopySource = require('./apiUtils/object/parseCopySource');
7474
const { tagConditionKeyAuth } = require('./apiUtils/authorization/tagConditionKeys');
7575
const { isRequesterASessionUser } = require('./apiUtils/authorization/permissionChecks');
7676
const checkHttpHeadersSize = require('./apiUtils/object/checkHttpHeadersSize');
77+
const constants = require('../../constants');
7778

7879
const monitoringMap = policies.actionMaps.actionMonitoringMapS3;
7980

@@ -219,8 +220,10 @@ const api = {
219220
}
220221
// issue 100 Continue to the client
221222
writeContinue(request, response);
222-
const MAX_POST_LENGTH = request.method === 'POST' ?
223-
1024 * 1024 : 1024 * 1024 / 2; // 1 MB or 512 KB
223+
224+
const defaultMaxPostLength = request.method === 'POST' ?
225+
constants.oneMegaBytes : constants.halfMegaBytes;
226+
const MAX_POST_LENGTH = constants.apisLengthLimits[apiMethod] || defaultMaxPostLength;
224227
const post = [];
225228
let postLength = 0;
226229
request.on('data', chunk => {

lib/api/multiObjectDelete.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const createAndStoreObject = require('./apiUtils/object/createAndStoreObject');
1919
const monitoring = require('../utilities/monitoringHandler');
2020
const metadataUtils = require('../metadata/metadataUtils');
2121
const { config } = require('../Config');
22+
const constants = require('../../constants');
2223
const { isRequesterNonAccountUser } = require('./apiUtils/authorization/permissionChecks');
2324
const { hasGovernanceBypassHeader, checkUserGovernanceBypass, ObjectLockInfo }
2425
= require('./apiUtils/object/objectLockHelpers');
@@ -492,7 +493,7 @@ function multiObjectDelete(authInfo, request, log, callback) {
492493
function parseXML(next) {
493494
return _parseXml(request.post,
494495
(err, quietSetting, objects) => {
495-
if (err || objects.length < 1 || objects.length > 1000) {
496+
if (err || objects.length < 1 || objects.length > constants.maxMultiObjectDeleteLen) {
496497
return next(errors.MalformedXML);
497498
}
498499
return next(null, quietSetting, objects);

0 commit comments

Comments
 (0)