Skip to content

Commit 1bf8301

Browse files
author
Kerkesni
committed
do not allow crr location as an object locationConstraint
Issue: CLDSRV-653
1 parent f7061bb commit 1bf8301

File tree

6 files changed

+115
-44
lines changed

6 files changed

+115
-44
lines changed

lib/api/objectCopy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ function _prepMetadata(request, sourceObjMD, headers, sourceIsDestination,
130130
const backendInfoObjDest = locationConstraintCheck(request,
131131
userMetadata, destBucketMD, log);
132132
if (backendInfoObjDest.err) {
133-
return { error: backendInfoObjSource.err };
133+
return { error: backendInfoObjDest.err };
134134
}
135135
const destLocationConstraintName = backendInfoObjDest.controllingLC;
136136

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"dependencies": {
2222
"@azure/storage-blob": "^12.25.0",
2323
"@hapi/joi": "^17.1.1",
24-
"arsenal": "git+https://github.com/scality/Arsenal#8.2.18",
24+
"arsenal": "git+https://github.com/scality/Arsenal#c102852d95d5ac91fd726d9f37a4faaf65ed6443",
2525
"async": "2.6.4",
2626
"aws-sdk": "^2.1692.0",
2727
"bucketclient": "scality/bucketclient#8.2.4",

tests/unit/api/multipartUpload.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2174,6 +2174,32 @@ describe('Multipart Upload API', () => {
21742174
},
21752175
], done);
21762176
});
2177+
2178+
it('should fail to initiate a multipart upload if location constraint is crr', done => {
2179+
const initiateRequest = {
2180+
socket: {
2181+
remoteAddress: '1.1.1.1',
2182+
},
2183+
bucketName,
2184+
namespace,
2185+
objectKey,
2186+
headers: {
2187+
host: `${bucketName}.s3.amazonaws.com`,
2188+
[constants.objectLocationConstraintHeader]: 'location-crr-v1',
2189+
},
2190+
url: `/${objectKey}?uploads`,
2191+
actionImplicitDenies: false,
2192+
};
2193+
2194+
bucketPut(authInfo, bucketPutRequest, log, err => {
2195+
assert.ifError(err);
2196+
initiateMultipartUpload(authInfo, initiateRequest,
2197+
log, err => {
2198+
assert(err.is.InvalidArgument);
2199+
done();
2200+
});
2201+
});
2202+
});
21772203
});
21782204

21792205
describe('complete mpu with versioning', () => {

tests/unit/api/objectCopy.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ function _createBucketPutRequest(bucketName) {
3939
});
4040
}
4141

42-
function _createObjectCopyRequest(destBucketName) {
42+
function _createObjectCopyRequest(destBucketName, headers = {}) {
4343
const params = {
4444
bucketName: destBucketName,
4545
namespace,
4646
objectKey,
47-
headers: {},
47+
headers,
4848
url: `/${destBucketName}/${objectKey}`,
4949
socket: {},
5050
};
@@ -231,6 +231,7 @@ describe('non-versioned objectCopy', () => {
231231
cleanup();
232232
sinon.stub(metadata, 'putObjectMD')
233233
.callsFake(originalputObjectMD);
234+
234235
async.series([
235236
callback => bucketPut(authInfo, putDestBucketRequest, log,
236237
callback),
@@ -338,6 +339,22 @@ describe('non-versioned objectCopy', () => {
338339
},
339340
], done);
340341
});
342+
343+
it('should fail to copy object when setting a crr location as the locationConstraint', done => {
344+
const testObjectCopyRequest = _createObjectCopyRequest(destBucketName, {
345+
'x-amz-metadata-directive': 'REPLACE', // needed to take the locationConstraint into account
346+
[objectLocationConstraintHeader]: 'location-crr-v1',
347+
});
348+
349+
async.series([
350+
next => objectPut(authInfo, testPutDestObjectRequest, undefined, log, next),
351+
next => objectCopy(authInfo, testObjectCopyRequest, sourceBucketName, objectKey,
352+
undefined, log, next),
353+
], err => {
354+
assert(err.is.InvalidArgument);
355+
done();
356+
});
357+
});
341358
});
342359

343360
describe('objectCopy overheadField', () => {

tests/unit/api/objectPut.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,27 @@ describe('objectPut API', () => {
843843
});
844844
});
845845
});
846+
847+
it('should fail to put object when setting a crr location as the locationConstraint', done => {
848+
const testPutObjectRequest = new DummyRequest({
849+
bucketName,
850+
namespace,
851+
objectKey: objectName,
852+
headers: {
853+
[objectLocationConstraintHeader]: 'location-crr-v1',
854+
},
855+
url: `/${bucketName}/${objectName}`,
856+
calculatedHash: 'vnR+tLdVF79rPPfF+7YvOg==',
857+
}, postBody);
858+
859+
bucketPut(authInfo, testPutBucketRequest, log, () => {
860+
objectPut(authInfo, testPutObjectRequest, undefined, log,
861+
err => {
862+
assert(err.is.InvalidArgument);
863+
done();
864+
});
865+
});
866+
});
846867
});
847868

