Skip to content

Conversation

@ArtemHoruzhenko
Copy link
Collaborator

…logs

@ArtemHoruzhenko ArtemHoruzhenko marked this pull request as ready for review July 30, 2025 07:44
@pawelangelow pawelangelow requested a review from Copilot July 30, 2025 07:49
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds request metadata to session metadata while ensuring it's excluded from logs for security purposes. The implementation uses class-transformer groups to control when sensitive request metadata is serialized.

  • Adds requestMetadata field to SessionMetadata with security group exposure control
  • Implements logDataToPlain function to sanitize log data and exclude sensitive metadata
  • Updates logging infrastructure to use the new sanitization function

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
redisinsight/api/src/common/models/session.ts Adds requestMetadata field with security group exposure
redisinsight/api/src/utils/logsFormatter.ts Implements logDataToPlain function for log sanitization
redisinsight/api/src/common/logger/app-logger.ts Updates logging to use new sanitization functions
redisinsight/api/src/common/decorators/session/session-metadata.decorator.ts Extracts and includes requestMetadata in session creation
redisinsight/api/src/common/decorators/client-metadata/client-metadata.decorator.ts Adds security groups to client metadata transformation
redisinsight/api/src/common/models/client-metadata.ts Updates type reference from Session to SessionMetadata

seen.add(value);

if (!isPlainObject(value)) {
return instanceToPlain(value);
Copy link

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The instanceToPlain call doesn't specify transformation groups, which could expose sensitive data. Since this function is used for logging, it should exclude security-sensitive fields by not including the 'security' group in the transformation options.

Suggested change
return instanceToPlain(value);
return instanceToPlain(value, { groups: [] });

Copilot uses AI. Check for mistakes.
return logData.join(separator);
});

const MAX_DEPTH = 10;
Copy link

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The MAX_DEPTH constant should be moved to the top of the file with other constants or configuration values for better maintainability and consistency with the existing LOGGER_CONFIG pattern.

Suggested change
const MAX_DEPTH = 10;

Copilot uses AI. Check for mistakes.
@IsOptional()
requestMetadata?: Record<string, any> = {};

@Expose()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we expose all of those? For example sessionId?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@IsObject()
data?: Record<string, any> = {};

@Expose({ groups: ['security'] })
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this should become Groups.Security constant as it's on a lot of places

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct but it is not a single place. Didn't want to introduce more changes in bunch of not related to this PR files

@ArtemHoruzhenko ArtemHoruzhenko merged commit 3d232d8 into main Jul 30, 2025
8 checks passed
@ArtemHoruzhenko ArtemHoruzhenko deleted the be/feature/RI-7200-add-request-meta-to-session-metadata branch July 30, 2025 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants