-
Couldn't load subscription status.
- Fork 411
RI-7200 add request metadata to session metadata and exclude it from … #4771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RI-7200 add request metadata to session metadata and exclude it from … #4771
Conversation
There was a problem hiding this 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
requestMetadatafield toSessionMetadatawith security group exposure control - Implements
logDataToPlainfunction 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); |
Copilot
AI
Jul 30, 2025
There was a problem hiding this comment.
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.
| return instanceToPlain(value); | |
| return instanceToPlain(value, { groups: [] }); |
| return logData.join(separator); | ||
| }); | ||
|
|
||
| const MAX_DEPTH = 10; |
Copilot
AI
Jul 30, 2025
There was a problem hiding this comment.
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.
| const MAX_DEPTH = 10; |
| @IsOptional() | ||
| requestMetadata?: Record<string, any> = {}; | ||
|
|
||
| @Expose() |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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'] }) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
…logs