Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,18 @@ const api = {
rateLimited: true,
rateLimitSource: cachedConfig.source,
});
// Add to server access log
if (request.serverAccessLog) {
/* eslint-disable no-param-reassign */
request.serverAccessLog.rateLimited = true;
request.serverAccessLog.rateLimitSource = cachedConfig.source;
/* eslint-enable no-param-reassign */
}
return callback(config.rateLimiting.error);
}

// Set tracker - rate limiting already applied
// eslint-disable-next-line no-param-reassign
request.rateLimitAlreadyChecked = true;

// Continue with normal flow
Expand Down
8 changes: 7 additions & 1 deletion lib/metadata/metadataUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,14 @@ function checkRateLimitIfNeeded(bucket, bucketName, request, log, callback) {
rateLimited: true,
rateLimitSource: rateLimitConfig.source,
});
// eslint-disable-next-line no-param-reassign
// Add to server access log
/* eslint-disable no-param-reassign */
if (request.serverAccessLog) {
request.serverAccessLog.rateLimited = true;
request.serverAccessLog.rateLimitSource = rateLimitConfig.source;
}
request.rateLimitAlreadyChecked = true;
/* eslint-enable no-param-reassign */
return callback(config.rateLimiting.error);
}

Expand Down
4 changes: 4 additions & 0 deletions lib/utilities/serverAccessLogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,10 @@ function logServerAccess(req, res) {
loggingTargetPrefix: params.loggingEnabled ? params.loggingEnabled.TargetPrefix : null,
awsAccessKeyID: authInfo ? authInfo.getAccessKey() : null,
raftSessionID: params.raftSessionID === undefined ? null : params.raftSessionID,

// Rate Limiting fields (only present when rate limited)
rateLimited: params.rateLimited,
rateLimitSource: params.rateLimitSource,
})}\n`);
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenko/cloudserver",
"version": "9.2.6",
"version": "9.2.7",
"description": "Zenko CloudServer, an open-source Node.js implementation of a server handling the Amazon S3 protocol",
"main": "index.js",
"engines": {
Expand Down
9 changes: 9 additions & 0 deletions schema/server_access_log.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,15 @@
"raftSessionID": {
"description": "Raft session ID.",
"type": ["integer", "null"]
},
"rateLimited": {
"description": "True when the request was rate-limited. This field is emitted only when rate limiting occurs; if absent, the request was not rate-limited.",
"type": "boolean"
},
"rateLimitSource": {
"description": "Source of the rate-limit configuration that applied to this request. 'global' means the global default bucket rate limit; 'bucket' means a bucket-specific override. This field is only emitted when the request was rate-limited.",
"type": "string",
"enum": ["global", "bucket"]
}
},
"additionalProperties": false,
Expand Down
Loading