848869
describe('objectPut API with versioning', () => {

yarn.lock

Lines changed: 47 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,10 @@
173173
fast-xml-parser "^5.0.7"
174174
tslib "^2.8.1"
175175

176-
"@azure/identity@^4.5.0":
177-
version "4.8.0"
178-
resolved "https://registry.yarnpkg.com/@azure/identity/-/identity-4.8.0.tgz#686682683a470ccf4dbb2597ee234f9c5c483a40"
179-
integrity sha512-l9ALUGHtFB/JfsqmA+9iYAp2a+cCwdNO/cyIr2y7nJLJsz1aae6qVP8XxT7Kbudg0IQRSIMXj0+iivFdbD1xPA==
176+
"@azure/identity@^4.10.0":
177+
version "4.10.0"
178+
resolved "https://registry.yarnpkg.com/@azure/identity/-/identity-4.10.0.tgz#10cfe49207b4d111ebe3aab3ade47561c2852c6d"
179+
integrity sha512-iT53Sre2NJK6wzMWnvpjNiR3md597LZ3uK/5kQD2TkrY9vqhrY5bt2KwELNjkOWQ9n8S/92knj/QEykTtjMNqQ==
180180
dependencies:
181181
"@azure/abort-controller" "^2.0.0"
182182
"@azure/core-auth" "^1.9.0"
@@ -186,17 +186,14 @@
186186
"@azure/core-util" "^1.11.0"
187187
"@azure/logger" "^1.0.0"
188188
"@azure/msal-browser" "^4.2.0"
189-
"@azure/msal-node" "^3.2.3"
190-
events "^3.0.0"
191-
jws "^4.0.0"
189+
"@azure/msal-node" "^3.5.0"
192190
open "^10.1.0"
193-
stoppable "^1.1.0"
194191
tslib "^2.2.0"
195192

196-
"@azure/identity@^4.9.1":
197-
version "4.9.1"
198-
resolved "https://registry.yarnpkg.com/@azure/identity/-/identity-4.9.1.tgz#ee4b9435f1b96bea5985e7dec989760a67d9a119"
199-
integrity sha512-986D7Cf1AOwYqSDtO/FnMAyk/Jc8qpftkGsxuehoh4F85MhQ4fICBGX/44+X1y78lN4Sqib3Bsoaoh/FvOGgmg==
193+
"@azure/identity@^4.5.0":
194+
version "4.8.0"
195+
resolved "https://registry.yarnpkg.com/@azure/identity/-/identity-4.8.0.tgz#686682683a470ccf4dbb2597ee234f9c5c483a40"
196+
integrity sha512-l9ALUGHtFB/JfsqmA+9iYAp2a+cCwdNO/cyIr2y7nJLJsz1aae6qVP8XxT7Kbudg0IQRSIMXj0+iivFdbD1xPA==
200197
dependencies:
201198
"@azure/abort-controller" "^2.0.0"
202199
"@azure/core-auth" "^1.9.0"
@@ -206,8 +203,11 @@
206203
"@azure/core-util" "^1.11.0"
207204
"@azure/logger" "^1.0.0"
208205
"@azure/msal-browser" "^4.2.0"
209-
"@azure/msal-node" "^3.5.0"
206+
"@azure/msal-node" "^3.2.3"
207+
events "^3.0.0"
208+
jws "^4.0.0"
210209
open "^10.1.0"
210+
stoppable "^1.1.0"
211211
tslib "^2.2.0"
212212

213213
"@azure/logger@^1.0.0":
@@ -1296,32 +1296,37 @@ arraybuffer.prototype.slice@^1.0.4:
12961296
get-intrinsic "^1.2.6"
12971297
is-array-buffer "^3.0.4"
12981298

1299-
"arsenal@git+https://github.com/scality/Arsenal#8.2.18":
1300-
version "8.2.18"
1301-
resolved "git+https://github.com/scality/Arsenal#6d0165b870575d77f265bd3dd98b1ca875ebaa06"
1299+
"arsenal@git+https://github.com/scality/Arsenal#8.2.4":
1300+
version "8.2.4"
1301+
resolved "git+https://github.com/scality/Arsenal#96ef6a3e26d7528f877300606586759f1da6d0cd"
13021302
dependencies:
1303-
"@azure/identity" "^4.9.1"
1304-
"@azure/storage-blob" "^12.27.0"
1303+
"@azure/identity" "^4.5.0"
1304+
"@azure/storage-blob" "^12.25.0"
1305+
"@eslint/plugin-kit" "^0.2.3"
13051306
"@js-sdsl/ordered-set" "^4.4.2"
13061307
"@scality/hdclient" "^1.3.1"
1308+
"@types/async" "^3.2.24"
1309+
"@types/utf8" "^3.0.3"
13071310
JSONStream "^1.3.5"
1308-
agentkeepalive "^4.6.0"
1311+
agentkeepalive "^4.5.0"
13091312
ajv "6.12.3"
13101313
async "~2.6.4"
13111314
aws-sdk "^2.1691.0"
13121315
backo "^1.1.0"
13131316
base-x "3.0.8"
13141317
base62 "^2.0.2"
1318+
bson "^6.8.0"
13151319
debug "^4.3.7"
1320+
diskusage "^1.2.0"
13161321
fcntl "github:scality/node-fcntl#0.3.0"
13171322
httpagent scality/httpagent#1.1.0
1318-
https-proxy-agent "^7.0.6"
1319-
ioredis "^5.6.1"
1323+
https-proxy-agent "^7.0.5"
1324+
ioredis "^5.4.1"
13201325
ipaddr.js "^2.2.0"
13211326
joi "^17.13.3"
13221327
level "~5.0.1"
13231328
level-sublevel "~6.6.5"
1324-
mongodb "^6.16.0"
1329+
mongodb "^6.11.0"
13251330
node-forge "^1.3.1"
13261331
prom-client "^15.1.3"
13271332
simple-glob "^0.2.0"
@@ -1335,9 +1340,9 @@ arraybuffer.prototype.slice@^1.0.4:
13351340
optionalDependencies:
13361341
ioctl "^2.0.2"
13371342

1338-
"arsenal@git+https://github.com/scality/Arsenal#8.2.4":
1339-
version "8.2.4"
1340-
resolved "git+https://github.com/scality/Arsenal#96ef6a3e26d7528f877300606586759f1da6d0cd"
1343+
"arsenal@git+https://github.com/scality/Arsenal#8.2.6":
1344+
version "8.2.6"
1345+
resolved "git+https://github.com/scality/Arsenal#ae9f1ec9e93da10c20c22e7197cd92dcc082ba08"
13411346
dependencies:
13421347
"@azure/identity" "^4.5.0"
13431348
"@azure/storage-blob" "^12.25.0"
@@ -1379,37 +1384,32 @@ arraybuffer.prototype.slice@^1.0.4:
13791384
optionalDependencies:
13801385
ioctl "^2.0.2"
13811386

1382-
"arsenal@git+https://github.com/scality/Arsenal#8.2.6":
1383-
version "8.2.6"
1384-
resolved "git+https://github.com/scality/Arsenal#ae9f1ec9e93da10c20c22e7197cd92dcc082ba08"
1387+
"arsenal@git+https://github.com/scality/Arsenal#c102852d95d5ac91fd726d9f37a4faaf65ed6443":
1388+
version "8.2.19"
1389+
resolved "git+https://github.com/scality/Arsenal#c102852d95d5ac91fd726d9f37a4faaf65ed6443"
13851390
dependencies:
1386-
"@azure/identity" "^4.5.0"
1387-
"@azure/storage-blob" "^12.25.0"
1388-
"@eslint/plugin-kit" "^0.2.3"
1391+
"@azure/identity" "^4.10.0"
1392+
"@azure/storage-blob" "^12.27.0"
13891393
"@js-sdsl/ordered-set" "^4.4.2"
13901394
"@scality/hdclient" "^1.3.1"
1391-
"@types/async" "^3.2.24"
1392-
"@types/utf8" "^3.0.3"
13931395
JSONStream "^1.3.5"
1394-
agentkeepalive "^4.5.0"
1396+
agentkeepalive "^4.6.0"
13951397
ajv "6.12.3"
13961398
async "~2.6.4"
13971399
aws-sdk "^2.1691.0"
13981400
backo "^1.1.0"
13991401
base-x "3.0.8"
14001402
base62 "^2.0.2"
1401-
bson "^6.8.0"
1402-
debug "^4.3.7"
1403-
diskusage "^1.2.0"
1403+
debug "^4.4.1"
14041404
fcntl "github:scality/node-fcntl#0.3.0"
14051405
httpagent scality/httpagent#1.1.0
1406-
https-proxy-agent "^7.0.5"
1407-
ioredis "^5.4.1"
1406+
https-proxy-agent "^7.0.6"
1407+
ioredis "^5.6.1"
14081408
ipaddr.js "^2.2.0"
14091409
joi "^17.13.3"
14101410
level "~5.0.1"
14111411
level-sublevel "~6.6.5"
1412-
mongodb "^6.11.0"
1412+
mongodb "^6.16.0"
14131413
node-forge "^1.3.1"
14141414
prom-client "^15.1.3"
14151415
simple-glob "^0.2.0"
@@ -2110,6 +2110,13 @@ debug@^3.1.0, debug@^3.2.7:
21102110
dependencies:
21112111
ms "^2.1.1"
21122112

2113+
debug@^4.4.1:
2114+
version "4.4.1"
2115+
resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.1.tgz#e5a8bc6cbc4c6cd3e64308b0693a3d4fa550189b"
2116+
integrity sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==
2117+
dependencies:
2118+
ms "^2.1.3"
2119+
21132120
debug@~4.3.1, debug@~4.3.2, debug@~4.3.4:
21142121
version "4.3.7"
21152122
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.7.tgz#87945b4151a011d76d95a198d7111c865c360a52"

0 commit comments

Comments
 (0)