MCPcopy Index your code
hub / github.com/scality/cloudserver / getOperation

Function getOperation

lib/utilities/serverAccessLogger.js:288–340  ·  view source on GitHub ↗
(req)

Source from the content-addressed store, hash-verified

286});
287
288function getOperation(req) {
289 const resourceType = methodToResType[req.apiMethod];
290
291 if (req.serverAccessLog && req.serverAccessLog.backbeat) {
292 if (req.serverAccessLog.expiration) {
293 return 'S3.EXPIRE.OBJECT';
294 }
295 if (req.serverAccessLog.replication) {
296 if (req.serverAccessLog.deleteMarker) {
297 return 'REST.DELETE.OBJECT';
298 }
299 if (req.serverAccessLog.tagging) {
300 return 'REST.PUT.OBJECT_TAGGING';
301 }
302 if (req.serverAccessLog.acl) {
303 return 'REST.PUT.ACL';
304 }
305 return 'REST.PUT.OBJECT';
306 }
307 return `REST.${req.method}.BACKBEAT`;
308 }
309
310 // Special handling for copy operations
311 if (req.apiMethod === 'objectCopy') {
312 return 'REST.COPY.OBJECT';
313 }
314 if (req.apiMethod === 'objectPutCopyPart') {
315 return 'REST.COPY.PART';
316 }
317 // Special handling for website operations
318 if (req.apiMethod === 'websiteGet') {
319 return 'WEBSITE.GET.OBJECT';
320 }
321 if (req.apiMethod === 'websiteHead') {
322 return 'WEBSITE.HEAD.OBJECT';
323 }
324
325 if (!resourceType) {
326 // Only emit a warning if apiMethod is not undefined, meaning request is valid.
327 // Otherwise we could get spam by invalid or broken requests.
328 // To help catch missing valid operation.
329 if (req.apiMethod) {
330 process.emitWarning('Unknown apiMethod for server access log', {
331 type: 'ServerAccessLogWarning',
332 code: 'UNKNOWN_API_METHOD',
333 detail: `apiMethod=${req.apiMethod}, method=${req.method}, url=${req.url}`
334 });
335 }
336 return `REST.${req.method}.UNKNOWN`;
337 }
338
339 return `REST.${req.method}.${resourceType}`;
340}
341
342const assumedRoleArnRegex = /^arn:aws:sts::[0-9]{12}:assumed-role\/\S+$/;
343

Callers 2

logServerAccessFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected