MCPcopy
hub / github.com/scality/cloudserver / bucketShield

Function bucketShield

lib/api/apiUtils/bucket/bucketShield.js:11–41  ·  view source on GitHub ↗

* Checks whether to proceed with a request based on the bucket flags * and sends a request to invisibly delete the bucket if applicable * @param {object} bucket - bucket metadata * @param {string} requestType - type of api request * @return {boolean} true if the bucket should be shielded, false

(bucket, requestType)

Source from the content-addressed store, hash-verified

9 * @return {boolean} true if the bucket should be shielded, false otherwise
10 */
11function bucketShield(bucket, requestType) {
12 const invisiblyDeleteRequests = constants.bucketOwnerActions.concat(
13 [
14 'bucketGet',
15 'bucketHead',
16 'bucketGetACL',
17 'objectGet',
18 'objectGetACL',
19 'objectHead',
20 'objectPutACL',
21 'objectDelete',
22 ]);
23 if (invisiblyDeleteRequests.indexOf(requestType) > -1 &&
24 bucket.hasDeletedFlag()) {
25 invisiblyDelete(bucket.getName(), bucket.getOwner());
26 return true;
27 }
28 // If request is initiateMultipartUpload (requestType objectPut),
29 // objectPut, bucketPutACL or bucketDelete, proceed with request.
30 // Otherwise return an error to the client
31 if ((bucket.hasDeletedFlag() || bucket.hasTransientFlag()) &&
32 (requestType !== 'objectPut' &&
33 requestType !== 'initiateMultipartUpload' &&
34 requestType !== 'objectPutPart' &&
35 requestType !== 'completeMultipartUpload' &&
36 requestType !== 'bucketPutACL' &&
37 requestType !== 'bucketDelete')) {
38 return true;
39 }
40 return false;
41}
42
43module.exports = bucketShield;

Callers 4

validateBucketFunction · 0.85
corsPreflightFunction · 0.85
multiObjectDeleteFunction · 0.85
websiteFunction · 0.85

Calls 2

invisiblyDeleteFunction · 0.85
getOwnerMethod · 0.80

Tested by

no test coverage detected