Skip to content

Commit 9397b79

Browse files
committed
CLDSRV-750: disable Put/GetBucketLogging if it is disabled in the config
1 parent 757c15b commit 9397b79

File tree

8 files changed

+31
-1
lines changed

8 files changed

+31
-1
lines changed

.github/docker/config.s3c.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,9 @@
6161
"host": "localhost:6000"
6262
}
6363
],
64-
"enableVeeamRoute": false
64+
"enableVeeamRoute": false,
65+
"serverAccessLogs": {
66+
"enabled": true,
67+
"outputFile": "/logs/server-access.log"
68+
}
6569
}

.github/docker/docker-compose.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ services:
4646
- S3QUOTA
4747
- QUOTA_ENABLE_INFLIGHTS
4848
- S3_VERSION_ID_ENCODING_TYPE
49+
- S3_ENABLE_SERVER_ACCESS_LOGS=true
4950
env_file:
5051
- creds.env
5152
depends_on:

lib/Config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,10 @@ function parseServerAccessLogs(config) {
592592
}
593593
}
594594

595+
if (process.env.S3_ENABLE_SERVER_ACCESS_LOGS === 'true') {
596+
res.enabled = true;
597+
}
598+
595599
return res;
596600
}
597601

lib/api/bucketGetLogging.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@ const { standardMetadataValidateBucket } = require('../metadata/metadataUtils');
22
const { checkExpectedBucketOwner } = require('./apiUtils/authorization/bucketOwner');
33
const monitoring = require('../utilities/monitoringHandler');
44
const { waterfall } = require('async');
5+
const { config } = require('../Config');
6+
const { errorInstances } = require('arsenal');
57

68
const BucketLoggingStatusNotFoundBody = '<?xml version="1.0" encoding="UTF-8"?>\n' +
79
'<BucketLoggingStatus xmlns="http://doc.s3.amazonaws.com/2006-03-01" />';
810

911
function bucketGetLogging(authInfo, request, log, callback) {
1012
log.debug('processing request', { method: 'bucketGetLogging' });
1113

14+
if (!config.serverAccessLogs || !config.serverAccessLogs.enabled) {
15+
return callback(errorInstances.NotImplemented);
16+
}
17+
1218
const bucketName = request.bucketName;
1319
const metadataValParams = {
1420
authInfo,

lib/api/bucketPutLogging.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@ const BucketLoggingStatus = require('arsenal').models.BucketLoggingStatus;
55
const metadata = require('../metadata/wrapper');
66
const monitoring = require('../utilities/monitoringHandler');
77
const { errorInstances } = require('arsenal');
8+
const { config } = require('../Config');
89

910
function bucketPutLogging(authInfo, request, log, callback) {
1011
log.debug('processing request', { method: 'bucketPutLogging' });
1112

13+
if (!config.serverAccessLogs || !config.serverAccessLogs.enabled) {
14+
return callback(errorInstances.NotImplemented);
15+
}
16+
1217
const bucketName = request.bucketName;
1318
const parsed = BucketLoggingStatus.fromXML(request.post);
1419
if (parsed.error) {

tests/functional/config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,9 @@
66
"localCache": {
77
"host": "127.0.0.1",
88
"port": 6379
9+
},
10+
"serverAccessLogs": {
11+
"enabled": true,
12+
"outputFile": "/logs/server-access.log"
913
}
1014
}

tests/unit/api/bucketGetLogging.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ const otherAuthInfo = makeAuthInfo('accessKey2');
1111
const bucketName = 'bucketgetloggingtest';
1212
const targetBucket = 'loggingbucket';
1313
const namespace = 'default';
14+
const { config } = require('../../../lib/Config');
15+
16+
config.serverAccessLogs.enabled = true;
1417

1518
const testBucketPutRequest = {
1619
bucketName,

tests/unit/api/bucketPutLogging.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ const otherAuthInfo = makeAuthInfo('accessKey2');
1010
const bucketName = 'bucketputloggingtest';
1111
const targetBucket = 'loggingbucket';
1212
const namespace = 'default';
13+
const { config } = require('../../../lib/Config');
14+
15+
config.serverAccessLogs.enabled = true;
1316

1417
const testBucketPutRequest = {
1518
bucketName,

0 commit comments

Comments
 (0)